Install the SDK and store your key
Use a virtual environment in your application. Set ROUTARA_API_KEY in your shell or secret manager; do not put the full key in a repository.
python -m pip install --upgrade openai
export ROUTARA_API_KEY="your-key"Send one request
The example uses alibaba-qwen-turbo, a low-cost text model. Check the live catalog before changing models; availability and price can change.
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["ROUTARA_API_KEY"], base_url="https://api.routara.ai/v1")
response = client.chat.completions.create(
model="alibaba-qwen-turbo",
messages=[{"role": "user", "content": "Reply with one short integration tip."}],
max_tokens=64,
)
print(response.id, response.model, response.usage)
print(response.choices[0].message.content)Check the result before migrating
A successful call returns a response ID, a model, usage, and assistant text. A 401 means the key or Authorization header is wrong. A 403 can mean account or regional policy. If the account has no eligible trial credit, add wallet funds before retrying; do not loop on a billing error.
Before you ship
- Start with one request and a low max_tokens value.
- Record the response ID when contacting support; never send your key.
- Compare the model and cost shown in your Routara account before sending production traffic.