Overview
Claude Code is Anthropic’s official command-line tool that brings Claude’s intelligence directly into your terminal. It can understand your codebase, edit files, run commands, and help you build software faster. By connecting Claude Code CLI to FoxAPI, you can access Claude’s full capabilities through FoxAPI’s reliable API infrastructure.FoxAPI provides a dedicated endpoint optimized for Claude Code CLI traffic. Use
https://aicode.cookai.cc as the base URL for the best experience.Prerequisites
FoxAPI API Key
You need an active FoxAPI API key with access to Claude models.
Node.js 18+
Required for installing Claude Code CLI via npm. Alternatively, you can use the curl-based installer.
Installation & Configuration
Install Claude Code CLI
Choose your preferred installation method:Verify the installation:
- npm (Recommended)
- curl
Configure FoxAPI API
You need to configure Claude Code to route requests through FoxAPI. Create or edit the Claude Code settings file:
- macOS / Linux
- Windows
- Environment Variables
Edit
~/.claude/settings.json:Verify the Connection
Run the following command to confirm Claude Code is correctly routing through FoxAPI:Usage Examples
Explore a codebase
Explore a codebase
Fix a bug
Fix a bug
Write tests
Write tests
Refactor code
Refactor code
Troubleshooting
Error: Authentication failed or 401 Unauthorized
Error: Authentication failed or 401 Unauthorized
Error: Connection refused or timeout
Error: Connection refused or timeout
- Verify
ANTHROPIC_BASE_URLis set tohttps://aicode.cookai.cc(no trailing slash). - Check your network connection and ensure you can reach
aicode.cookai.cc. - If you are behind a corporate proxy, ensure the proxy allows HTTPS traffic to
aicode.cookai.cc.
Claude Code still tries to connect to Anthropic directly
Claude Code still tries to connect to Anthropic directly
- Make sure
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICis set to1. - If using
settings.json, ensure the JSON syntax is valid (no trailing commas, proper quoting). - Restart your terminal after making changes to environment variables or settings.
Settings file not taking effect
Settings file not taking effect
- Confirm the file is located at
~/.claude/settings.json(not inside your project directory). - Validate the JSON format using a tool like
jq: - Ensure there are no conflicting environment variables set in your shell profile that might override the settings file.
Security Best Practices
- Never commit your API key to version control. If using environment variables, add them to your shell profile rather than project files.
- Use project-scoped keys when possible. FoxAPI allows you to create multiple API keys — use a dedicated key for Claude Code so you can revoke it independently if needed.
- Monitor usage on your FoxAPI dashboard to detect any unexpected consumption.