Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Request field map

Rust and the proxy express the same request semantics through different envelopes. Rust uses an OpenAI-shaped serde_json::Value; the proxy groups its portable subset under config and everything else under provider_config.

Availability: Rust: flexible top-level JSON · Proxy/clients: typed compact envelope

Rust engine request

These are the stable, adapter-recognized fields. A field marked “mapped” is renamed or reshaped for the selected provider; unsupported controls are omitted.

FieldTypeClassBehavior
modelstringRoutingRequired; explicit provider/model or a recognized bare prefix
messagesarrayPortableRequired conversation history; translated to native message/content forms
streambooleanPortableSet to true by llmshim::stream; selects native streaming
max_tokensintegerPortable, mappedNative output limit; max_completion_tokens is accepted as an alias
temperaturenumberConditionalSent to Anthropic and Gemini; not copied by the OpenAI/xAI Responses adapters
top_pnumberConditionalSent to Anthropic and Gemini
top_kintegerConditionalSent to Anthropic and Gemini
stoparray of stringsConditional, mappedPassed as stop to Anthropic or mapped to Gemini stopSequences; omitted by OpenAI/xAI
reasoning_effortstringPortable, mapped/clampedUnified effort from none through max
reasoning_modestringPortable, mapped/clampedstandard or pro
reasoning_summarystringAnthropic (auto|none)Reasoning visibility → Anthropic thinking.display; auto→summarized (default with reasoning_effort), none→omitted for lower latency
toolsarrayPortable, mappedOpenAI Chat Completions function schema translated to native tools
tool_choicestring or objectPortable, mappedTranslated where the provider supports tool choice
x-openaiobjectNative passthroughFields copied to an OpenAI Responses request
x-anthropicobjectNative passthrough/controlAnthropic body fields plus extra_betas and disable_1m_context controls
x-geminiobjectNative passthroughGemini body fields; thinkingConfig goes under generationConfig
x-openrouterobjectNative passthrough/controlOpenRouter body fields (provider, models, transforms, route, native reasoning); http_referer/x_title become request headers
x-vllm / x-sglangobjectNative passthroughServer-specific body params for a self-hosted vLLM/SGLang server (chat_template_kwargs, separate_reasoning, guided_json, top_k, min_p, …)

There is no x-xai namespace. OpenAI additionally recognizes store, prompt_cache_key, prompt_cache_retention, safety_identifier, and speed. Anthropic recognizes cache_control, thinking, output_config, and speed. Those fields are provider-specific even when they are not wrapped in an x-* namespace.

The request is a Value, so Rust does not reject unknown keys up front. Adapters deliberately select only fields they understand. Do not assume an arbitrary top-level key reaches the provider; use a documented native namespace.

Reasoning values and family-specific clamps are canonicalized in Reasoning controls. Native namespaces and precedence are covered in Native provider controls.

Message fields

FieldTypePurpose
rolestringsystem, developer, user, assistant, or tool semantics
contentstring, array, or nullText and multimodal content blocks
tool_callsarrayComplete assistant tool requests, including owned id, wire_ids, and any signature object
tool_call_idstringConnects a role: "tool" result to its request
reasoningarrayOrdered typed blocks with origin, text or opaque data, signature/item identity, and original structured payload when needed
thought_signature (on a tool call)objectOpaque data plus origin; retain the whole object
Legacy reasoning siblingsstringsMigration input only; untracked data is dropped

Content blocks may use OpenAI image_url, Anthropic image, or Gemini inline_data input forms. See Images and vision.

Lossless reasoning round-trip

Preserve the complete assistant message, including reasoning[] and tool-call signature objects. llmshim reconstructs native reasoning only when the stored origin matches the target family and wire; encrypted data also requires a matching issuer binding. Anthropic thinking remains first and ordered, and Responses items retain their encrypted payloads. Unknown origins/families are never replayed. See reasoning replay.

Proxy request

FieldTypeClassEngine destination
modelstringRoutingtop-level model
messagesarrayPortabletop-level messages
streambooleanTransportselects SSE only on /v1/chat
configobjectPortablerecognized children become top-level engine controls
provider_configobjectPassthrough containereach non-reserved child is merged into the engine request
fallbackarray of stringsProxy orchestrationordered non-streaming backup routes; not sent to a provider
x-cacheobjectCaller stability annotationsnative breakpoints or prompt_cache_key; never forwarded verbatim

The exact config children are:

ChildTypeEngine field
max_tokensunsigned integermax_tokens
temperaturenumbertemperature
top_pnumbertop_p
top_kunsigned integertop_k
stoparray of stringsstop
reasoning_effortstringreasoning_effort
reasoning_modestringreasoning_mode

For example, this proxy fragment:

{
  "config": {"reasoning_effort": "high"},
  "provider_config": {
    "tools": [],
    "x-anthropic": {"disable_1m_context": true}
  }
}

becomes engine fields named reasoning_effort, tools, and x-anthropic. Because provider_config is merged after config, a same-named child there overrides the portable value. Prefer the x-* namespace for an intentional native override; it makes that loss of portability visible.

model and messages are reserved at the provider_config root. After named route defaults and aliases are resolved, the proxy validates only the selected provider's active namespace and wire. Every resolvable explicit fallback is validated the same way before the primary request runs. The proxy rejects fields that would replace the admitted model or main history/input container: x-openai.model/input, x-chatgpt.input, x-anthropic.model/messages, x-gemini.contents, x-openrouter.model/messages, and the corresponding model plus messages/input fields for any OpenAiCompatible provider's configured namespace and wire. A namespace is inactive only when neither the primary nor an explicit fallback or route can select its provider. Native system and instructions, tool definitions, schemas, output limits, OpenRouter routing preferences, and other documented controls remain valid and are included in the estimate when active.

Output contracts

response_format: {type:"json_schema", json_schema:{name?, schema, strict?}} requests validated JSON output. x-shim controls structured_output (auto|native|forced_tool|prompt), tool_calling (auto|native|prompt), and reasoning_capture (off|forced_tool). See capability shims for path selection, bounded repair, streaming behavior, and provenance.