Skip to content

types

Provider-neutral chat message supporting text, tool calls, and tool results.

Each provider maps this internal representation to its own wire format:

  • OpenAI: tool_calls in assistant messages, role: "tool" for results
  • Anthropic: tool_use content blocks, tool_result content blocks

Fields

FieldTypeDescription
roleString
contentOption<String>
tool_callsOption<Vec<ToolCallRequest>>Tool calls requested by the assistant (present in assistant messages).
tool_call_idOption<String>ID of the tool call this message is responding to (present in tool-result messages).
nameOption<String>Function name for tool-result messages.

A tool call as requested by the LLM in an assistant message.

arguments is normalized to serde_json::Value internally — OpenAI sends arguments as a JSON string, Anthropic sends input as a JSON object. Each provider normalizes on ingest and serializes back to its wire format.

Fields

FieldTypeDescription
idString
nameString
argumentsserde_json::Value

Fields

FieldTypeDescription
nameString
descriptionOption<String>
parametersserde_json::Value
strictOption<bool>

Fields

FieldTypeDescription
modelString
messagesVec<ChatMessage>
toolsOption<Vec<ToolSchema>>
tool_choiceOption<ToolChoice>
temperatureOption<f32>
max_tokensOption<u32>
extensionsOption<serde_json::Map<String, serde_json::Value>>

Fields

FieldTypeDescription
prompt_tokensOption<u32>
completion_tokensOption<u32>
total_tokensOption<u32>

Fields

FieldTypeDescription
indexu32
messageChatMessage
finish_reasonOption<String>

Fields

FieldTypeDescription
idOption<String>
call_idOption<String>
nameString
argumentsserde_json::Value

Fields

FieldTypeDescription
idOption<String>
createdOption<u64>
modelOption<String>
choicesVec<LlmChoice>
usageOption<Usage>
tool_callsOption<Vec<ToolCall>>

How the model should choose tools (OpenAI / Anthropic wire formats mapped internally).

Variants

VariantDescription
Auto
None
Required
Function(String)

Methods

fn to_openai_value(&self) -> serde_json::Value

OpenAI Chat Completions / Responses tool_choice JSON.

fn to_anthropic_value(&self) -> serde_json::Value

Anthropic Messages tool_choice JSON.