NanoClaw accesses Claude API at low cost via Defapi.
NanoClaw is a personal AI assistant running in an isolated container that interacts with users via WhatsApp. It can execute tasks and access files within a secure Linux container environment. By connecting NanoClaw to Defapi, users can enjoy powerful AI capabilities at a lower cost.
Introduction
NanoClaw primarily manages API authentication information through the .env file in the project's root directory.
The advantage of the Defapi platform is that it provides API interfaces fully compatible with official ones, with usage costs at only 50% of the official price, making it ideal for long-running personal AI assistants.
Almost all models on Defapi are compatible with the following protocols:
v1/chat/completionsinterfacev1/messagesinterfacev1beta/models/interface
Specific Procedures
-
Obtain API Credentials
Register an account on the Defapi platform and get your exclusive API Key. -
Configure Environment Variables
Open the.envfile in the root directory of the NanoClaw project. Modify or add the following configuration to point the API request address to Defapi and fill in your API Key:ANTHROPIC_API_KEY=your-defapi-api-key ANTHROPIC_BASE_URL=https://api.defapi.com/v1 -
Restart Application Service
After saving the configuration file, restart the NanoClaw service to apply the new environment variables.- If using a daemon (such as macOS
launchctl), please reload the service:launchctl unload ~/Library/LaunchAgents/com.nanoclaw.plist launchctl load ~/Library/LaunchAgents/com.nanoclaw.plist - If in development mode, you can re-run
npm run dev.
- If using a daemon (such as macOS
Verify if NanoClaw is Working Properly
Method 1: Direct Message Test
Ensure the service has started successfully. Open WhatsApp and send a test message in a registered group or a private chat with the assistant, for example:
@Andy Hello, please reply to this message to confirm the connection is normal.
If the configuration is correct, the assistant will respond within a few seconds.
Method 2: Check Running Logs
Confirm that API requests are successful and there are no authentication errors by checking the system's real-time logs:
tail -f logs/nanoclaw.log
tail -f logs/nanoclaw.error.log
If no errors such as 401 Unauthorized appear, it indicates the interface is connected normally.
5 Common Use Cases
-
24/7 Cross-Platform Communication Assistant
Ask the assistant questions anytime via the WhatsApp interface to get answers regarding general knowledge, programming challenges, or copywriting without opening specific applications. -
Automated Daily Task Planning
Set periodic instructions to have NanoClaw send weather forecasts and schedules every morning, or automatically organize work summaries at the end of each week. -
Intelligent Collaborator for Local Projects
Allow the AI assistant within the container to safely read specified working directories, letting it help you review code, find errors in projects, or summarize the core content of long documents. -
Real-time Web Information Retriever
Send a web link and ask the assistant to extract page content and generate key summaries; or have it search the web for specific news events and market trends. -
Browser Interaction Executor
Combined with browser automation tools, command the assistant to independently visit websites to perform complex operations, such as comparing product prices on e-commerce platforms or assisting in flight information queries.