Skip to navigation

LLM Requests

View as Markdown

This reference covers request fields and the built-in provider mappings. For the integration flow and a construction example, read LLM-Related Protocols. For the reply, continue to Responses and Streams.

Request envelope

An algorithm receives Request. Its llm_request contains the conversation; the remaining envelope data belongs to the application.

Field and typeMeaning
Request.llm_request: LlmRequestThe conversation and settings used by the algorithm and model client.
Request.metadata: Option<Metadata>Optional session, correlation, and routing metadata.
Request.raw_request: Option<Value>An optional original body retained by the host. Translation codecs do not read this field.

Codec replay uses LlmRequest.preservation, separately from the envelope’s raw body. See preservation and edits before changing a decoded request.

Conversation fields

These mappings describe the built-in codecs. Supported features also depend on the destination model. Select a Rust field or type for its full crate definition.

Protocol field and typeMeaningAnthropic MessagesOpenAI ResponsesChat Completions
LlmRequest.model: Option<String>Addressed model; the host can replace it with the selected target.modelmodelmodel
LlmRequest.instructions: Vec<InstructionBlock>Top-level system and developer instructions.Top-level system; no distinct developer authorityinstructionsLeading system/developer messages in messages
LlmRequest.messages: Vec<Message>Ordered turns, each with a role and content blocks.messages[]; inline system/developer messages are added to top-level system on encodeMessages, including system/developer messages, and tool items in inputmessages[], including later system/developer messages
LlmRequest.tools: Vec<Tool>Available functions, MCP toolsets, or retained provider definitions.tools[]tools[]tools[]; function definitions are nested in function
LlmRequest.tool_choice: Option<ToolChoice>Let the model choose, require a call, forbid calls, or select a named tool.auto, any, none, or toolauto, required, none, or functionauto, required, none, or function
LlmRequest.stream: boolRequest incremental output.streamstreamstream
LlmRequest.extensions: ProviderExtensionsProvider fields without a first-class neutral field.Source fields retained by the codecSource fields retained by the codecSource fields retained by the codec
LlmRequest.preservation: PreservationMetadataOriginal JSON used for same-format replay.Original parsed bodyOriginal parsed bodyOriginal parsed body

Messages and tool content

Message.role is a Role; Message.content is an ordered Vec<ContentBlock>. The content variants cover text, reasoning, media, tools, MCP activity, refusals, and unknown provider blocks. An unknown block retains its source format and raw JSON. Its retention does not make it usable in a different API.

Protocol field and typeMeaningAnthropic MessagesOpenAI ResponsesChat Completions
ToolDefinition.parameters: ValueJSON Schema for function arguments.input_schemaFunction parameterstools[].function.parameters
ToolCall.id: StringIdentifier that pairs a call with its result.tool_use.idfunction_call.call_idtool_calls[].id
ToolCall.name: StringFunction name.tool_use.namefunction_call.nametool_calls[].function.name
ToolCall.arguments: ValueParsed argument value.JSON-valued inputarguments, commonly a JSON-encoded stringfunction.arguments, commonly a JSON-encoded string
ToolResult.tool_call_id: StringIdentifier of the call being answered.tool_result.tool_use_idfunction_call_output.call_idTool message tool_call_id
ToolResult.content: Vec<ContentBlock>Ordered tool output.tool_result.contentfunction_call_output.outputTool message content
ToolResult.is_error: Option<bool>Whether tool execution failed, if reported.tool_result.is_errorNo dedicated error flagNo standard error flag

Tool definitions describe available work. A ToolCall records a model’s request to execute that work; it does not execute the tool. Keep call IDs and content order intact when writing an adapter.

Tool::Provider retains an unsupported tool definition for its source format. Built-in provider tools and reasoning signatures may have no valid counterpart in another API. Consult the translation limits instead of assuming a successful parse implies cross-provider support.

Generation settings

The request groups these fields in SamplingParams, OutputParams, and ReasoningParams. Optional values remain unspecified when absent; individual providers apply their own defaults and accepted ranges.

Protocol field and typeMeaningAnthropic MessagesOpenAI ResponsesChat Completions
SamplingParams.temperature: Option<f64>Sampling temperature.(omitted; refer to the note below)temperaturetemperature
SamplingParams.top_p: Option<f64>Nucleus-sampling probability mass.top_ptop_ptop_p
SamplingParams.top_k: Option<i64>Maximum candidate-token count.top_kNo standard fieldNo standard field
OutputParams.max_output_tokens: Option<u64>Output token budget.max_tokensmax_output_tokensmax_completion_tokens, or legacy max_tokens
OutputParams.response_format: Option<Value>Requested structured-output shape.output_config.formattext.formatresponse_format
OutputParams.is_schema_enforced: Option<bool>Override whether the provider must enforce the schema; absence retains native behavior.Schema-backed output configurationSchema strictness in text.formatSchema strictness in response_format
ReasoningParams.effort: Option<String>Requested reasoning effort.output_config.effortreasoning.effortreasoning_effort
ReasoningParams.raw: Option<Value>Provider-specific reasoning configuration.thinking controlsreasoning objectNo standard equivalent for the whole object

Anthropic temperature: Switchyard omits temperature when rebuilding Anthropic requests. Older models still support this parameter under API version 2023-06-01, but models released after Claude Opus 4.6 reject values other than the default 1.0. For model restrictions, refer to the Anthropic parameter documentation. API version 2026-10-21 removes the parameter entirely and rejects it even at its default value. For removal details, refer to Anthropic’s migration guide. Switchyard scales OpenAI temperatures from the 0.0–2.0 range to Anthropic’s 0.0–1.0 range before comparing with the default. An OpenAI temperature of 2.0 scales to Anthropic’s default of 1.0 and is omitted without diagnostics or rejection. Omitting a non-default value after scaling to Anthropic’s range follows the lossy-conversion policy. Exact preserved Anthropic requests can still retain temperature.

For older Anthropic models that support non-default temperatures under API version 2023-06-01, add these settings to the target’s TOML configuration:

omit_body_fields = ["temperature"]
extra_body = { temperature = 0.5 }

After translation, Switchyard removes any existing temperature and sets it to 0.5 in Anthropic’s units, without further scaling. This also overrides temperature in preserved requests. Refer to the target configuration reference for these settings.

Preserved same-format bodies take precedence over edits to these settings, including schema enforcement. See encoding an edited request.

Provider contracts

For complete provider schemas, see Anthropic Messages, OpenAI Responses, and Chat Completions. For response fields and event ownership, continue to Responses and Streams.