Developers
An API you already know.
Quick start
- Create a key in Settings → API → Keys. It is shown once.
- List the models your key can call with
GET /v1/models. - Send a chat completion.
curl https://api.useunbound.ai/v1/chat/completions \
-H "Authorization: Bearer $UNBOUND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<model-id>",
"messages": [{ "role": "user", "content": "Hello" }]
}'from openai import OpenAI
client = OpenAI(base_url="https://api.useunbound.ai/v1", api_key="<your Unbound key>")
stream = client.chat.completions.create(
model="<model-id>",
messages=[{"role": "user", "content": "Hello"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")In local development the same routes answer at http://localhost:3000/v1.
Authentication
Send your key as a bearer token: Authorization: Bearer ub_…. Keys are stored only as a keyed hash, can be revoked instantly, and can carry a spending limit and their own rate limit. Never ship a key in browser or mobile code.
Reference
GET/v1/models
Models your key can call. A model appears only if it has a provider route authorized for API resale, so this list can be shorter than the one in the app. Each entry includes context length, modalities, privacy level and per-million-token prices.
POST/v1/chat/completions
OpenAI-compatible chat completions, streaming or not.
| Field | Type | Notes |
|---|---|---|
| model | string | Required. An id from /v1/models. |
| messages | array | Required. Roles: system, user, assistant, tool. Content may be a string or content parts. |
| stream | boolean | Server-sent events when true. |
| stream_options.include_usage | boolean | Adds a final chunk with token usage. |
| max_tokens | integer | Caps output and the amount held. Also accepted as max_completion_tokens. |
| temperature | number | 0 to 2. |
| top_p | number | 0 to 1. |
| stop, seed | Forwarded when the model supports them. | |
| tools, tool_choice | Function calling, for models that support tools. | |
| response_format | object | JSON mode or JSON schema, for models that support it. |
| reasoning_effort | string | minimal, low, medium or high, for reasoning models. |
POST/v1/images/generations
OpenAI-compatible image generation. A parameter the model does not support is rejected with 400, never ignored. Send an Idempotency-Key header to make retries safe: the same key returns the same images and is charged once.
| Field | Type | Notes |
|---|---|---|
| model | string | Required. An image model from /v1/models. |
| prompt | string | Required. |
| n | integer | Number of images, up to the model limit. |
| size | string | For example 1024x1024. Mapped to the nearest aspect ratio and resolution. |
| aspect_ratio, resolution | string | Unbound fields, for example 16:9 and 2k. Take precedence over size. |
| seed, negative_prompt | Only for models that support them. | |
| response_format | string | b64_json (default) or url. URLs are signed and expire after one hour. |
The exact price is held before the image is generated; if fewer images are delivered than requested, only those are charged; a failed generation is not charged.
Embeddings, decisions, speech and transcription have their own pages in the documentation. Image editing, music, video and webhook endpoints are in development and will be documented as each one ships.
Streaming
With stream: true the response is a stream of chat.completion.chunk objects ending in data: [DONE]. If you close the connection early, generation stops and you are charged only for what was produced.
Billing
Before a request is sent upstream, Unbound holds enough credit to cover the prompt plus max_tokens of output. When it finishes, the real usage is charged and the rest is returned. Set max_tokens to keep holds small. Every response carries an x-request-id header that matches the entry in your usage history.
Errors
Errors use the OpenAI envelope: an error object with message, type and code.
| Status | Type | Meaning |
|---|---|---|
| 400 | invalid_request_error | The request is malformed or a parameter is out of range. |
| 401 | authentication_error | The API key is missing, revoked or expired. |
| 402 | insufficient_quota | Not enough credits, or the key reached its spending limit. Nothing was charged. |
| 403 | permission_error | The key lacks the scope this endpoint needs. |
| 404 | model_not_found | The model does not exist or is not available through the API. |
| 429 | rate_limit_error | Too many requests for this key. Retry after the Retry-After interval. |
| 502 | server_error | The upstream provider failed. The hold was released; you were not charged. |
Clients
Any client that lets you set an OpenAI-compatible base URL can use Unbound. A custom provider entry for OpenCode looks like this:
{
"provider": {
"unbound": {
"npm": "@ai-sdk/openai-compatible",
"name": "Unbound AI",
"options": { "baseURL": "https://api.useunbound.ai/v1" },
"models": { "<model-id>": { "name": "<display name>" } }
}
}
}Compatibility with specific third-party clients is verified per release; check the changelog.