TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/zeroclaw-labs/zeroclaw/llms.txt
Use this file to discover all available pages before exploring further.
Provider trait defines the interface for all LLM providers in ZeroClaw. Implement this trait to integrate new language model APIs into the framework.
Trait Definition
Required Methods
chat_with_system
One-shot chat with optional system prompt. This is the only required method - all other methods have default implementations.
Optional system prompt to guide the model’s behavior
The user message to send to the model
Model identifier (e.g., “claude-3-5-sonnet-20241022”, “gpt-4”)
Sampling temperature (typically 0.0-1.0)
The model’s response text, or an error
Optional Methods with Defaults
capabilities
Declare what features this provider supports.
false.
convert_tools
Convert unified tool specifications to provider-native format.
Array of tool specifications in unified format
Provider-specific tool payload format:
ToolsPayload::Gemini- Gemini functionDeclarations formatToolsPayload::Anthropic- Anthropic tools formatToolsPayload::OpenAI- OpenAI tools formatToolsPayload::PromptGuided- Text-based fallback (injected into system prompt)
ToolsPayload::PromptGuided with formatted instructions.
simple_chat
Simple one-shot chat without system prompt.
User message
Model identifier
Sampling temperature
chat_with_system with None as system prompt.
chat_with_history
Multi-turn conversation with message history.
Array of chat messages with roles (system, user, assistant, tool)
Model identifier
Sampling temperature
chat_with_system.
chat
Structured chat API for agent loop callers. Handles tool injection.
Model identifier
Sampling temperature
chat_with_tools
Chat with native tool calling support.
Message history
Provider-native tool definitions
Model identifier
Sampling temperature
chat_with_history and returns empty tool_calls vector.
supports_native_tools
Check if provider supports native function calling API.
Default: Returns capabilities().native_tool_calling.
supports_vision
Check if provider supports multimodal vision input.
Default: Returns capabilities().vision.
supports_streaming
Check if provider supports streaming responses.
Default: Returns false.
stream_chat_with_system
Streaming version of chat_with_system.
stream_chat_with_history
Streaming version of chat_with_history.
Default: Extracts last message and delegates to stream_chat_with_system.
warmup
Warm up HTTP connection pool (TLS handshake, DNS, HTTP/2).
Default: No-op.
Types
ChatMessage
ChatMessage::system(content)- Create system messageChatMessage::user(content)- Create user messageChatMessage::assistant(content)- Create assistant messageChatMessage::tool(content)- Create tool result message
ToolCall
TokenUsage
NormalizedStopReason
NormalizedStopReason::from_openai_finish_reason(raw: &str)NormalizedStopReason::from_anthropic_stop_reason(raw: &str)NormalizedStopReason::from_bedrock_stop_reason(raw: &str)NormalizedStopReason::from_gemini_finish_reason(raw: &str)
Implementation Example
Factory Registration
After implementing the trait, register your provider in the factory:Best Practices
Security: Never log API keys, tokens, or sensitive request/response data. Use the security policy framework for credential handling.
Related
- Tool Trait - Implement tools for providers to call
- Channel Trait - Implement communication channels
- Configuration Reference - Configure providers in config.toml