Skip to main content

Claude Code Integration

Use Korad.AI with Claude Code for instant cost savings.

Setup

Step 1: Set Environment Variables

export ANTHROPIC_BASE_URL="https://api.korad.ai/v1"
export ANTHROPIC_API_KEY="sk-korad-YOUR-KEY"

Step 2: Restart Claude Code

# Quit Claude Code completely
# Then restart
claude

That's it! Claude Code now routes through Korad.AI automatically.

Verification

Check that Claude Code is using Korad.AI:

claude
> Which API are you connected to?

You should see responses with korad_metrics showing your savings.

Configuration File

For permanent configuration, create ~/.claude/config.json:

{
"api_base": "https://api.korad.ai/v1",
"api_key": "sk-korad-YOUR-KEY"
}

Features

Full Compatibility

All Claude Code features work:

  • ✅ Code generation
  • ✅ File editing
  • ✅ Terminal commands
  • ✅ Multi-file operations
  • ✅ Context awareness

Automatic Savings

Every request automatically optimized:

claude
> Refactor this function
# Original cost via Anthropic: $0.15
# Your cost via Korad.AI: $0.05 (67% savings)

Example Session

$ claude
> Read the user authentication code
[Reading auth.py...]

> Add password reset functionality
[Analyzing existing code...]
[Generating password reset implementation...]
[Cost: $0.018 vs $0.054 via Anthropic]

> Write tests for the reset flow
[Creating test file...]
[Tests generated]
[Total session cost: $0.045 vs $0.135 via Anthropic]

Troubleshooting

"Connection Refused" Error

Make sure ANTHROPIC_BASE_URL is set:

echo $ANTHROPIC_BASE_URL
# Should output: https://api.korad.ai/v1

"Invalid API Key" Error

Verify you're using your Korad.AI key:

echo $ANTHROPIC_API_KEY | grep sk-korad
# Should match

No Savings Showing

Check that requests are going through Korad.AI:

# Look for korad_metrics in Claude Code's output

Advanced Configuration

Project-Specific Settings

Create .claude/config.json in your project:

{
"api_base": "https://api.korad.ai/v1",
"api_key": "sk-korad-PROJECT-SPECIFIC-KEY",
"model": "claude-sonnet-4-20250514-optim"
}

Savings Level

Set savings level per project:

{
"korad_settings": {
"savings_level": "high"
}
}

Best Practices

  1. Use environment variables — Keep API keys secure
  2. Monitor usage — Check dashboard for balance
  3. Test before committing — Verify code quality with optimization
  4. Use project-specific keys — Separate keys for different projects

Next Steps

Cursor Integration →