LiteLLM verbinden met OpenLLM Buddy

Use LiteLLM with OpenLLM Buddy: call it from the Python SDK or add it to the LiteLLM proxy config for a unified gateway with keys and budgets.

SDK en framework · Integratiegids

Wat is LiteLLM?

LiteLLM translates one OpenAI-style interface to 100+ providers. Run it as a Python library or as a proxy server with virtual keys, budgets, and logging. Bezoek LiteLLM.

Waarom OpenLLM Buddy verbinden?

Put OpenLLM Buddy behind LiteLLM to give every team member their own key and budget, to fall back between models, or to hand tools a stable URL while you swap models behind it.

Maak voordat je begint een API-sleutel aan in de console en deploy een model. Gaat er iets mis, voer dan eerst de curl-test in stap 4 uit: geen enkele tool kan een kapot endpoint repareren.

1

Call it from the Python SDK

Prefix the model with openai/ and pass api_base so LiteLLM treats it as a generic OpenAI-compatible server.

sdk.py
python
import os
import litellm

resp = litellm.completion(
    model="openai/gemma4:26b",
    api_base="https://openllmbuddy-proxy.botbuddytech.workers.dev/v1",
    api_key=os.environ["OPENLLMBUDDY_API_KEY"],
    messages=[{"role": "user", "content": "Hello from LiteLLM"}],
)
print(resp.choices[0].message.content)
2

Or add it to the proxy

For a shared gateway, install the proxy and describe the model in config.yaml.

config.yaml
yaml
model_list:
  - model_name: buddy
    litellm_params:
      model: openai/gemma4:26b
      api_base: https://openllmbuddy-proxy.botbuddytech.workers.dev/v1
      api_key: os.environ/OPENLLMBUDDY_API_KEY

model_name is the alias your clients use. You can list several deployments under the same alias for load balancing.

3

Run the proxy and call it

Start the proxy, then use any OpenAI client against http://localhost:4000.

Terminal
bash
pip install 'litellm[proxy]'
export OPENLLMBUDDY_API_KEY=YOUR_API_KEY
litellm --config config.yaml --port 4000

curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "buddy", "messages": [{"role": "user", "content": "Reply with OK"}]}'

Set a master_key in general_settings before exposing the proxy beyond your machine.

4

Het endpoint testen met curl

Controleer of sleutel, URL en model-ID werken voordat je LiteLLM debugt. Een kort JSON-antwoord betekent dat het endpoint gezond is.

Terminal
bash
curl -sS https://openllmbuddy-proxy.botbuddytech.workers.dev/v1/chat/completions   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"model": "gemma4:26b", "messages": [{"role": "user", "content": "Reply with OK"}], "max_tokens": 16}'

Probleemoplossing

  • `LLM Provider NOT provided` — the openai/ prefix is missing from the model name.
  • Wrong model in logs — the id after openai/ is sent to the endpoint unchanged, so it must match your deployment exactly.
  • 401 of 403 — de API-sleutel is fout, ingetrokken of mist het voorvoegsel Bearer . Maak een nieuwe sleutel aan in de console.
  • 404 op /chat/completions — de base-URL moet eindigen op /v1, zonder /chat/completions erachter en zonder extra pad.
  • Model niet gevonden — het model-ID moet exact overeenkomen met je deployment. Voer de curl-test uit en kopieer het ID dat je hebt gebruikt.
  • Time-outs bij het eerste verzoek — een GPU die inactief was, is mogelijk nog bezig het model te laden. Probeer het na een minuut opnieuw.
  • Verbinding geweigerd vanuit Docker of een externe host — gebruik de openbare HTTPS-base-URL, nooit localhost.

Verbindingsgegevens

Gebruik deze waarden overal waar LiteLLM om een OpenAI-compatible provider vraagt.

Referentie
text
Base URL:  https://openllmbuddy-proxy.botbuddytech.workers.dev/v1
Chat URL:  https://openllmbuddy-proxy.botbuddytech.workers.dev/v1/chat/completions
API-sleutel: je sleutel uit de console
Model-ID:  gemma4:26b