bitsrun

LiteLLM custom OpenAI endpoint for your own model

Use a LiteLLM custom OpenAI endpoint to call your own open model from the SDK or the proxy config.yaml, with private, per-second billing on BitsRun.

Updated

On this page

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

ClientLiteLLM SDK (litellm.completion) or LiteLLM proxy
Provider settingopenai/<model> with api_base, LiteLLM's route for OpenAI-compatible servers
Paths used/v1/chat/completions, /v1/embeddings
Streaming and tool callsSupported (tool calls need a model trained for them)
Cost when idleNothing. 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_key stands 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

  1. Save your key in an environment variable:

    bash
    export BITSRUN_API_KEY="brk_your_key"
  2. 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:

    python
    import 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)
  3. Run python chat.py. You should see a response object with the model's reply in choices[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

  1. Create config.yaml. model_name is the name your apps will ask the proxy for:

    yaml
    model_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_KEY makes the proxy read the key from the environment, so it never sits in the file. timeout and stream_timeout come from the LiteLLM timeouts page.

  2. Start the proxy:

    bash
    litellm --config /path/to/config.yaml
  3. Call the proxy like any OpenAI server, using the model name from the config:

    bash
    curl --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_KEY is 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:

python
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 kindWarm GPU (ran recently)New GPU machine
GGUF models on llama.cppA few seconds to about 40 secondsAbout 2 to 3 minutes
Embedding models on Text Embeddings InferenceA few seconds to about 40 secondsAbout 2 to 3 minutes
Safetensors chat models on vLLMAbout 40 secondsAbout 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 symptomWhat to do
Not Found ErrorMake sure api_base ends in /v1, as the LiteLLM docs also advise.
401 unauthorizedThe key is missing, mistyped or revoked. Check BITSRUN_API_KEY in the proxy's environment.
404 not_found on chatThe endpoint runs an embedding model, or the key is limited to another endpoint.
402 payment_requiredYour balance is $0. Add credit in the dashboard.
429 rate_limitedToo many requests open at once for your plan. Retry with a short, growing pause.
Response body with model_startingThe model took longer than 8 minutes to wake. Send the request again.
Timeout error after a minute or twoThe 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.

Try it on your own model

Sign up with your email, add $10 of credit and deploy from an Ollama name or a Hugging Face repo. An L4 costs $0.95 an hour, billed per second only while your model is awake. Waking up is never billed, and credit you buy does not expire.