Skip to content

ToolSchema ​

Category: LLM Providers

Source: tool_schema.dart

Classes ​

sealed ToolSchemaEncoder ​

Encodes [Tool] definitions into provider-specific JSON schemas.

Constructor ​

dart
const ToolSchemaEncoder()

AnthropicToolEncoder ​

Anthropic Messages API tool format.

Uses the existing Tool.toSchema() which already produces {name, description, input_schema: {type, properties, required}}.

Constructor ​

dart
const AnthropicToolEncoder()

GeminiToolEncoder ​

Gemini Developer API tool format.

Wraps every declaration in a single {functionDeclarations: [...]} entry and uppercases JSON-Schema type values (Gemini expects OBJECT, STRING, ARRAY, etc.). Per-parameter items schemas are also walked so array element types stay valid.

Constructor ​

dart
const GeminiToolEncoder()

OpenAiToolEncoder ​

OpenAI Chat Completions function-calling format.

Wraps each tool in {type: "function", function: {name, description, parameters}}.

Constructor ​

dart
const OpenAiToolEncoder()

Released under the MIT License.