OpenAI Python SDK with MagmaRouter

MagmaRouter speaks the OpenAI chat-completions dialect, so the official openai Python client works with a base URL change and nothing else.
- Base URL
- https://api.magmarouter.com/v1
- API key
- Get one, starts sk-mr-
- Example model
- glm-5.3-xploded
base_url and api_key
Set base_url to https://api.magmarouter.com/v1 (the /v1 is part of it) and api_key to your key. The client also reads OPENAI_BASE_URL and OPENAI_API_KEY from the environment.
Python
# pip install openai from openai import OpenAI client = OpenAI( base_url="https://api.magmarouter.com/v1", api_key="sk-mr-...", ) resp = client.chat.completions.create( model="glm-5.3-xploded", messages=[{"role": "user", "content": "Hello"}], ) print(resp.choices[0].message.content)
Use chat completions MagmaRouter serves /v1/chat/completions, /v1/responses and /v1/models. It has no /v1/completions or /v1/embeddings, and this guide uses the chat.completions call.