Get started
Quickstart
The Unbound API speaks the OpenAI format. If you already have code that talks to an OpenAI-compatible service, you change two things: the base URL and the key.
1. Create a key
Open Settings → API → Keys and create a key. The full key is shown once, so copy it then. Keys spend from the same balance as the app, and each key can carry its own spending limit.
Keep keys on a server. Never ship one in a browser bundle or a mobile app.
export UNBOUND_API_KEY="<your key>"
2. See what your key can call
curl https://api.useunbound.ai/v1/models \
-H "Authorization: Bearer $UNBOUND_API_KEY"
The list contains only models with a provider route that is authorized for API use, tested and priced. Copy an id from the response for the next step. The same list, with prices, is on the models page.
3. Send a request
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" }],
"max_tokens": 200
}'
With the OpenAI SDK for Python:
from openai import OpenAI
client = OpenAI(base_url="https://api.useunbound.ai/v1", api_key="<your Unbound key>")
reply = client.chat.completions.create(
model="<model-id>",
messages=[{"role": "user", "content": "Hello"}],
max_tokens=200,
)
print(reply.choices[0].message.content)
And for JavaScript:
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.useunbound.ai/v1", apiKey: process.env.UNBOUND_API_KEY });
const reply = await client.chat.completions.create({
model: "<model-id>",
messages: [{ role: "user", content: "Hello" }],
max_tokens: 200,
});
console.log(reply.choices[0].message.content);
4. Check what it cost
Every response carries an x-request-id header. The same id appears in your usage history with the tokens counted and the amount charged.
What happens to your balance
Before a request is sent to a provider, Unbound holds enough credit to cover the prompt plus max_tokens of output. When the request finishes, the real usage is charged and the rest of the hold is returned. If the request fails, the whole hold is returned and nothing is charged. Setting max_tokens keeps holds small.
Local development
When you run this project locally, the same routes answer at http://localhost:3000/v1 and a simulated model is available so you can test the full flow without calling a real provider.