Skip to content
Browse the docs

API reference

Introduction

How to authenticate, what is compatible with OpenAI, and what every response and error looks like.

Endpoints

The API is served at https://api.useunbound.ai/v1. It follows the OpenAI request and response format for every endpoint it implements, so existing OpenAI clients work after changing the base URL and the key.

A machine-readable description of everything on these pages is available as OpenAPI 3.1.

Authentication

Send your key as a bearer token on every request:

http
Authorization: Bearer <your key>
  • Keys are created and revoked in Settings → API → Keys. Revoking takes effect immediately.
  • Unbound stores only a keyed hash of each key. The full value is shown once, when the key is created.
  • A key can carry a spending limit. When the limit is reached, requests fail with 402 and nothing is charged.
  • All live endpoints need the inference scope, which every key has by default.
EndpointMethodNeeds a key
/v1/modelsGETYes
/v1/chat/completionsPOSTYes
/v1/images/generationsPOSTYes

OpenAI compatibility

Point any OpenAI client at the Unbound base URL.

python
from openai import OpenAI

client = OpenAI(base_url="https://api.useunbound.ai/v1", api_key="<your Unbound key>")
javascript
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.useunbound.ai/v1", apiKey: process.env.UNBOUND_API_KEY });

Model ids are Unbound ids, taken from GET /v1/models. An id from another service will return 404 model_not_found.

Unbound-specific fields

These are additions to the OpenAI format. Clients that do not know them can ignore them.

WhereFieldMeaning
GET /v1/modelsname, type, context_length, max_output_tokens, input_modalities, output_modalities, capabilitiesWhat the model is and what it accepts.
GET /v1/modelsprivacyThe privacy level the model's route can substantiate: anonymized, private or e2ee.
GET /v1/modelspricingUSD per one million tokens, as decimal strings.
Chat responsereasoning_contentReasoning text, when the model returns it. Also sent in stream deltas.
POST /v1/images/generationsaspect_ratio, resolution, negative_prompt, seedAccepted only by models that declare them.
POST /v1/images/generationsIdempotency-Key headerMakes a retry return the same images and charge once.
Image responsemime_typeSent next to b64_json.

Response headers

HeaderSent onMeaning
x-request-idEvery responseIdentifies the request. It matches the entry in your usage history.
retry-after429Seconds to wait before retrying.
x-ratelimit-limit-requests429The per-minute request limit of this key.
x-ratelimit-remaining-requests429Always 0 on a rate-limited response.

Rate-limit headers are sent only on rate-limited responses today; successful responses do not carry them yet.

Rate limits

Each key has a per-minute request limit. The default is 120 requests per minute; a key can be given its own limit. Your current limits are shown in Settings → API. There is no separate token-per-minute limit: spending is bounded by your balance and by the key's spending limit.

Errors

Errors use the OpenAI envelope:

json
{
  "error": {
    "message": "Not enough credits for this request.",
    "type": "insufficient_quota",
    "code": "insufficient_credits",
    "param": null
  }
}
StatustypeMeaningCharged
400invalid_request_errorMalformed request, or a parameter the model does not support.No
401authentication_errorThe key is missing, revoked or expired.No
402insufficient_quotaNot enough credit, or the key reached its spending limit.No
403permission_errorThe key lacks the scope the endpoint needs.No
404model_not_foundThe model does not exist or is not available through the API.No
413invalid_request_errorThe body is too large: 4 MB, 1 MB for embeddings, decisions and speech, 24 MB for a recording.No
429rate_limit_errorToo many requests for this key.No
502server_errorThe upstream provider failed. The hold was released.No

A stream that fails after it has started cannot change its status code. The failure arrives as a final data: event containing an error object, and you are charged only for output that was delivered before it.

Differences from OpenAI

  1. Only the endpoints listed in this reference exist. Video and image editing are in development and return 404 today.
  2. On chat completions, parameters that are not in the reference (for example n, logprobs or logit_bias) are not forwarded.
  3. On image generation, a parameter the chosen model does not support is rejected with 400 rather than ignored.
  4. The developer role is accepted and treated as system.
  5. Image generation defaults to b64_json. Ask for "response_format": "url" to get signed links, which expire after one hour.
  6. Token usage on a stream is sent only when you ask for it with stream_options.include_usage.
  7. Speech is always MP3 and has no speed. Transcription answers as json or text. Embeddings take texts, not token numbers.

Billing

Requests are billed from your account balance at the prices listed on the models page. Input and output tokens are priced separately. A hold is placed before a request runs and settled to actual usage afterwards; see Control what you spend.

Stability

The API is versioned in the path (/v1). Fields may be added to responses without notice; nothing documented here is removed or renamed without an entry in the changelog. Model availability changes as provider routes are added or retired, so read the model list rather than hard-coding assumptions about it.