This page shows how to point LiteLLM at a custom OpenAI endpoint that runs your own open model on BitsRun. At the end you will call it from the LiteLLM Python SDK and from the LiteLLM proxy (config.yaml), so every app behind your proxy can use it. It takes about 10 minutes once you have an endpoint.
Checked against the LiteLLM docs on 2026-11-14 (latest release on PyPI: 1.109.1).
What you get
| Client | LiteLLM SDK (litellm.completion) or LiteLLM proxy |
| Provider setting | openai/<model> with api_base, LiteLLM's route for OpenAI-compatible servers |
| Paths used | /v1/chat/completions, /v1/embeddings |
| Streaming and tool calls | Supported (tool calls need a model trained for them) |
| Cost when idle | Nothing. The endpoint sleeps and wakes on the next request |
Before you start
- A BitsRun endpoint. Follow Deploy your first model or Deploy an Ollama model to the cloud.
- Its base URL,
https://<endpoint-id>.endpoint.bitsrun.com/v1, from the Copy button on the endpoint card.<endpoint-id>is your endpoint's id. - An API key starting with
brk_(see API keys). Below,brk_your_keystands for your key. - Python with LiteLLM installed:
pip install litellm(add'litellm[proxy]'for the proxy).
How to call a custom OpenAI endpoint from the LiteLLM SDK
Save your key in an environment variable:
bashexport BITSRUN_API_KEY="brk_your_key"Create
chat.py. This is the example from the LiteLLM OpenAI-compatible docs, with our model, key and base URL, plus a timeout for cold starts:pythonimport litellm import os response = litellm.completion( model="openai/qwen3:8b", # add `openai/` prefix to model so litellm knows to route to OpenAI api_key=os.environ["BITSRUN_API_KEY"], # api key to your openai compatible endpoint api_base="https://<endpoint-id>.endpoint.bitsrun.com/v1", # set API Base of your Custom OpenAI Endpoint timeout=600, # seconds; covers a cold start messages=[ { "role": "user", "content": "Hey, how's it going?", } ], ) print(response)Run
python chat.py. You should see a response object with the model's reply inchoices[0].message.content.
The openai/ prefix tells LiteLLM to speak the OpenAI format. The rest of the name (qwen3:8b) is sent as the model field. An endpoint serves exactly one model and always uses it, so pass the name you deployed.
How to add a custom endpoint to the LiteLLM proxy config.yaml
Create
config.yaml.model_nameis the name your apps will ask the proxy for:yamlmodel_list: - model_name: my-model litellm_params: model: openai/qwen3:8b # add openai/ prefix to route as OpenAI provider api_base: https://<endpoint-id>.endpoint.bitsrun.com/v1 # add api base for OpenAI compatible provider api_key: os.environ/BITSRUN_API_KEY # api key to send your model timeout: 600 # timeout in (seconds) stream_timeout: 600 # timeout for stream requests (seconds)os.environ/BITSRUN_API_KEYmakes the proxy read the key from the environment, so it never sits in the file.timeoutandstream_timeoutcome from the LiteLLM timeouts page.Start the proxy:
bashlitellm --config /path/to/config.yamlCall the proxy like any OpenAI server, using the model name from the config:
bashcurl --location 'http://0.0.0.0:4000/chat/completions' \ --header "Authorization: Bearer $LITELLM_API_KEY" \ --header 'Content-Type: application/json' \ --data '{ "model": "my-model", "messages": [ { "role": "user", "content": "what llm are you" } ] }'You should see a chat completion in JSON.
$LITELLM_API_KEYis your proxy key, not the BitsRun key.
How to use a BitsRun embedding endpoint in LiteLLM
Embedding endpoints answer /v1/embeddings. Use the same prefix:
import litellm
import os
response = litellm.embedding(
model="openai/snowflake-arctic-embed-l-v2.0", # add `openai/` prefix to model so litellm knows to route to OpenAI
api_key=os.environ["BITSRUN_API_KEY"], # api key to your openai compatible endpoint
api_base="https://<endpoint-id>.endpoint.bitsrun.com/v1", # set API Base of your Custom OpenAI Endpoint
input=["good morning from litellm"]
)
print(response)More on embedding models in Self-hosted embeddings API.
What happens when the endpoint is asleep
The first request after a quiet period wakes the endpoint. The wait is never billed.
| Model kind | Warm GPU (ran recently) | New GPU machine |
|---|---|---|
| GGUF models on llama.cpp | A few seconds to about 40 seconds | About 2 to 3 minutes |
| Embedding models on Text Embeddings Inference | A few seconds to about 40 seconds | About 2 to 3 minutes |
| Safetensors chat models on vLLM | About 40 seconds | About 3 to 4 minutes |
BitsRun keeps the request open for up to 8 minutes, so set LiteLLM's timeout to 600 seconds as shown above. Avoid aggressive retries: requests that time out on your side still run once the model is ready and are billed. Read Cold starts for the details.
If something goes wrong
| Message or symptom | What to do |
|---|---|
Not Found Error | Make sure api_base ends in /v1, as the LiteLLM docs also advise. |
401 unauthorized | The key is missing, mistyped or revoked. Check BITSRUN_API_KEY in the proxy's environment. |
404 not_found on chat | The endpoint runs an embedding model, or the key is limited to another endpoint. |
402 payment_required | Your balance is $0. Add credit in the dashboard. |
429 rate_limited | Too many requests open at once for your plan. Retry with a short, growing pause. |
Response body with model_starting | The model took longer than 8 minutes to wake. Send the request again. |
| Timeout error after a minute or two | The client timeout is too short for a cold start. Set timeout to 600. |
All codes are on Error codes.
Frequently asked questions
How do I use a self-hosted model with LiteLLM?
Deploy the model on BitsRun, then set model: openai/<model-name>, api_base to your endpoint URL ending in /v1, and api_key to your brk_ key. LiteLLM then treats it as an OpenAI-compatible provider.
Does streaming work through the LiteLLM proxy?
Yes. BitsRun supports streaming on /v1/chat/completions, and LiteLLM passes stream: true through. Set stream_timeout high enough to cover a cold start.
Can I put several BitsRun endpoints behind one LiteLLM proxy?
Yes. Add one model_list entry per endpoint, each with its own api_base and a model_name your apps can ask for.
Which fields does BitsRun accept from LiteLLM?
Standard chat fields such as messages, max_tokens, temperature, tools and response_format. Other fields are dropped; the full list is on Chat and completions.
Next step
Need a model for your proxy? See Host a GGUF model as an OpenAI-compatible API. Check what fits on each GPU with the VRAM calculator, then create your account.