Claude Code
Configure Claude Code CLI to use Eden AI’s multi-provider backend for enhanced flexibility and cost savings.Overview
Claude Code is Anthropic’s official CLI tool for AI-powered coding assistance. By default, it uses Anthropic’s API, but you can configure it to use Eden AI for:- Multi-provider access: Use GPT-4, Gemini, or other models alongside Claude
- Cost optimization: Leverage Eden AI’s competitive pricing
- Provider redundancy: Automatic failover if one provider is down
Prerequisites
- Claude Code installed (Installation Guide)
- Eden AI API key from https://app.edenai.run
Configuration
Claude Code can be configured to use custom API endpoints through environment variables or configuration files.Option 1: Environment Variables
Set environment variables before running Claude Code:Option 2: Configuration File
Create or edit the Claude Code configuration file:Using Different Models
With Eden AI, you can use models from different providers:Model Format
When using Eden AI with Claude Code, use theprovider/model format:
Anthropic Models
anthropic/claude-3-5-sonnet-20241022(recommended)anthropic/claude-3-opus-20240229anthropic/claude-3-sonnet-20240229anthropic/claude-3-haiku-20240307
OpenAI Models
openai/gpt-4openai/gpt-4-turboopenai/gpt-4o
Google Models
google/gemini-progoogle/gemini-1.5-pro
Permanent Configuration
Make the configuration permanent by adding to your shell profile: Reload your shell:Custom Model Switching Script
Create a script to easily switch between models: Usage:Features
Code Generation
Claude Code can generate code in any language with Eden AI:Code Review
Review and improve existing code:Refactoring
Refactor code with context awareness:Documentation
Generate documentation:Advanced Configuration
Custom Headers
If you need to pass custom headers (e.g., for analytics):Timeout Configuration
Adjust timeouts for longer requests:Troubleshooting
Authentication Errors
If you see authentication errors:- Verify your Eden AI API key is correct
- Check that the
ANTHROPIC_API_KEYenvironment variable is set - Ensure there are no trailing spaces in your API key
Model Not Found
Ensure you’re using the correct model format:Connection Issues
If you experience connection issues:- Check your internet connection
- Verify the base URL is correct:
https://api.edenai.run/v3/llm - Check Eden AI status: https://app-edenai.instatus.com
Cost Tracking
Monitor your Eden AI usage through the dashboard:Best Practices
1. Use Appropriate Models
Choose models based on task complexity:- Simple tasks:
anthropic/claude-3-haiku-20240307(fast, cost-effective) - Complex reasoning:
anthropic/claude-3-5-sonnet-20241022(best balance) - Maximum capability:
anthropic/claude-3-opus-20240229(most powerful)
2. Leverage Multiple Providers
Test different providers for different tasks:- Code generation: GPT-4 or Claude
- Explanation: Claude or Gemini
- Quick tasks: Haiku or GPT-3.5
3. Monitor Costs
Regularly check your Eden AI dashboard to track spending and optimize model selection.Integration with Git
Use Claude Code in Git hooks for automated code review:Next Steps
- Cline Integration - VS Code extension
- Continue.dev Integration - Another powerful VS Code extension
- API Reference - Complete API documentation
- LLM How-To Guides - Learn more about LLM features