Quickstart
Make your first authenticated ModelBeat call and read the annotated response.
1. Get a key
Create an API key in the ModelBeat console. Keys are prefixed mb_live_, are scoped to
one tenant, and are shown once. Store it in a secret manager, not in source.
export MODELBEAT_API_KEY="mb_live_..."2. Make a call
Any OpenAI client works. Change the base URL and the key, nothing else:
from openai import OpenAI
client = OpenAI(
api_key=os.environ["MODELBEAT_API_KEY"],
base_url="https://api.modelbeat.ai/v1",
)
r = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Explain prepaid inference in one sentence."}],
max_tokens=100,
)
print(r.choices[0].message.content)3. Read the response
The body is an ordinary OpenAI chat completion, plus two ModelBeat additions:
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1769472000,
"model": "claude-haiku-4-5",
"system_fingerprint": "fp_...",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": { "role": "assistant", "content": "..." }
}
],
// What it cost you. Not present on stock OpenAI.
"usage": {
"prompt_tokens": 18,
"completion_tokens": 42,
"total_tokens": 60,
"cost": {
"input_tokens_cost": 0.00009,
"output_tokens_cost": 0.00042,
"total_cost": 0.00051
}
},
// Which model actually served it. Not present on stock OpenAI.
"extra_fields": {
"request_type": "chat_completion",
"latency": 842,
"chunk_index": 0,
"routing_info": {
"provider": "bedrock",
"model": "claude-haiku-4-5",
"is_fallback": false
}
}
}Two fields to get familiar with now:
extra_fields.routing_info.modelis the model that actually answered. It is not always the model you asked for. See Routing transparency.usage.cost.total_costis what came off your balance. See Costs.
Guard `usage` before you read it
usage may be null when the serving provider reported no usage at all. Reading
usage.cost without checking is the most common way a first integration crashes in
production rather than in testing.
4. Keep the request id
Every response carries an X-Request-Id header. Log it. It is the fastest way for us to
trace a specific call, and it is present on failures as well as successes.
Next
- Errors. The two error envelopes and what each one means.
- Limits. What is supported, and what deliberately is not.
- API reference. Full schemas, with a playground.