Back to blog
IntegrationBeginnerTechnical article

Your First RouterLab API Call in 5 Minutes with Python or curl

Published 11 Oct 20264 min readRouterLab

Decision summary

One trial account, one API key and one request: get your first response, then find the tokens consumed in your dashboard.

APIPythoncurlOpenAI-compatibleTrial
Your First RouterLab API Call in 5 Minutes with Python or curl

Trying an AI API should be straightforward: create an account, get a key, send a request and receive a response.

This guide takes you through your first RouterLab API call and shows you how to check your usage. Once your email address is verified, allow about five minutes with Python or curl already installed.

1. Create your trial account

Visit the RouterLab trial page, sign up and verify your email address to activate your access.

The trial includes:

  • 7 days of access, after email verification;
  • 1,000,000 tokens per day, shared across all trial models;
  • no credit card required.

A token is a unit of text used by models. Both your request and the generated response consume tokens. The quota adds up to a maximum of 7 million tokens over the trial; it is not a pool you can spend in a single day.

Access covers the trial catalog models. Check the list on the trial page for the routes available when you run your test.

2. Create your API key

In your dashboard, open API key management and create a key. Store it in an environment variable to keep it out of your script. Do not share it or commit it to a Git repository.

In a macOS or Linux terminal:

bash
RouterLab
export ROUTERLAB_API_KEY="your-api-key"

On Windows with PowerShell:

powershell
RouterLab
$env:ROUTERLAB_API_KEY = "your-api-key"

Replace your-api-key with your RouterLab key. This variable is set for the terminal session, so keep that terminal open for the next step.

3. Send your first request

For this test, we use glm-5.3-flash-trial, the model in the example published on the official trial page.

Choose just one of the two options below: Python or curl.

Option A — Python

The API used here is compatible with the OpenAI format. You can use the OpenAI SDK by setting RouterLab as the base URL.

Install the SDK:

bash
RouterLab
python -m pip install openai

Create a file named first_call.py and add this code:

python
RouterLab
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)

In the terminal where you set your key, navigate to the file's directory and run:

bash
RouterLab
python first_call.py

Depending on your installation, the command may be python3 on macOS/Linux or py on Windows. Use that command for both SDK installation and running the file.

If the model's response appears, your first call succeeded. The wording may vary between calls.

Option B — curl

To send the same request from a macOS or Linux terminal without installing the Python SDK:

bash
RouterLab
curl https://api.routerlab.ch/v1/chat/completions \
  -H "Authorization: Bearer $ROUTERLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3-flash-trial",
    "max_tokens": 128,
    "messages": [
      {"role": "user", "content": "Hello RouterLab!"}
    ]
  }'

The response is JSON. You will find the generated text in choices[0].message.content.

4. Check your usage

Return to your dashboard and open the usage history to find your request and check the tokens consumed. If it has not appeared yet, wait a few moments and refresh the page.

Build this habit into your first tests. It will help you compare token usage across prompts and estimate your needs before choosing an offer.

Before changing models, check the route badge

The model name alone does not determine the request format. Check its route badge in the catalog:

  • OpenAI-compatible API: the format used in this guide, with POST /v1/chat/completions;
  • Claude Messages API: the Messages format, with POST /v1/messages.

Changing only the model name in your script is not enough if the new model uses a different protocol. The RouterLab API documentation explains both formats.

If your first call fails

Start with these three checks:

  • API key: is ROUTERLAB_API_KEY defined in the terminal running the command?
  • Model: did you copy its exact identifier, including the -trial suffix, and is it listed in the trial catalog?
  • Protocol: does your request format match the model's route badge?

Also check that your email is verified, your trial is still active and your daily quota has not been exhausted. If your evaluation needs a larger quota, open a ticket from your account and describe your requirements.

What happens after the trial?

Once your first call works, try a prompt that reflects your application: a user question, a summary or a text generation task.

Then compare the RouterLab offers. Subscriptions provide a monthly credit allocation; prepaid credits are also available without a subscription. Available models and routes depend on the offer you choose.

Create your trial account and send your first request.

RouterLab endpoint

Try the RouterLab API

Move from the article to a real request: start a trial, get a key, and call models through an OpenAI-compatible API.

https://api.routerlab.ch/v1

Audience measurement

Allow Google Analytics and RouterLab to measure public visits and link campaign sources to your signup? This is optional and can be changed at any time. If you decline, only anonymous visit totals are kept.