Zeroclaw integrates Defapi's low-cost Gemini & Claude APIs
This tutorial will guide you on how to integrate various Large Language Models (LLMs) into Zeroclaw via the Defapi platform. With Defapi, you can gain an experience fully compatible with official interfaces at a highly cost-effective price.
Introduction
Zeroclaw is an autonomous AI Agent runtime environment built on Rust, supporting interactions with users through channels like Telegram, Discord, and Slack. Defapi is a platform that provides cost-effective model APIs, with prices at only half of the official rates. It supports stable global access and is fully compatible with the API protocols of major model providers (such as v1/chat/completions, v1/messages, v1beta/models/, etc.).
Steps
Integrating models through Defapi is straightforward. Here are the specific configuration steps.
1. Get the API Key
First, visit the Defapi official website and register an account. Obtain your exclusive API Key from the page of the model you need (e.g., Claude or Gemini models).
For example: Defapi Claude Page or Defapi Gemini Page.
2. Configure Environment Variables
Configure the corresponding environment variables in your system terminal or environment, entering your API Key:
For Claude models:
export ANTHROPIC_API_KEY="dk-xxxxxxxxxxxxxxxx"
For Gemini models:
export GEMINI_API_KEY="dk-xxxxxxxxxxxxxxxx"
3. Modify the Configuration File
Edit Zeroclaw's main configuration file (usually located at ~/.zeroclaw/config.toml), and adjust the settings based on the selected model.
Using Claude models (taking Claude Sonnet 4.5 as an example):
default_provider = "anthropic-custom:https://api.defapi.org"
api_key = "dk-xxxxxxxxxxxxxxxx"
default_model = "anthropic/claude-sonnet-4.5"
default_temperature = 0.7
Using Gemini models (taking Gemini 3 Flash as an example):
default_provider = "custom:https://api.defapi.org"
api_key = "dk-xxxxxxxxxxxxxxxx"
default_model = "gemini-3-flash"
default_temperature = 0.7
Tip: Defapi's interface is perfectly compatible with Anthropic's official
v1/messagesinterface and Google'sv1beta/models/*:generateContentinterface. You can switch seamlessly without modifying any underlying code.
Verifying if Zeroclaw is Working Properly
Once configured, you can verify if Zeroclaw has successfully connected to Defapi using the following methods.
Method 1: Direct Messaging Test
Start Zeroclaw in the terminal and send a test message:
zeroclaw agent -m "Hello, can you hear me?"
If the model returns a response normally and quickly, the configuration is successful.
Method 2: Using Diagnostic Commands
Zeroclaw has built-in diagnostic commands to check the operational status:
# View system status
zeroclaw status
# Run system diagnostics
zeroclaw doctor
# List all available providers and models
zeroclaw providers
Method 3: Channel Configuration Test
You can configure social channels (e.g., Telegram) for real interaction testing:
[channels_config.telegram]
bot_token = "123456:your-telegram-token"
allowed_users = ["*"]
5 Common Use Cases
Combined with the low-cost advantage of Defapi, Zeroclaw can be widely applied in the following scenarios:
Use Case 1: Code Review Assistant
Automatically review codebases to point out potential bugs, security vulnerabilities, and optimization suggestions.
[agents.code_reviewer]
provider = "anthropic-custom:https://api.defapi.org"
model = "anthropic/claude-sonnet-4.5"
system_prompt = "You are an expert code reviewer. Review the code for bugs, security issues, and best practices."
agentic = false
max_iterations = 1
Use Case 2: Intelligent Customer Service Bot
Provide 24/7 fast Q&A support and friendly responses to users.
[agents.support]
provider = "anthropic-custom:https://api.defapi.org"
model = "anthropic/claude-haiku-4.5"
system_prompt = "You are a helpful customer support agent. Be concise and friendly."
max_iterations = 3
Use Case 3: Automated Research Assistant
Can autonomously search the web and summarize results, suitable for deep investigation and information gathering.
[agents.researcher]
provider = "custom:https://api.defapi.org"
model = "gemini-3-flash"
system_prompt = "You are a research assistant. Search the web and summarize findings."
agentic = true
max_depth = 2
allowed_tools = ["web_search", "http_request", "file_read"]
max_iterations = 8
Use Case 4: Data Analyst
Connects local files with Shell tools to help analyze data and provide deep insights.
[agents.analyst]
provider = "anthropic-custom:https://api.defapi.org"
model = "anthropic/claude-sonnet-4.5"
system_prompt = "You are a data analyst. Analyze the provided data and provide insights."
agentic = true
allowed_tools = ["shell", "file_read"]
Use Case 5: Multimodal Content Generation
Combines various input sources (like images, documents) to quickly generate creative marketing copy or multimedia content.
[agents.content_creator]
provider = "custom:https://api.defapi.org"
model = "gemini-3-flash"
system_prompt = "You are a creative content creator. Generate engaging content based on user requests."
agentic = true
allowed_tools = ["web_search", "file_read"]
max_iterations = 3