Skip to main content
POST

Authorizations

Authorization
string
header
required

Send your SLNG API key as a Bearer token (an OpenAI SDK's api_key option). Provider credentials in slng_config authenticate to those providers.

Headers

X-Slng-Agent-Id
string

Stable agent ID. Scopes the cache — change it when the system prompt changes. Required unless sent as slng_agent_id (body wins). Max 256 chars; no whitespace, commas, pipes or braces.

Opaque ID. Max 256 characters; no whitespace, commas, pipes or braces.

Maximum string length: 256
Pattern: ^[^\s,|{}]+$
X-Slng-Session-Id
string

ID for a single call, constant across its turns. Required unless sent as slng_session_id (body wins). Same character rules as the agent ID.

Opaque ID. Max 256 characters; no whitespace, commas, pipes or braces.

Maximum string length: 256
Pattern: ^[^\s,|{}]+$
X-Slng-Request-Id
string

Optional correlation ID, echoed back in x-slng-request-id. X-Request-Id is also accepted.

Body

application/json

OpenAI Chat Completions body plus SLNG extensions. Unlisted OpenAI fields pass through.

messages
object[]
required

OpenAI messages array. template_variables substitution touches the system message only.

Minimum array length: 1
model
string
default:slng/auto

slng/auto (or omit) answers from your configured models with failover, and picks a tier for each request when you configure two or more tiers. Pass an entry's model label to pin that model: no per-turn routing, no failover to another model, and a separate cache. Any other value returns a 400.

Examples:

"slng/auto"

"gpt-4o-mini"

temperature
number

OpenAI parameter, passed through.

top_p
number

OpenAI parameter, passed through.

max_tokens
integer

OpenAI parameter, passed through.

max_completion_tokens
integer

OpenAI parameter, passed through.

stream
boolean
default:false

true for SSE streaming, false for a single JSON response. Supported for every model.

stream_options
object

Streaming options.

tools
object[]

OpenAI tool definitions. Answers with tool calls, and the turn after a tool result, are not cached.

tool_choice

OpenAI tool choice, passed through.

template_variables
object

SLNG extension. {name: value} map substituted into {{name}} placeholders in the system message only. Names are letters, digits and underscore.

Limits (over any returns 422): 64 variables, 64-char names, 4000-char values. A {{name}} with no value returns 422 (missing_template_variables); unused variables are ignored.

Use for personalization that is spoken or echoed. Values that steer the answer (language, plan, region) belong in the prompt — steering here can make the cache serve another caller's answer.

Example:
slng_config
object

SLNG extension. Your models, endpoints and provider keys sent inline, applied on top of the configuration your request uses (a project's key uses that project's). With tiers, those models answer; without tiers, that configuration's models answer. Settings you don't send come from that configuration; the fields you send apply to this request only. The fields below are the ones most requests need: any other top-level setting of the configuration can be sent the same way, and an unknown field returns 400. Treat as a credential (HTTPS, keep out of logs); under 256 KB serialized. Invalid config returns 400 (invalid slng_config:); a non-object returns 422 (invalid_slng_config).

slng_agent_id
string

Body form of X-Slng-Agent-Id. Required unless the header is sent; wins if both.

Maximum string length: 256
Pattern: ^[^\s,|{}]+$
slng_session_id
string

Body form of X-Slng-Session-Id. Required unless the header is sent; wins if both.

Maximum string length: 256
Pattern: ^[^\s,|{}]+$
slng_analytics
boolean
default:false

Set true to record the request and response (in-region) for analytics. Requires both IDs.

slng_pure_proxy
boolean
default:false

Set true to return the provider response with no caching or edits. Failover still applies. There is no per-turn tier pick: with two or more tiers, your default_tier answers every turn, including turns that may need a tool call.

Response

Chat completion in OpenAI format, live or cached. See x-slng-response-source.

OpenAI Chat Completions response, live or cached. usage reports the cached answer's tokens on a hit, billed tokens on a live answer.

id
string
object
string
Example:

"chat.completion"

created
integer
model
string
choices
object[]
usage
object