Wildcard routing
Wildcard routing lets one deployment stand for many models. Instead of registering every model a provider offers, you register a pattern such as anthropic/*, and the gateway forwards any request whose model name matches it, using that deployment's credential. When the provider ships a new model, callers can use it straight away.
What this is for
Registering models one by one means somebody has to add every new model, and until they do, requests for it fail. A wildcard removes that chore for providers you trust completely, while explicit deployments still win for the models you want to limit, price or route differently. Spend is tracked per resolved model, so the bill stays accurate for every model reached through the wildcard.
Scenario
A research team wants to try every Anthropic model as soon as it comes out, through the gateway, with the team's budget and logging. The admin adds one anthropic/* deployment and gives the team's key access to anthropic/*. From then on a request for any Anthropic model name works, and the Usage page shows spend per model.
Steps
-
Add the wildcard deployment. In the Admin UI open Models + Endpoints, pick the Add Model tab, choose Anthropic as the Provider, pick All anthropic Models (Wildcard) under Spanway Model Name(s), choose the credential and click Add Model. The public and provider names are both
anthropic/*. From the command line:curl -X POST http://localhost:4000/model/new \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"model_name": "anthropic/*","spanway_params": {"model": "anthropic/*", "api_key": "os.environ/ANTHROPIC_API_KEY"}}'In
config.yamlthe same deployment, plus two more providers, looks like this:model_list:- model_name: "anthropic/*"spanway_params:model: "anthropic/*"api_key: os.environ/ANTHROPIC_API_KEY- model_name: "openai/*"spanway_params:model: "openai/*"api_key: os.environ/OPENAI_API_KEY- model_name: "bedrock/*"spanway_params:model: "bedrock/*"aws_region_name: us-east-1 -
Give a key access to the pattern. On the Virtual Keys page click Create Key and pick
anthropic/*in the models list, or create the key from the command line:curl -X POST http://localhost:4000/key/generate \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"models": ["anthropic/*"], "key_alias": "research-anthropic"}' -
Call any model under the pattern with that key.
curl -X POST http://localhost:4000/v1/chat/completions \-H "Authorization: Bearer $SPANWAY_RESEARCH_KEY" -H "Content-Type: application/json" \-d '{"model": "anthropic/claude-haiku-5-5", "messages": [{"role": "user", "content": "Hello"}]}' -
Check the listing.
GET /v1/models?return_wildcard_routes=trueon that key listsanthropic/*, and the Deployed Models tab shows the wildcard with its own Model ID.
Expected result
The part of the requested name that matches * replaces the * in spanway_params.model, so step 3 sends claude-haiku-5-5 to Anthropic with the deployment's key and returns a normal chat completion. The response header x-spanway-model-id names the wildcard deployment, the spend log records anthropic/claude-haiku-5-5 as the model, and the price comes from the bundled price map for that model. A request for anthropic/some-new-model released tomorrow works the same way with no change on the gateway.
Custom patterns
The pattern does not have to be a provider prefix. A public name pattern can map onto a provider path, so callers do not have to know the provider.
model_list:
- model_name: "claude-*"
spanway_params:
model: "anthropic/claude-*"
api_key: os.environ/ANTHROPIC_API_KEY
A request for claude-sonnet-5-5 is then sent to anthropic/claude-sonnet-5-5.
Matching rules
An exact model_name always wins over a wildcard, so you can register a few models explicitly, with their own limits, prices or credentials, and let a wildcard catch everything else. When several wildcards match, the most specific pattern is used, where longer patterns with fewer wildcards count as more specific. Wildcard deployments can be load balanced like any other group by repeating the same pattern with different credentials.
Access control
Keys, teams and organizations with a models list must include the pattern, for example anthropic/*, to use the models it covers. A key with models: ["anthropic/*"] can call any Anthropic model through the gateway and nothing else. Model access groups work the same way, add the wildcard deployment to the group.
Health checks and pricing
A wildcard deployment has no single model to test, so set model_info.health_check_model to a real model, as described in health checks. Costs are looked up per resolved model in the bundled price map. A model that is missing from the price map is recorded as unpriced, see cost tracking. The config file layout is in configuration.
Errors
| What you see | Why | Fix |
|---|---|---|
403 with key_model_access_denied | The key's models list does not include the pattern. | Add anthropic/* to the key, or to its team. See the error reference. |
400 Invalid model name passed in model=... | No deployment, exact or wildcard, matches the name. | Check the prefix matches a wildcard deployment, for example anthropic/ and not claude/. |
The provider answers 404 for the model | The name after the prefix is not a model the provider has. | Use the provider's exact model id. |
The health check fails with the provider's own model-not-found error for anthropic/* | The wildcard has no health_check_model, so the gateway sends the pattern itself to the provider. | Set model_info.health_check_model to a real model. |
A family alias such as claude-sonnet-latest returns 404 | Wildcards never answer family aliases, because the gateway cannot tell which concrete models the wildcard serves. | Add an explicit deployment for the member, or a model_group_alias. |
| The Usage page shows the model as unpriced | The resolved model is missing from the price map. | Add a custom price for it. |
Logs
Wildcard routing writes no log lines of its own. A wildcard health check without health_check_model fails on every health check cycle with the provider's error for the pattern, which shows on the health page and in the health check log, until you set one. Run the gateway with --detailed_debug to see which deployment a wildcard name resolved to.
Related
- Model management, adding deployments at runtime.
- Models + Endpoints page, the wildcard option in the form.
- Model family aliases, newest model of a family.
- Virtual keys, giving a key access to a pattern.
- Health checks, health checking a wildcard.
- Configuration, the config file layout.