MagmaRouter.

Use MagmaRouter through LiteLLM.

LiteLLM reaches any OpenAI-compatible endpoint with an openai/ model prefix and an api_base. It splits the model string at the first slash only, so a MagmaRouter id with its own slash survives.

The SDK

# pip install litellm
from litellm import completion

resp = completion(
    model="openai/deepseek/deepseek-chat-v3.1",
    api_key="rl-...",
    api_base="https://magmarouter.com/v1",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)

The openai/ prefix tells LiteLLM to use the OpenAI-compatible path; the rest of the string, slash and all, is passed through as the model id.

The Proxy

In the LiteLLM Proxy config.yaml:

model_list:
  - model_name: deepseek-chat
    litellm_params:
      model: openai/deepseek/deepseek-chat-v3.1
      api_base: https://magmarouter.com/v1
      api_key: os.environ/MAGMAROUTER_API_KEY

api_base must end in /v1. MagmaRouter has no embeddings endpoint, so do not route embedding models through it.

Related guides