BinerAI · Models · Docs · Pricing

BinerAI API reference

Base URL https://binerai.biner.dev. Every request and response is JSON.

Authentication

Create a token under API tokens and send it as a bearer token.

Authorization: Bearer bai_xxxxxxxxxxxxxxxxxxxx

Create a prediction

POST /v1/predictions. Returns 201 with the prediction in queued state. Send Idempotency-Key to make retries safe: the same key returns the same prediction for 24 hours.

curl -s https://binerai.biner.dev/v1/predictions \
  -H "Authorization: Bearer $BINERAI_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-8812" \
  -d '{
    "model": "black-forest-labs/flux-schnell",
    "version": "v1",
    "input": { "prompt": "a red fox in a snowy forest", "num_outputs": 2 },
    "webhook": "https://example.com/hooks/binerai"
  }'
{
  "id": "prd_d33rCGkXxt2ywp3Q8NU8Sr",
  "model": "black-forest-labs/flux-schnell",
  "version": "v1",
  "status": "queued",
  "input": { "prompt": "a red fox in a snowy forest", "num_outputs": 2, "aspect_ratio": "1:1", "num_inference_steps": 4 },
  "output": null,
  "error": null,
  "billing": { "unit": "image", "expected_units": 2, "actual_units": null, "held_usd": 0.006, "charged_usd": null },
  "urls": { "get": "https://binerai.biner.dev/v1/predictions/prd_...", "cancel": "https://binerai.biner.dev/v1/predictions/prd_.../cancel" }
}

Input is validated against the model's JSON Schema (see the model's API tab, or GET /v1/models/:owner/:name). Invalid input returns 400 with a details list of paths and messages. Defaults from the schema are filled in and echoed back.

Upload a file

Inputs that take a file (an image to upscale, audio to transcribe) take a URL. If the file is not online yet, upload it: POST /v1/files with the raw file as the body and its Content-Type. Up to 100 MB. Use the returned url as the input value. The URL is unguessable but public, like prediction outputs, and the file is deleted after 1 day.

curl -s https://binerai.biner.dev/v1/files \
  -H "Authorization: Bearer $BINERAI_TOKEN" \
  -H "Content-Type: image/jpeg" \
  --data-binary @cat.jpg

Get a prediction

GET /v1/predictions/:id. Poll every 1 to 2 seconds until status is succeeded, failed or canceled. output is a list of URLs for image models. Output files are deleted 3 days after they are created, so copy what you want to keep. Uploaded input files are deleted after 1 day.

GET /v1/predictions?limit=20&cursor= lists your predictions, newest first. POST /v1/predictions/:id/cancel cancels a queued or running prediction.

List models

GET /v1/models lists public models (?collection=text-to-image, ?q=flux). GET /v1/models/:owner/:name returns one model with its versions, input and output JSON Schema, price per unit and a cost estimate (estimate: typical_run_usd, typical_run_seconds, boot_usd, boot_seconds, and warm_now, which is true when a GPU is already running so the next request pays no boot). GET /v1/collections lists collections. These endpoints need no token.

Webhooks

When webhook is set we POST the finished prediction as { "event": "prediction.completed", "data": <prediction> }. Answer with any 2xx. We retry after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours.

Each delivery carries X-BinerAI-Timestamp and X-BinerAI-Signature: v1=<hex> where the hex is HMAC_SHA256(secret, timestamp + "." + rawBody). Your secret is under Webhooks.

import { createHmac, timingSafeEqual } from "node:crypto";

export function verify(req, rawBody, secret) {
  const ts = req.headers["x-binerai-timestamp"];
  const sig = String(req.headers["x-binerai-signature"]).replace(/^v1=/, "");
  const expected = createHmac("sha256", secret).update(`${ts}.${rawBody}`).digest("hex");
  return sig.length === expected.length && timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
}

Billing

Credit is prepaid in USD. Creating a prediction holds expected_units × price plus room for a possible GPU boot. On success you are charged for the units actually produced, plus the boot time if your request started the GPU, and the remainder is released. Failed predictions release the whole hold. A canceled prediction on a container model pays for the GPU time it used until the cancel, boot included, at the model's per-second price and never more than its hold; on shared models a cancel is free. Once a day, GPU standby time that no prediction paid for is shared at cost between that day's users, pro rata to usage, as a ledger adjustment. GET /v1/account returns your balance, GET /v1/account/ledger the last 100 entries.

Errors

{ "error": { "code": "insufficient_credits", "message": "Insufficient credits" } }
StatusCodeMeaning
400bad_requestInvalid body or input; see details
401unauthorizedMissing or revoked token
402insufficient_creditsAdd credit and retry
404not_foundUnknown model, version or prediction
409conflictToo many predictions in flight (default 5)
429rate_limitedSlow down; see Retry-After
500internalOur fault; retry with the same Idempotency-Key

Rate limits

60 requests per minute per token by default and 5 predictions in flight per account. Ask hello@biner.dev for more.