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 or Responses to https://tokens.bd/v1, or Anthropic Messages to https://tokens.bd.
Models outside Amp's catalog#
Amp's docs say: "A mapping line can name any model ID, including a model that is not in Amp's catalog yet." So you can map a Tokens model that Amp doesn't list. Amp may not offer such a model in Tune Modes unless it knows the model's token limits.
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 |
responses | https://tokens.bd/v1 | https://tokens.bd/v1/responses |
anthropic-messages | https://tokens.bd | https://tokens.bd/v1/messages |
- Enter your API key,
tok_live_your_key. Amp sends it asAuthorization: Bearer.
chat-completions and responses append their path directly, so their base includes /v1. anthropic-messages appends /v1/messages, and Amp doesn't double a /v1 you leave on the base.
Amp stores the key with the connection; it doesn't read TOKENS_API_KEY.
3. Map Amp models to Tokens IDs#
For each 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 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. Amp may not offer a model outside its catalog until it knows the model's token limits. Check the mapping, and see Amp's model routing docs.
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 has an extra path, such as /chat/completions. Use https://tokens.bd/v1 for chat-completions and responses, 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 November 2026.