This guide explains how to configure Amp CLI to work with EllProxy, enabling you to use both Factory and Amp through a single proxy server.
EllProxy integrates with Amp CLI by:
- Routing Amp management requests (login, settings) to ampcode.com
- Routing Amp model requests through CLIProxyAPI
- Automatically falling back to ampcode.com for models you haven't authenticated locally
- EllProxy installed and running
- Amp CLI installed (
amp --versionto verify)
Edit or create ~/.config/amp/settings.json:
mkdir -p ~/.config/amp
cat > ~/.config/amp/settings.json << 'EOF'
{
"amp.url": "http://localhost:8317"
}
EOFThis tells Amp CLI to use EllProxy instead of connecting directly to ampcode.com.
Run the Amp login command:
amp loginThis will:
- Open your browser to
http://localhost:8317/api/auth/cli-login - EllProxy forwards the request to ampcode.com
- You complete the login in your browser
- Amp CLI saves your API key to
~/.local/share/amp/secrets.json
After login, the secrets file will have URL-specific keys that CLIProxyAPI can't read. You need to add a simple apiKey field.
Open the secrets file:
cat ~/.local/share/amp/secrets.jsonYou'll see something like:
{
"apiKey@https://ampcode.com/": "sgamp_user_01XXXXX...",
"apiKey@http://localhost:8317": "sgamp_user_01XXXXX..."
}Edit the file to add the apiKey field:
nano ~/.local/share/amp/secrets.jsonAdd a new line with just apiKey (copy the value from one of the existing keys):
{
"apiKey@https://ampcode.com/": "sgamp_user_01XXXXX...",
"apiKey@http://localhost:8317": "sgamp_user_01XXXXX...",
"apiKey": "sgamp_user_01XXXXX..."
}Important: The value should be identical to the other keys - just copy/paste it.
Or use this one-liner to do it automatically:
python3 << 'EOF'
import json
import os
secrets_file = os.path.expanduser('~/.local/share/amp/secrets.json')
with open(secrets_file, 'r') as f:
data = json.load(f)
# Get the API key from any URL-specific key
api_key = data.get('apiKey@https://ampcode.com/', data.get('apiKey@http://localhost:8317', ''))
if api_key and 'apiKey' not in data:
data['apiKey'] = api_key
with open(secrets_file, 'w') as f:
json.dump(data, f, indent=2)
print('✅ Added apiKey field to secrets.json')
elif 'apiKey' in data:
print('✅ apiKey field already exists')
else:
print('❌ No API key found in secrets.json')
EOFFor CLIProxyAPI to pick up the new API key:
- Quit EllProxy from the menu bar
- Launch EllProxy again
Now you can use Amp CLI normally:
# Interactive mode
amp
# Direct prompt
amp "Write a hello world in Python"
# With specific mode
amp --mode smart "Explain quantum computing"Amp CLI
↓
http://localhost:8317 (ThinkingProxy)
↓
├─ /auth/cli-login → /api/auth/cli-login → ampcode.com (login)
├─ /provider/* → /api/provider/* → CLIProxyAPI:8318 (model requests)
└─ /api/* → ampcode.com (management requests)
When Amp requests a model:
-
Local OAuth available? (e.g., you ran
--codex-loginfor GPT models)- ✅ Uses your ChatGPT Plus/Pro subscription (no Amp credits)
-
No local OAuth?
- ✅ Falls back to ampcode.com using your Amp API key
- Uses Amp credits
Example:
- If you've authenticated Claude (
--claude-login), Claude models use your subscription - Gemini models without local OAuth will use Amp credits
Problem: CLIProxyAPI can't find the Amp API key.
Solutions:
- Verify
~/.local/share/amp/secrets.jsonhas theapiKeyfield (see Step 3) - Restart EllProxy to reload the secrets file
- Check permissions:
ls -la ~/.local/share/amp/secrets.json(should be readable)
Problem: Amp can't reach the proxy.
Solutions:
- Verify EllProxy is running (check menu bar)
- Verify
AMP_URLis set:echo $AMP_URL(should showhttp://localhost:8317) - Test the proxy:
curl http://localhost:8317/api/user(should redirect or return HTML)
Problem: Path rewriting isn't working.
Solutions:
- Make sure you're using the latest EllProxy build
- Manually add
/api/to the URL in the browser if needed
If you have local OAuth tokens that have expired (e.g., old Google/Gemini auth), remove them:
# List current tokens
ls -la ~/.cli-proxy-api/*.json
# Remove expired token (example)
rm ~/.cli-proxy-api/ran@example.com-*.json
# Restart EllProxy
killall CLIProxyMenuBar
# Then launch EllProxy againTo use your own subscriptions instead of Amp credits for specific models:
/Applications/EllProxy.app/Contents/Resources/cli-proxy-api \
-config /Applications/EllProxy.app/Contents/Resources/config.yaml \
-login/Applications/EllProxy.app/Contents/Resources/cli-proxy-api \
-config /Applications/EllProxy.app/Contents/Resources/config.yaml \
-codex-login/Applications/EllProxy.app/Contents/Resources/cli-proxy-api \
-config /Applications/EllProxy.app/Contents/Resources/config.yaml \
-claude-loginAfter authenticating, restart EllProxy. Those models will now use your subscriptions instead of Amp credits.
✅ One proxy for everything - Factory, Amp, and any other tool
✅ Smart fallback - Uses your subscriptions when available, Amp credits when not
✅ Seamless integration - Amp works exactly as before, just through the proxy
✅ Cost optimization - Maximize use of existing subscriptions, minimize Amp credits
