Loading
Skip to content
RedRouterRedRouter
Dashboard ↗

LiteLLM

Route a LiteLLM Chat Completions call to RedRouter using LiteLLM's generic OpenAI-compatible adapter. This configuration recipe has not been live-tested against RedRouter.

Call from Python

python -m pip install litellm
export REDROUTER_API_KEY="your-redrouter-api-key"

Save as example.py and run python example.py:

import os
import litellm

try:
    response = litellm.completion(
        model="openai/red-cyber-1",
        api_base="https://redrouter.org/v1",
        api_key=os.environ["REDROUTER_API_KEY"],
        messages=[{"role": "user", "content": "Give one reason to test database migrations."}],
        max_tokens=512,
        timeout=120,
        num_retries=0,
    )
    if response.choices[0].finish_reason == "length":
        raise RuntimeError("Output was truncated.")
    print(response.choices[0].message.content)
except litellm.AuthenticationError:
    raise SystemExit("Check REDROUTER_API_KEY and the account's API access.")
except litellm.RateLimitError:
    raise SystemExit("Request limited; inspect the error before scheduling another attempt.")

A successful call prints a short answer. openai/ selects LiteLLM's adapter and is removed before the model ID is sent. It does not select OpenAI inference. api_base includes /v1; do not append /chat/completions yourself.

For streaming, add stream=True and iterate over the returned chunks. Some usage chunks contain no choices. See Python streaming for the corresponding OpenAI-shaped stream handling.

Add to an existing LiteLLM gateway

If you already operate a LiteLLM proxy, add a model entry to its configuration:

model_list:
  - model_name: redrouter-cyber
    litellm_params:
      model: openai/red-cyber-1
      api_base: https://redrouter.org/v1
      api_key: os.environ/REDROUTER_API_KEY
      max_tokens: 1024

Applications calling that proxy select its local alias, redrouter-cyber, and authenticate to the proxy using its credentials. The proxy supplies the separate RedRouter key for its outgoing call. Preserve the gateway's authentication, request limits, and logging policy; never expose an unauthenticated proxy to the internet.

Account for the extra layer

RedRouter model capabilities and prices remain authoritative. Do not infer accurate RedRouter cost accounting from a generic LiteLLM model entry. Use RedRouter's usage and billing, and configure gateway cost metadata separately if your application needs it.

Keep retries in one layer. Gateway retries, SDK retries, and application retries can otherwise multiply generation attempts. Review production guidance. Do not silently drop unsupported parameters: a 400 is useful evidence that the application requested a feature it will not receive.

red-cyber-1 supports text, tools, and structured output. Embeddings, hosted tools, and stored Responses are outside this recipe. If using LiteLLM Responses, read both its translation behavior and RedRouter's Responses limits; sending previous_response_id does not add server-side state.

References: LiteLLM OpenAI-compatible endpoints and exception mapping.

↑ ↓ to select · Enter to open · Esc to close