Amp (ampcode.com, from Sourcegraph) is a coding agent with a settings UI and a CLI. Its Model Routing feature lets you send requests for a model through your own connection, called a Custom URL. A Custom URL connection can speak OpenAI Chat Completions to https://tokens.bd/v1, or Anthropic Messages to https://tokens.bd.
The limitation: Amp routes only its own catalog#
Read this before you start, because it decides whether Amp works for you.
Amp's model mappings use Amp's canonical model IDs, written as provider/model. A Custom URL connection can only serve models that already exist in Amp's catalog. You can change the ID that gets sent upstream, but you cannot add a new model that Amp doesn't know about.
For Tokens that means:
- If a model is in Amp's catalog and Tokens carries the same model, you can route it through Tokens.
- You can't add
deepseek/deepseek-v4.1-flash, or any other Tokens model, to Amp unless Amp's catalog has an entry for it. We have not confirmed whether Amp's catalog includes a DeepSeek model that could map to Tokens.
If you want to choose any model from the Tokens catalog freely, use an agent with open custom provider support, such as OpenCode, Claude Code or Cline.
Add a Custom URL connection in Amp Model Routing#
1. Create a key#
Create a key in the dashboard. API keys covers spend caps and allow-lists. If you want Amp to use only certain models through Tokens, a key with an allow-list enforces that on our side.
2. Add the connection#
- Open your personal settings in Amp and go to Model Routing.
- Click Add and choose Custom URL. From the terminal,
amp config model-providersdoes the same. - Pick the format and base URL:
| Format | Base URL | Amp sends requests to |
|---|---|---|
chat-completions (default) | https://tokens.bd/v1 | https://tokens.bd/v1/chat/completions |
anthropic-messages | https://tokens.bd | https://tokens.bd/v1/messages |
- Enter your API key,
tok_live_your_key. Amp sends it asAuthorization: Bearer.
Get the base URL right for the format. chat-completions appends /chat/completions, so it needs /v1 in the base. anthropic-messages appends /v1/messages, so it must not.
Amp stores the key with the connection; it doesn't read TOKENS_API_KEY.
3. Map Amp models to Tokens IDs#
For each Amp catalog model you route, the mapping can rename the ID sent upstream. Amp's docs show the format with an exact line like this:
moonshotai/kimi-k3 -> kimi-k3-turboThe left side is Amp's canonical ID. The right side is the ID your connection receives. For Tokens, the right side must be the exact Tokens model ID. Tokens IDs also use provider/model form, but they don't always match Amp's spelling, so check the exact ID in the catalog or with:
curl -s https://tokens.bd/v1/models -H "Authorization: Bearer $TOKENS_API_KEY"Switch models#
Switching models in Amp works the way it always does: you pick from Amp's catalog. Which of those go through Tokens is decided by your Model Routing mappings. To route another model, add a mapping from its Amp ID to the matching Tokens ID. Choosing a model helps when Tokens offers several candidates.
Verify it works#
Test the key directly:
export TOKENS_API_KEY=tok_live_your_key
curl -s https://tokens.bd/v1/models -H "Authorization: Bearer $TOKENS_API_KEY"Then use Amp's own checks. In the UI, click Check Access on the connection. From the CLI:
amp config model-providers test <connection-id>
amp config model-providers check-access --provider-model <provider/model>Replace <connection-id> with your connection's ID and <provider/model> with the Amp catalog ID you mapped. Finally, run a short task in Amp with that model and confirm the request appears in your dashboard usage analytics.
Troubleshooting#
The model you want isn't selectable. It isn't in Amp's catalog. Model Routing can't add it. Use another agent for that model.
404 model_not_found. The right-hand side of the mapping doesn't match a Tokens ID. Copy it exactly from GET /v1/models.
404 on every request. The base URL doesn't match the format. Use https://tokens.bd/v1 for chat-completions and https://tokens.bd for anthropic-messages.
401 invalid_api_key. Wrong, revoked or rotated key. Rotation stops the old secret immediately.
403 model_not_allowed_on_key or tier_permission_denied. The key's allow-list or your plan doesn't include the mapped model.
429 errors. Read Retry-After; Troubleshooting lists each code.
Request formats are in Chat Completions and Messages.
Source: Amp docs, model routing, checked October 2026.