API reference

Chat completions API

LineMod is a security gateway with agent behavior observability—guardrails at the edge, harness diagnostics across runs, and policy routing when you need it. This page is the chat completions API reference for that gateway. LineMod exposes an OpenAI-compatible surface on https://api.linemod.ai/v1 with gateway policy headers on every request and response.
Endpoints

Public gateway surface

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
List models available to your org and region. Catalog rows come from the platform model registry.

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

Optional per-request overrides. Org defaults and API key settings apply when a header is omitted.
HeaderValuesPurpose
X-LineMod-Securitystrict | standard | relaxed | offOverride security template for this request.
X-LineMod-Budget-MaxUSD floatPer-request spend cap hint.
X-LineMod-Fallbackcomma-separated modelsCustom fallback chain for this request.
X-LineMod-TagstringCost attribution label for usage reports.
X-LineMod-Cost-Quality0–10Cost-quality dial for supported auto:* templates.
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 idDeclare the calling agent or IDE client type (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 with your application request ID for support, billing reconciliation, and audit review.
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-ProfileResolved client profile id used for Agent insights and harness baselines.
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 availableCatalog, cooldown state, region filter, or failover chain.