Claude Code with Synthetic
With Synthetic's native Anthropic API support, you can now use Claude Code with any model we support.
Native Anthropic API Support
Synthetic now provides native Anthropic API compatibility, allowing Claude Code to work seamlessly without additional software!
Installation
- bash
npm install -g @anthropic-ai/claude-code
Configuration
Environment Variables
Persistent Configuration
Add these values to your ~/.bashrc or ~/.zshrc to persist changes in new sessions.
- bash
# Server configuration
export ANTHROPIC_BASE_URL=https://api.synthetic.new/anthropic # What server to talk to instead of the default
export ANTHROPIC_AUTH_TOKEN=\${SYNTHETIC_API_KEY} # Auth key
# Model configuration
export ANTHROPIC_DEFAULT_OPUS_MODEL=hf:zai-org/GLM-4.6 # The model to use for opus plan mode
export ANTHROPIC_DEFAULT_SONNET_MODEL=hf:zai-org/GLM-4.6 # The model to use for most tasks
export ANTHROPIC_DEFAULT_HAIKU_MODEL=hf:zai-org/GLM-4.6 # Primarily used for summarization
export CLAUDE_CODE_SUBAGENT_MODEL=hf:zai-org/GLM-4.6 # When starting subagents, what model to use
# Privacy configuration
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 # Don't send telemetry data
Creating a Convenient Function
For easier access, create a synclaude function that launches Claude Code with Synthetic configuration:
- bash
# Add to ~/.bashrc or ~/.zshrc
synclaude() {
ANTHROPIC_BASE_URL=https://api.synthetic.new/anthropic \
ANTHROPIC_AUTH_TOKEN=${SYNTHETIC_API_KEY} \
ANTHROPIC_DEFAULT_OPUS_MODEL=hf:zai-org/GLM-4.6 \
ANTHROPIC_DEFAULT_SONNET_MODEL=hf:zai-org/GLM-4.6 \
ANTHROPIC_DEFAULT_HAIKU_MODEL=hf:zai-org/GLM-4.6 \
CLAUDE_CODE_SUBAGENT_MODEL=hf:zai-org/GLM-4.6 \
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
claude "$@"
}
# Then use: synclaude
Convenient Management CLI
Thank you to community member parnexcodes for building a convenient CLI (parnexcodes/synclaude) for using Claude Code with Synthetic.
See installation instructions at https://github.com/parnexcodes/synclaude
Third Party Package
parnexcodes/synclaude was developed by a member of our community and not affiliated with Synthetic. We have done an initial safety check, but do your due dilligence and provide API keys at your own risk.