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. model takes
auto (or an intelligence tier) — you do not name a
model on this API:
import os
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 the ModelBeat cost breakdown:
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1769472000,
"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
}
}
}The one field to get familiar with now is usage.cost.total_cost — 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
- Routing. What
autoactually does. - Capabilities. Tool calling, vision, and the SDKs.
- 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.