bitsrun

Call your endpoint

Send requests to your endpoint URL with an API key in the Authorization header, using curl, the OpenAI SDKs or any OpenAI-compatible tool.

On this page

Your endpoint speaks the OpenAI API. Any code or tool that can talk to OpenAI can talk to it: change the base URL to your endpoint and the key to a BitsRun API key.

1. Create an API key

  1. In the dashboard, open API keys and select New API key.
  2. Give it a name you will recognize, such as "Staging server".
  3. Under Works with, choose all endpoints or only this one.
  4. Copy the key. It is shown only once.

Store it as an environment variable, never in your code:

bash
export BITSRUN_API_KEY="paste-your-key-here"

More in API keys.

2. Copy your endpoint URL

On the Endpoints page, select Copy on the dark bar of your endpoint card. It looks like this:

https://01k8y4000d3m00000000000011.endpoint.bitsrun.com/v1

Each card also has How to call it, with ready-made examples for that endpoint.

An endpoint card with How to call it open, showing tabs for Code with it, bitsrun commands, curl, Node and Python
How to call it gives copyable examples for this endpoint.

3. Send a request

curl

bash
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 one sentence."}]}'

Python

bash
pip install openai
python
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 one sentence."}],
)
print(reply.choices[0].message.content)

JavaScript or TypeScript

bash
npm install openai
javascript
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 one sentence." }],
});
console.log(reply.choices[0].message.content);

Ollama clients

GGUF models (from an Ollama name or a .gguf file) also answer Ollama's own API on the same host without /v1. Pass your key as a header; the ollama command line app cannot, so use a library such as Ollama Python:

python
import os
from ollama import Client

client = Client(
    host="https://01k8y4000d3m00000000000011.endpoint.bitsrun.com",
    headers={"Authorization": f"Bearer {os.environ['BITSRUN_API_KEY']}"},
)
reply = client.chat(model="qwen3:8b", messages=[{"role": "user", "content": "Say hello in one sentence."}])
print(reply.message.content)

More in Chat and completions.

The first request after sleep

If the endpoint is asleep, your request wakes it and waits on the open connection for up to 8 minutes, then answers as soon as the model is ready. Streaming or not, you do not need to retry. To get a 503 with "code": "model_starting" and Retry-After: 30 instead, send the header X-BitsRun-Wait: 0. Details in Cold starts.

Next steps

View as MarkdownUpdated

Still stuck?

Email support@bitsrun.com with what you tried and any request id you saw. A real person answers.