mlx-optiq

API reference

The API follows OpenAI's chat completions format at one base URL. You authenticate with a key from the dashboard.

Base URL 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

MethodPathWhat it does
POST/chat/completionsA chat completion, in OpenAI's format, streamed or not.
GET/modelsThe 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.

CaseHTTPCode
No key, or a revoked or unknown key401invalid_token
Expired key401key_expired
Balance empty402insufficient_balance
Key at its monthly spending limit403key_spend_limit_reached
Model not allowed for this key403model_not_allowed
Model not on the list404model_not_found
Too many requests, or too many at once429rate_limit_exceeded, concurrency_limit_exceeded
No provider can serve the model right now503model_unavailable
Not signed in, through optiq serve401run optiq cloud login
Another machine, through optiq serve403refused by optiq serve