types
Structs
Section titled “Structs”ChatMessage
Section titled “ChatMessage”Provider-neutral chat message supporting text, tool calls, and tool results.
Each provider maps this internal representation to its own wire format:
- OpenAI:
tool_callsin assistant messages,role: "tool"for results - Anthropic:
tool_usecontent blocks,tool_resultcontent blocks
Fields
| Field | Type | Description |
|---|---|---|
role | String | |
content | Option<String> | |
tool_calls | Option<Vec<ToolCallRequest>> | Tool calls requested by the assistant (present in assistant messages). |
tool_call_id | Option<String> | ID of the tool call this message is responding to (present in tool-result messages). |
name | Option<String> | Function name for tool-result messages. |
ToolCallRequest
Section titled “ToolCallRequest”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
| Field | Type | Description |
|---|---|---|
id | String | |
name | String | |
arguments | serde_json::Value |
ToolSchema
Section titled “ToolSchema”Fields
| Field | Type | Description |
|---|---|---|
name | String | |
description | Option<String> | |
parameters | serde_json::Value | |
strict | Option<bool> |
LlmRequest
Section titled “LlmRequest”Fields
| Field | Type | Description |
|---|---|---|
model | String | |
messages | Vec<ChatMessage> | |
tools | Option<Vec<ToolSchema>> | |
tool_choice | Option<ToolChoice> | |
temperature | Option<f32> | |
max_tokens | Option<u32> | |
extensions | Option<serde_json::Map<String, serde_json::Value>> |
Fields
| Field | Type | Description |
|---|---|---|
prompt_tokens | Option<u32> | |
completion_tokens | Option<u32> | |
total_tokens | Option<u32> |
LlmChoice
Section titled “LlmChoice”Fields
| Field | Type | Description |
|---|---|---|
index | u32 | |
message | ChatMessage | |
finish_reason | Option<String> |
ToolCall
Section titled “ToolCall”Fields
| Field | Type | Description |
|---|---|---|
id | Option<String> | |
call_id | Option<String> | |
name | String | |
arguments | serde_json::Value |
LlmResponse
Section titled “LlmResponse”Fields
| Field | Type | Description |
|---|---|---|
id | Option<String> | |
created | Option<u64> | |
model | Option<String> | |
choices | Vec<LlmChoice> | |
usage | Option<Usage> | |
tool_calls | Option<Vec<ToolCall>> |
ToolChoice
Section titled “ToolChoice”How the model should choose tools (OpenAI / Anthropic wire formats mapped internally).
Variants
| Variant | Description |
|---|---|
Auto | |
None | |
Required | |
Function(String) |
Methods
to_openai_value
Section titled “to_openai_value”fn to_openai_value(&self) -> serde_json::ValueOpenAI Chat Completions / Responses tool_choice JSON.
to_anthropic_value
Section titled “to_anthropic_value”fn to_anthropic_value(&self) -> serde_json::ValueAnthropic Messages tool_choice JSON.