Skip to main content

Overview

CLI Proxy API includes integrated support for Amp CLI and Amp IDE extensions, enabling you to use your existing Google/ChatGPT/Claude OAuth subscriptions with Amp’s coding tools.

Key Features

  • Provider route aliases for Amp’s API patterns (/api/provider/{provider}/v1...)
  • Management proxy for OAuth authentication and account features
  • Smart model fallback with automatic routing
  • Model mapping to route unavailable models to alternatives (e.g., claude-opus-4.5claude-sonnet-4)
  • Per-client upstream routing for multi-tenant deployments
  • Security-first design with localhost-only management endpoints

Configuration

Basic Setup

Add the ampcode section to your config.yaml:
config.yaml

Model Mappings

Route unavailable Amp models to alternative models available in your local proxy. This is useful when Amp CLI requests models you don’t have access to (e.g., Claude Opus 4.5) but you have a similar model available (e.g., Claude Sonnet 4).
config.yaml
How it works:
  1. Amp CLI requests a model (e.g., claude-opus-4-5-20251101)
  2. If the model isn’t available locally, CLI Proxy API checks for a mapping
  3. If a mapping exists and the target model has providers, the request is routed to the target model
  4. If no mapping exists or the target model is unavailable, the request falls back to the Amp upstream

Per-Client Upstream Routing

For multi-tenant deployments, you can map different client API keys to different Amp upstream API keys:
config.yaml

Management Proxy Routes

The following routes are proxied to the Amp upstream for OAuth authentication and account management:
  • /api/auth/* - OAuth authentication flows
  • /api/user/* - User profile and settings
  • /api/internal/* - Internal Amp features
  • /api/meta/* - Metadata endpoints
  • /api/threads/* - Thread management
  • /api/telemetry/* - Telemetry data
  • /api/otel/* - OpenTelemetry integration
  • /api/tab/* - Tab management
  • /threads, /threads/* - Thread views (root-level)
  • /docs, /docs/* - Documentation (root-level)
  • /settings, /settings/* - Settings UI (root-level)
  • /auth, /auth/* - Auth flows (root-level)

Security

Management routes require a valid API key in the Authorization header. When restrict-management-to-localhost: true is enabled, these routes are only accessible from localhost (127.0.0.1 or ::1).

Provider Routes

Amp CLI uses provider-specific routes. CLI Proxy API automatically translates these to your local providers:

OpenAI/Codex

Anthropic/Claude

Google/Gemini

Example Setup

1

Configure CLI Proxy API

Add the ampcode section to your config.yaml:
config.yaml
2

Start CLI Proxy API

The server will listen on http://localhost:8317 by default.
3

Configure Amp CLI

Point Amp CLI to your local proxy endpoint:
4

Authenticate with Amp

Use Amp CLI’s normal authentication flow. OAuth requests will be proxied through CLI Proxy API to ampcode.com.
5

Start coding

Amp CLI will now use your local Google/ChatGPT/Claude OAuth subscriptions through CLI Proxy API:

Hot-Reload Support

The following configuration options support hot-reload without restarting the server:
  • model-mappings - Update model routing rules
  • upstream-api-key - Change the default upstream API key
  • upstream-api-keys - Update per-client upstream key mappings
  • upstream-url - Change the upstream URL
  • restrict-management-to-localhost - Toggle localhost restriction
Simply update your config.yaml and the changes will be applied automatically.

Troubleshooting

Model not found errors

If Amp requests a model that’s not available locally:
  1. Check if you have the provider configured (OAuth or API key)
  2. Add a model mapping to route to an available alternative
  3. Ensure the target model in your mapping has available providers

OAuth authentication fails

If OAuth authentication doesn’t work:
  1. Verify upstream-url is set correctly
  2. Check that management routes are accessible (not blocked by firewall)
  3. If using restrict-management-to-localhost: true, ensure you’re accessing from localhost

Fallback to upstream

If requests are falling back to the Amp upstream when you expect local routing:
  1. Enable debug logging: debug: true in config.yaml
  2. Check logs for “amp model mapping” messages
  3. Verify your model mappings are configured correctly
  4. Ensure the target model has available providers