Model API docs
Model API
Causal Reflection is an OpenAI-compatible chat completions API. It improves agent performance and reliability on long-running, tool-heavy work by adding a reasoning framework that helps agents adapt from their own outcomes—without changing how you call chat completions.
stream: true returns a server-sent event stream. Tool calls use the OpenAI tools and tool_calls shape.
Start here
- Create a key on the dashboard. The secret is shown once.
- Call
POST /v1/chat/completionswithAuthorization: Bearer,X-Session-Id, andX-Workload. - Send this run's task, then the message that reports the outcome. The pack page shows the message shape for each workload.
The keys page shows the base URL and the model id. The base URL is https://api.basedmodels.com/v1. GET /v1/models lists the model ids.
Call the API
Send the key as Authorization: Bearer. Keep one X-Session-Id for the whole workflow. Set X-Workload on the first call.
curl https://api.basedmodels.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "X-Session-Id: workflow-1" \
-H "X-Workload: generic" \
-H "X-Run-Id: run-1" \
-d '{"model":"glm-5.3-flash:causal-reflection","messages":[{"role":"user","content":"Check whether the daily export finished."}]}'
X-Run-Id can be left off. The same call from Python:
from openai import OpenAI
client = OpenAI(
base_url="https://api.basedmodels.com/v1",
api_key="YOUR_KEY",
)
client.chat.completions.create(
model="glm-5.3-flash:causal-reflection",
messages=[
{"role": "user", "content": "Check whether the daily export finished."}
],
extra_headers={
"X-Session-Id": "workflow-1",
"X-Workload": "generic",
},
)
A successful call returns a normal chat completion: id, object, model, choices, and usage.
| Header | What it does |
|---|---|
X-Session-Id | Names a session. The same id and the same key continue it. |
X-Workload | Chooses which pack reads the outcome. The first call stores it. |
X-Run-Id | Optional label. The session page shows it beside the workload. |
Sessions
A session is stored for the pair of API key and X-Session-Id. Reuse one id when the same job, customer, ticket, or project should stay consistent across calls. Send this run's task and the message that reports the outcome.
A daily job is the same rule. Hard-code one X-Session-Id, such as daily-export, and the same API key on every run. Each day sends that day's task and the tool result. A new id starts a new session.
Leave X-Session-Id off and a new prompt starts a session id such as sess_…. The API resumes a session without the header only when today's messages still begin with the stored transcript and that session was updated in the last 24 hours. A saved id still loads after that window.
X-Run-Id is a label on the session. Changing it changes the label only. The session stays keyed on X-Session-Id.
Choose a pack
X-Workload chooses the pack. Set it on the first call. Later calls on this session use the stored choice, including when the header is absent.
If the header is absent on the first call, the API guesses from the tools. Coding tool names such as read_file or apply_patch select coding. Any other tools select tool-use. No tools select generic.
For a daily job, send generic. The tool result can be a signal: line or a top-level outcome, status, ok, or is_error. The field table and the other packs are on the pack page.
| Pack | Use cases | Send it when | Where the outcome is |
|---|---|---|---|
generic | Daily jobs, per-customer or per-ticket agents, workflows with a simple success/failure signal | The result is a signal: line or a small JSON object | The tool result after the assistant tool call |
medical | Multi-step billing over one case, chart, or patient | Later questions need facts already taken from that record | The tool call's summary and answer; the tool result's outcome |
coding | Fixing tests, applying patches, iterating until the suite passes | The run is a test suite or a file edit | The test footer, or the edit result |
tool-use | Agents that call APIs or tools—search, booking, CRM updates | The agent calls tools and a normal result means success | The tool result after the assistant tool call |
query | Database or SQL agents that inspect schema and answer | The agent inspects a database and then answers | A JSON QUERY action, then the next user message |
forecast | Training or backtesting loops with a scored closed period | A script is fit, then a year closes with a score | The assistant command, then a later user message |
cohort | Clinical or research study agents probing columns, survival, or schema | A study prints columns, survival, or a failed probe | The latest user message |
strategy | Multi-round games or sims with named opponents and per-round scores (poker, trading, negotiations, competitive play) | A hand names an opponent and a chip change | The latest user message |
registry | Signal or spectrum scanning agents that remember peaks or centers | A scan prints detected peaks | The latest user message |
Missing or unknown X-Workload is not an error; the first call stores a guessed pack.
A pack reads only its own shape. A turn that does not match the pack leaves the session unchanged.
Messages
Send the messages the model should see on each call. When you reuse a session id, you do not need to resend the full conversation every time for the workflow to stay consistent. Include earlier messages when the model should see that text.
Images
The Model API accepts images. Put them in a message content list next to the text. The URL is https or a base64 data URI. The types are png, jpeg, jpg, gif, bmp, tiff, and ppm. One request can hold 120 images, and the base64 payloads together must be under 10 MB. The API does not download the URL.
{"role": "user", "content": [
{"type": "text", "text": "What is in this chart?"},
{"type": "image_url", "image_url": {"url": "https://example.com/chart.png"}}
]}
The session stores the text and an [image] marker. It does not store the image. Send the image again on a later call when the model should still see it.
Dashboard
The API Platform dashboard shows your API keys, usage, and cost. Sessions list by id with workload and optional run name. Beta accounts share a monthly usage cap across all keys on the account. The call that reaches the cap still completes. The next call returns HTTP 402.
Errors
| Status | When |
|---|---|
| 401 | The bearer token is missing or not a known key. |
| 400 | messages is missing or empty, the model id is unknown, or an image was sent to a model that does not accept one. |
| 402 | The account's list cost for this calendar month has reached its cap. The body is monthly spend cap reached. |
| 502 | The model provider failed. The body is detail. |
Limits
A different API key with the same session id is a different session. Unrelated tasks on one id share one session, so their outcomes can mix. When several callers use one id, the last completed call is what is stored.
A human approval counts when it comes back in the shape that pack reads. For generic, that is a tool result with a signal: line or a top-level outcome field.