Skip to content

Using byesu with LiteLLM

LiteLLM is a popular open-source library and proxy server that gives you a unified interface to 100+ LLM providers. Because byesu exposes a standard OpenAI-compatible API (and an Anthropic-native Messages API for Claude models), it plugs into LiteLLM with zero code changes — both in the Python SDK and in the LiteLLM Proxy.

This guide covers:

  1. LiteLLM Python SDK — call byesu models directly from Python
  2. LiteLLM Proxy — run a local OpenAI-compatible gateway backed by byesu
  3. Anthropic-native routing — route Claude models through byesu's /v1/messages endpoint
  4. Troubleshooting

Prerequisites

  • A byesu API token (sk-...) — create one in your byesu console
  • Python 3.8+ with pip install 'litellm[proxy]'

Set your token as an environment variable:

bash
export BYESU_API_KEY="sk-your-byesu-token"

byesu is an AI API gateway with pay-as-you-go billing — the same token works for every model listed on the models page.

LiteLLM Python SDK

Use the openai/ prefix and point api_base at byesu's OpenAI-compatible endpoint:

python
import os
from litellm import completion

response = completion(
    model="openai/claude-opus-4-8",           # openai/ prefix = OpenAI-compatible route
    api_base="https://byesu.com/v1",
    api_key=os.environ["BYESU_API_KEY"],
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
print(response.choices[0].message.content)

Swap the model name for anything byesu serves, e.g. openai/gpt-5.6-terra, openai/grok-4.5, openai/gemini-3.1-pro.

Streaming works out of the box:

python
response = completion(
    model="openai/gpt-5.6-terra",
    api_base="https://byesu.com/v1",
    api_key=os.environ["BYESU_API_KEY"],
    messages=[{"role": "user", "content": "Write a haiku about gateways."}],
    stream=True,
)
for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")

LiteLLM Proxy config

The LiteLLM Proxy lets your whole team (or your apps: Cursor, Open WebUI, LangChain, etc.) talk to one local OpenAI-compatible server while byesu handles the upstream models.

Create config.yaml:

yaml
model_list:
  # --- Claude via byesu (OpenAI-compatible route) ---
  - model_name: claude-opus-4-8
    litellm_params:
      model: openai/claude-opus-4-8
      api_base: https://byesu.com/v1
      api_key: os.environ/BYESU_API_KEY

  # --- GPT via byesu ---
  - model_name: gpt-5.6-terra
    litellm_params:
      model: openai/gpt-5.6-terra
      api_base: https://byesu.com/v1
      api_key: os.environ/BYESU_API_KEY

  # --- Grok via byesu ---
  - model_name: grok-4.5
    litellm_params:
      model: openai/grok-4.5
      api_base: https://byesu.com/v1
      api_key: os.environ/BYESU_API_KEY

  # --- Optional: Claude via byesu's Anthropic-native Messages API ---
  - model_name: claude-opus-4-8-native
    litellm_params:
      model: anthropic/claude-opus-4-8
      api_base: https://byesu.com        # LiteLLM appends /v1/messages automatically
      api_key: os.environ/BYESU_API_KEY

Start the proxy:

bash
litellm --config config.yaml
# INFO: Uvicorn running on http://0.0.0.0:4000

Test it with any OpenAI client — here with curl:

bash
curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-1234" \
  -d '{
    "model": "claude-opus-4-8",
    "messages": [{"role": "user", "content": "Hello from LiteLLM + byesu!"}]
  }'

Or from the OpenAI Python SDK:

python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:4000/v1", api_key="sk-1234")
resp = client.chat.completions.create(
    model="grok-4.5",
    messages=[{"role": "user", "content": "One-line fun fact about proxies."}],
)
print(resp.choices[0].message.content)

Load balancing and fallbacks

Because byesu aggregates official models from multiple vendors behind one token, a single api_base covers all of them. You can still use LiteLLM's router features — for example, fall back from one model to another:

yaml
litellm_settings:
  fallbacks:
    - claude-opus-4-8: ["gpt-5.6-terra"]

Anthropic-native routing (Claude models)

byesu also exposes the Anthropic Messages API (POST https://byesu.com/v1/messages). LiteLLM's anthropic/ provider supports a custom api_base, so you can route Claude models through the native protocol instead of the OpenAI-compatible one — useful when you need Anthropic-specific request/response semantics (e.g. native tool use blocks, thinking blocks).

python
import os
from litellm import completion

response = completion(
    model="anthropic/claude-opus-4-8",
    api_base="https://byesu.com",          # LiteLLM appends /v1/messages
    api_key=os.environ["BYESU_API_KEY"],
    messages=[{"role": "user", "content": "Hello via the native Messages API."}],
)
print(response.choices[0].message.content)

Notes:

  • LiteLLM automatically appends /v1/messages to api_base for the anthropic/ provider. If you pass the full path yourself, set LITELLM_ANTHROPIC_DISABLE_URL_SUFFIX=true.
  • The anthropic/ provider sends the key in the x-api-key header; byesu accepts both x-api-key and Authorization: Bearer on the native route, so no extra configuration is needed.
  • Non-Claude models (GPT, Grok, Gemini) should use the OpenAI-compatible route shown above.

Troubleshooting

SymptomFix
404 Not Found when testing the proxyMake sure api_base ends with /v1 for openai/ models: https://byesu.com/v1
401 UnauthorizedCheck BYESU_API_KEY is exported in the shell that runs litellm, and that the token has quota for the requested model
Model not foundUse the exact model ID from the byesu models page (e.g. claude-opus-4-8, not claude-opus)
Anthropic route hits wrong URLDo not add /v1 to api_base for anthropic/ models — LiteLLM appends /v1/messages itself

See also

Got a problem? Contact support or join our group.