Documentation 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 System
The Provider system abstracts model inference backends behind a uniform interface, enabling ZeroClaw to work with any LLM provider (OpenAI, Anthropic, local models, etc.) through a single consistent API.Architecture Overview
Provider Trait
All providers implement theProvider trait from src/providers/traits.rs:
Provider Capabilities
Providers declare capabilities to enable intelligent adaptation:Native Tool Calling
Providers that support native tool calling return structured tool calls:- OpenAI (GPT-4, GPT-3.5)
- Anthropic (Claude)
- Gemini
- Azure OpenAI
Prompt-Guided Tool Calling
Providers without native tool support use prompt injection:OpenAI Provider Implementation
Real implementation fromsrc/providers/openai.rs:
Provider Factory
Providers are instantiated via factory function insrc/providers/mod.rs:
Reliable Provider Wrapper
TheReliableProvider wrapper adds fallback chains and retry logic:
Stop Reason Normalization
Providers normalize stop reasons to a common enum:Token Usage Tracking
Configuration
Providers are configured inzeroclaw.toml:
Built-in Providers
| Provider | Native Tools | Vision | Streaming | Base URL |
|---|---|---|---|---|
| OpenAI | ✅ | ✅ | ✅ | https://api.openai.com/v1 |
| Anthropic | ✅ | ✅ | ✅ | https://api.anthropic.com |
| Gemini | ✅ | ✅ | ✅ | https://generativelanguage.googleapis.com |
| Ollama | ❌ | ❌ | ✅ | http://localhost:11434 |
| Azure OpenAI | ✅ | ✅ | ✅ | https://.openai.azure.com |
| AWS Bedrock | ✅ | ✅ | ✅ | Runtime endpoint |
| OpenRouter | ✅ | Varies | ✅ | https://openrouter.ai/api/v1 |
Adding a New Provider
FromAGENTS.md §7.1:
- Create provider file:
src/providers/new_provider.rs
- Register in factory:
src/providers/mod.rs
- Add tests: Test factory wiring and error paths
- Update docs: Add to
docs/providers-reference.md
Best Practices
Error Handling
- Return structured errors with context
- Distinguish retryable vs. non-retryable errors
- Log API errors at debug level, not error
Rate Limiting
- Respect provider rate limits
- Implement exponential backoff
- Surface rate limit errors to user
Security
- Never log API keys or tokens
- Use environment variables for credentials
- Validate API responses before parsing
Performance
- Reuse HTTP clients (connection pooling)
- Implement
warmup()for connection pre-warming - Stream responses when possible