Use the API
Every endpoint is an OpenAI-compatible API at its own address, so existing OpenAI code works after you change the base URL and the key.
On this page
Each endpoint you deploy gets its own web address, called the base URL. It looks like this:
https://01k8y4000d3m00000000000011.endpoint.bitsrun.com/v1The part before .endpoint is your endpoint id. You find the full URL on the endpoint's card in the dashboard (with a Copy button), or with bitsrun status <endpoint> in the terminal.
Your code sends an API key with every request. An API key is a secret that proves the request comes from you. Create one on the API keys page; see API keys.
What the API answers
| Path | Method | What it does | Works on |
|---|---|---|---|
/v1/chat/completions | POST | Chat: send messages, get the next reply. Streaming and tool calls supported | Chat models |
/v1/completions | POST | Plain text completion from a prompt | Chat models |
/v1/embeddings | POST | Turns text into vectors (lists of numbers) for search and RAG | Embedding models |
/v1/models | GET | Lists the one model this endpoint serves | Every endpoint |
GGUF models also answer the native Ollama paths (/api/chat, /api/generate, /api/embed, /api/embeddings, /api/tags) on the same host without /v1, so Ollama libraries that can send the Authorization header work too (the ollama command line app cannot). See Chat and completions.
Any other path answers 404. Endpoints that only run embeddings answer only /v1/embeddings and /v1/models.
Your first call
Set your key once in your terminal, then call the endpoint:
export BITSRUN_API_KEY="brk_..."
curl https://01k8y4000d3m00000000000011.endpoint.bitsrun.com/v1/chat/completions \
-H "Authorization: Bearer $BITSRUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "qwen3:8b", "messages": [{"role": "user", "content": "Say hello in five words."}]}'The same call with the official OpenAI SDKs:
import os
from openai import OpenAI
client = OpenAI(
base_url="https://01k8y4000d3m00000000000011.endpoint.bitsrun.com/v1",
api_key=os.environ["BITSRUN_API_KEY"],
)
reply = client.chat.completions.create(
model="qwen3:8b",
messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(reply.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://01k8y4000d3m00000000000011.endpoint.bitsrun.com/v1",
apiKey: process.env.BITSRUN_API_KEY,
});
const reply = await client.chat.completions.create({
model: "qwen3:8b",
messages: [{ role: "user", content: "Say hello in five words." }],
});
console.log(reply.choices[0].message.content);When the endpoint is asleep
An endpoint sleeps when nobody uses it, and the first request wakes it. That start takes a few seconds on a warm GPU and a few minutes when a new GPU starts. You are never billed for it. How your request behaves while it waits:
- Every request stays open and waits for the model, up to 8 minutes, then answers normally. Streaming requests get keep-alive comments while they wait; other requests get spaces before the JSON, which JSON parsers skip.
- After 8 minutes, or if the model fails to start, the answer has status
200and an error body (model_startingormodel_unavailable). Send the request again. - Header
X-BitsRun-Wait: 0: a request that finds the model asleep gets503with the codemodel_startingand aRetry-After: 30header after about 45 seconds instead.
Read Cold starts for timings and how to avoid them.
Errors
Every error has the same shape: a stable code your code can check, a friendly message, and a requestId to send to support.
{
"error": {
"code": "payment_required",
"message": "Your credit balance has run out. Add credit in the dashboard to continue.",
"requestId": "01k9a2b3c4d5e6f7g8h9j0k1m2"
}
}The full list, with what each one means and how to fix it, is on Error codes.
Pages in this section
- Chat and completions: messages, streaming, thinking, LangChain and Ollama clients
- Embeddings: vectors for search and RAG
- Tool calling: let the model call your functions
- API keys: create, limit and revoke keys
- Limits: requests at once, request fields and time limits
Still stuck?
Email support@bitsrun.com with what you tried and any request id you saw. A real person answers.