API reference

Chat completions API

Use the OpenAI-compatible chat completions API at https://api.linemod.ai/v1. This reference covers endpoints, request and response headers, streaming, and errors.
Endpoints

API endpoints

Authenticate with Authorization: Bearer <api_key>.
POST/v1/chat/completions
Primary chat endpoint. Set model to a concrete ID or an auto:* alias. Supports stream: true for SSE chunks.
GET/v1/models
The response lists models available to your organization and region.

Request body (chat)

FieldTypeRequiredNotes
modelstringyesConcrete model ID or auto:balanced, auto:cost, etc.
messagesarrayyesOpenAI-compatible role/content messages.
streambooleannoWhen true, returns SSE data: chunks ending with [DONE].
temperaturenumbernoPassed through when supported by the routed model.
max_tokensintegernoCompletion token cap for the upstream call.
Headers

Gateway request headers

Use these optional headers to override settings for one request. If omitted, organization and API key defaults apply.
HeaderValuesPurpose
X-LineMod-Securitystrict | standard | relaxed | offOverride security template for this request.
X-LineMod-Budget-MaxUSD floatSuggested maximum spend for this request.
X-LineMod-Fallbackcomma-separated modelsCustom fallback chain for this request.
X-LineMod-TagstringCost attribution label for usage reports.
X-LineMod-Cost-Quality0–10Cost–quality preference for supported auto:* aliases.
X-LineMod-Session-IdstringSticky routing context across related turns.
X-LineMod-No-FailovertrueFail fast instead of rerouting to fallbacks.
X-LineMod-Run-Idstring (UUID)Attach gateway calls to an agent run waterfall. Reuse the same ID across every step in a multi-turn agent loop.
X-LineMod-Clientregistry idIdentify the agent or IDE client making the request (for example cursor, claude_code). Must match a published registry id when your org enforces client identification.
X-LineMod-Tool-ApprovaltokenApprove a gated agent tool call (agent security flows).
Transparency

Response headers

Log these headers alongside your application request ID to investigate routing, reconcile costs, and review security events.
HeaderDescription
X-LineMod-Request-IdUnique request identifier for audit correlation.
X-LineMod-Model-UsedConcrete model ID that served the request.
X-LineMod-Route-ReasonHuman-readable routing decision summary.
X-LineMod-Route-ConfidenceRouting confidence score when learned routes apply.
X-LineMod-Route-ExcludedTruncated list of models filtered out of consideration.
X-LineMod-CostEstimated request cost in USD.
X-LineMod-SavedSavings percentage vs a reference model (when configured).
X-LineMod-Credential-Sourceplatform | org_byok | platform_fallback
X-LineMod-CrossBordertrue when the call crossed region boundaries.
X-LineMod-Security-RiskInput risk level: low | medium | high | critical
X-LineMod-Output-RiskOutput risk tags when scanners flag content.
X-LineMod-Run-IdAgent run ID when agent mode is active (echoed when supplied on the request).
X-LineMod-Client-ProfileClient profile ID used by Agent Insights to compare agent runs.
X-LineMod-Client-Profile-SourceHow the profile was resolved: api_key, header, user_agent, or unknown.
X-LineMod-Run-Cost / X-LineMod-Run-StepsAggregated agent run cost and step count.
X-LineMod-Schema-Valid / X-LineMod-Schema-ErrorsStructured output validation results from the routing executor.
Streaming

SSE stream format

Streaming responses use standard OpenAI chunk objects. Upstream interruption may append an error event.
SSEchat.completion.chunk
data: {"object":"chat.completion.chunk","model":"deepseek-v3",
"choices":[{"delta":{"content":"Hello"},"finish_reason":null}]}

data: {"object":"chat.completion.chunk",
"choices":[{"delta":{},"finish_reason":"stop"}],
"usage":{"prompt_tokens":10,"completion_tokens":20,"total_tokens":30}}

data: [DONE]
Errors

Common status codes

Errors use a unified envelope: { "error": { "code", "message", "type" } }.
StatusTypical causeWhat to check
401Invalid or revoked API keyBearer token, key scope, and org membership.
402Insufficient platform creditsWallet balance or BYOK subscription status.
403Blocked by security policyTemplate level, tool permission, or output scanner verdict.
429Rate limitedOrg, key, or upstream provider throughput.
503No routable model availableModel availability, provider cooldown, region restrictions, and fallback configuration.