Use MagmaRouter through LiteLLM

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.

Base URL
https://api.magmarouter.com/v1
API key
Get one, starts sk-mr-
Example model
glm-5.3-xploded

The SDK

Python
# pip install litellm
from litellm import completion

resp = completion(
    model="openai/glm-5.3-xploded",
    api_key="sk-mr-...",
    api_base="https://api.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:

YAML
model_list:
  - model_name: deepseek-chat
    litellm_params:
      model: openai/glm-5.3-xploded
      api_base: https://api.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