Chat Completions API
POST https://inertialai.com/api/v1/chat/completions
Authorization: Bearer iai_...
Content-Type: application/json
The endpoint is OpenAI-compatible: request and response bodies follow the OpenAI Chat Completions schema, so official OpenAI SDKs and any framework built on them work unchanged against this base URL.
Request
{
"model": "inertialai-0.1",
"messages": [
{ "role": "system", "content": "You are a monitoring assistant." },
{ "role": "user", "content": "Readings: 2.1, 2.0, 4.8, 5.1. Normal or anomaly?" }
],
"max_tokens": 256,
"temperature": 0.2,
"logprobs": true,
"top_logprobs": 5
}
| Field | Type | Required | Description |
|---|---|---|---|
model | string | yes | Must be "inertialai-0.1". |
messages | array | yes | OpenAI-shaped message list. Roles: system, user, assistant. Content is text; include sensor readings, metrics, or market data inline as numbers or CSV-style rows. |
max_tokens | int | no | Cap on generated tokens. |
temperature | float | no | 0–2, default 1. Use low values for classification and extraction over your metrics. |
stream | bool | no | Not yet supported — set false (the default). stream: true returns 400. |
logprobs | bool | no | Return log-probabilities for each generated token. Free — no surcharge. |
top_logprobs | int | no | 0–5. Requires logprobs: true, otherwise the request is rejected with 422. Also returns the top-N alternative tokens and their logprobs at each position. |
series | array | array of arrays | no | Raw numeric series to analyse, as one channel or several. See Sending time series. |
rate | string | no | Spacing between samples in series, e.g. 1h, 5m, 1d. Labels the series for the model; defaults to 1h. |
latency_mode | string | no | interactive (warm replica, seconds) or batch (scale-to-zero, cheaper, minutes on a cold start). See Cold starts. |
:::warning OpenAI-compatible, but not every OpenAI parameter
The endpoint accepts the OpenAI request shape, and unknown fields are ignored
rather than rejected. These common OpenAI parameters are not implemented and
have no effect if you send them: top_p, stop, n, presence_penalty,
frequency_penalty, seed, user. Sampling is controlled by temperature and
max_tokens only.
:::
Getting numbers into the prompt
There are two ways. Prefer series — pass the raw numbers and let the upstream
model serialise them into its numeric vocabulary; see
Sending time series for the field's full behaviour, multi-channel
input and units.
You can also put numbers directly in the message text, which is what the rest of this section covers. The model is trained to read numeric sequences directly from message text. Practical guidance:
- Plain comma-separated values work well:
"2.1, 2.0, 2.2, 4.8". - Keep a consistent unit and state it once ("mm/s", "requests/s", "mmol/L").
- For multiple channels or timestamps, CSV-style rows
(
"ts,temp,load\n01:00,12.4,0.81") are the most reliably parsed layout. - Sub-sample very long histories; a few hundred to a few thousand points is the sweet spot for cost and accuracy.
Response
{
"id": "chatcmpl-9f3b2c...",
"object": "chat.completion",
"created": 1784563200,
"model": "inertialai-0.1",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "anomaly" },
"logprobs": {
"content": [
{
"token": "anomaly",
"logprob": -0.0726,
"top_logprobs": [
{ "token": "anomaly", "logprob": -0.0726 },
{ "token": "normal", "logprob": -2.6593 }
]
}
]
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 1,
"total_tokens": 43
}
}
choices[].message— the assistant reply.choices[].logprobs— present only when the request setlogprobs: true; OpenAI-shaped, one entry per generated token, each with optionaltop_logprobsalternatives.exp(logprob)is the model's probability for that token — the confidence signal; see Token-level confidence.finish_reason—stop(the model finished) orlength(it hitmax_tokens). There is no moderation layer on this endpoint, socontent_filteris never returned.usage— exact token counts; multiply by the per-token rates to reconstruct the charge.
Streaming
Streaming is not yet available: requests with "stream": true return
400. When it ships it will use OpenAI-format chat.completion.chunk
events over SSE (terminated by data: [DONE]), with each chunk carrying
the logprobs for its delta tokens — the standard OpenAI SDK streaming
iterator will work as-is. Until then, use non-streaming requests; logprobs
are fully supported there today.
Cold starts
Serving scales to zero when idle, so you are never billed for a GPU nobody is using. The trade is the first request after an idle period: measured at up to 5 minutes, because the inference engine compiles its execution graphs at startup — the same work that makes throughput cheap once warm. Subsequent requests return in seconds.
- Pass
"latency_mode": "interactive"when a person is waiting. That tier keeps a warm replica, so the first token arrives in seconds instead of after a boot. It costs more per request;batchscales to zero and is substantially cheaper. - Name a tier explicitly whenever latency or cost matters. Leaving
latency_modeunset does not meanbatch— the request goes to whichever endpoint is configured as the default, which may be either tier. - Set your HTTP client timeout above 360 seconds on the
batchtier — 400 s is a good default. A 30- or 60-second default will abort during a cold start and look like an outage; setting exactly 360 s races the API's own upstream timeout and turns a clean502into an opaque client-side abort. - Send a warmup ping (
max_tokens: 1) at process start, or on a timer ahead of scheduled jobs, and do not block a user on it — see the quickstart. - Once warm the model stays up for several minutes of inactivity, so a session of related questions pays this once.
- Cold starts are billed like any other request — only the tokens, no surcharge.
Errors
Standard OpenAI-shaped error envelopes and status codes:
| Status | Meaning | Fix |
|---|---|---|
401 | Missing/malformed key, out of credits, or unverified email | Check the Authorization: Bearer iai_... header first; if the key is good, check your balance in Billing and that your email is verified. The message body distinguishes the three. |
403 | Key revoked or expired | Create a fresh key in the dashboard |
422 | Body doesn't match the schema | Check model and messages; top_logprobs requires logprobs: true and must be 0–5 |
429 | Rate limited (300 requests/minute per account) | Back off and retry |
502 | Upstream model failed, or the request exceeded the timeout during a cold start | Retry with backoff; keep client timeouts above 360 s (see Cold starts) |
503 | Chat is not configured on this deployment | Not retryable — contact support |
Out of credits returns 401, not 402. The API has no 402 Payment Required
class today: insufficient credits, an unverified email and a bad key all raise the
same unauthorized error, so you cannot branch on the status code alone — read the
message. This is a known wart; if it changes, this table changes with it.
Pricing
| Input tokens | $0.25 / 1M |
| Output tokens | $1.25 / 1M |
logprobs / top_logprobs | Free |
Metered from usage on every response; the full billing model is on the
Billing & credits page.