# 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.

Source: https://bitsrun.com/docs/get-started/call-your-endpoint/
Updated: 2026-11-09

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](https://bitsrun.com/docs/api/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:

```text
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](https://bitsrun.com/docs/img/endpoint-how-to-call.png "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);
```

> [!TIP]
> The endpoint always serves its own model, so the `model` field can be any name. Keep the real name there anyway: it makes logs easier to read.

### 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](https://bitsrun.com/docs/api/chat/#ollama-clients).

## 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](https://bitsrun.com/docs/get-started/cold-starts/).

## Next steps

- [Chat completions in detail](https://bitsrun.com/docs/api/chat/), [embeddings](https://bitsrun.com/docs/api/embeddings/) and [tool calling](https://bitsrun.com/docs/api/tools/).
- [Keep it from sleeping](https://bitsrun.com/docs/endpoints/sleep-and-always-on/) when you need instant answers.
