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) routes across your configured models with failover. Pass an entry's model label to pin one — disabling failover and giving it 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. Model endpoints and provider keys sent inline, replacing your saved configuration for that request. 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. Routing and failover still apply.

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