Make my first API call
7 days · 1,000,000 tokens per day shared across all trial models · no credit card
1. Activate your trial and create a key
Register, verify your email and open API keys. Create a key and copy it when it is shown. Check the model in GET /v1/models using this key.
2. Install the Python SDK
Prerequisite: Python 3.10 or newer. Use python or python3 depending on your installation.
Python SDK shell
python -m pip install openai3. Set the key for this session
Replace the quoted value with your key. Keep it private and outside your repository. Choose the command for your terminal.
macOS / Linux shell
export ROUTERLAB_API_KEY="YOUR_ROUTERLAB_API_KEY"Windows PowerShell powershell
$env:ROUTERLAB_API_KEY="YOUR_ROUTERLAB_API_KEY"4. Save and run the script
Copy the full script into routerlab_first_call.py and run python routerlab_first_call.py. A text response appears in your terminal; its contents may vary. This script uses Chat Completions.
routerlab_first_call.py python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ROUTERLAB_API_KEY"],
base_url="https://api.routerlab.ch/v1",
)
response = client.chat.completions.create(
model="glm-5.3-flash-trial",
max_tokens=128,
messages=[{"role": "user", "content": "Hello RouterLab"}],
)
print(response.choices[0].message.content)If the call fails
- 401 / AuthenticationError
- Check ROUTERLAB_API_KEY in the same terminal as your script, your active key, and https://api.routerlab.ch/v1.
- 403 / PermissionDeniedError
- List GET /v1/models with this key. Choose an authorized -trial variant. Production routes may be denied. Check your trial expiry date.
- 429 / RateLimitError
- All keys and models share the account quota. Check your budget and next reset in your dashboard. Wait if you hit a rate limit.
- 400 / 404
- Copy the exact authorized model ID and use its indicated protocol. Claude Messages and image models do not use this chat example.