API reference
The API follows OpenAI's chat completions format at one base URL. You authenticate with a key from the dashboard.
https://cloud.mlx-optiq.com/api/v1
Authentication
Create a key on the dashboard and send it as a bearer token:
Authorization: Bearer sk-optiq-cloud-…. A key is shown once, when it is made. Each key has its own
limits.
Endpoints
| Method | Path | What it does |
|---|---|---|
| POST | /chat/completions | A chat completion, in OpenAI's format, streamed or not. |
| GET | /models | The models, with their prices and context windows. No key needed. |
Examples
With curl, and with OpenAI's Python client:
$ curl https://cloud.mlx-optiq.com/api/v1/chat/completions \
-H "Authorization: Bearer $OPTIQ_CLOUD_KEY" -H "Content-Type: application/json" \
-d '{"model": "glm-5.3-flash", "messages": [{"role": "user", "content": "Hello"}]}'from openai import OpenAI
client = OpenAI(base_url="https://cloud.mlx-optiq.com/api/v1", api_key=OPTIQ_CLOUD_KEY)
reply = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=[{"role": "user", "content": "Hello"}],
reasoning_effort="low",
)Standard settings are accepted: temperature, top_p,
stop, seed, tool_choice,
response_format, frequency_penalty,
presence_penalty, reasoning_effort, and
max_tokens up to the model's limit. Settings you leave out use the ones
the model was tested with. Each reply's usage says what the call cost
and the balance left. GET /api/v1/models lists the models with their
prices.
Streaming, usage and sessions
Set "stream": true for server-sent events in OpenAI's chunk format. The last chunk carries
usage, with the call's cost in dollars and your remaining balance in
usage.optiq_cloud; a reply that is not streamed carries the same usage.
Send an x-session-id header with the same value on every call of one task. Calls with the same
session stay with the provider that holds the conversation's prompt cache, which keeps cached input high,
and the dashboard groups them into one task.
Rate-limit headers
Every response carries x-ratelimit-limit-requests, x-ratelimit-remaining-requests and
x-ratelimit-reset-requests for the key's per-minute limit. A refused call (429) also carries
Retry-After, in seconds.
Errors
Each case comes back as a plain message in the client's own format, and nothing is charged for a call that did not run.
| Case | HTTP | Code |
|---|---|---|
| No key, or a revoked or unknown key | 401 | invalid_token |
| Expired key | 401 | key_expired |
| Balance empty | 402 | insufficient_balance |
| Key at its monthly spending limit | 403 | key_spend_limit_reached |
| Model not allowed for this key | 403 | model_not_allowed |
| Model not on the list | 404 | model_not_found |
| Too many requests, or too many at once | 429 | rate_limit_exceeded, concurrency_limit_exceeded |
| No provider can serve the model right now | 503 | model_unavailable |
Not signed in, through optiq serve | 401 | run optiq cloud login |
Another machine, through optiq serve | 403 | refused by optiq serve |