Access control
Access control on the gateway answers three questions for every request. Who is calling, which routes they may hit, and which models, tools and data sources they may use. The caller is identified by a virtual key, a user session from the Admin UI, a JWT, or your own custom auth function. You decide the answers with roles on users, allowed routes and models on keys, access groups, and a short list of what team admins may change on their own teams.
When you would use this
A partner integration should only ever call chat completions and embeddings with one cheap model, and never touch management routes or other models. You give its key allowed_routes with those two routes and a model list with one model. Separately, the platform team wants team admins to manage their own members and keys but not raise their own budget. The defaults already do that, and you allow only tpm_limit and rpm_limit for team admins so they can tune rate limits themselves.
Before you start
You need a proxy admin key or an Admin role session. Roles are set per user, see users, and team roles per membership, see team budgets.
Step by step
-
Give each person the right role. In the Admin UI open Internal Users, open the user, click Edit Settings on the Details tab and pick the Global Proxy Role. Over the API set
user_roleon/user/newor/user/update.proxy_admincan call everything,proxy_admin_viewercan call read-only management routes,org_admincan manage teams and users inside their organization, andinternal_usercan manage only their own keys. Inference routes such as/v1/chat/completionsare open to any valid key, subject to its model access. Custom roles let enterprise deployments define their own.curl -X POST http://localhost:4000/user/update \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"user_id": "user-123", "user_role": "internal_user", "max_budget": 50}' -
Narrow the routes of a key. On the key form choose Key Type, AI APIs for inference only, Management for management routes only, or Full Access, or type exact routes under Allowed Routes on the key's Settings tab. Over the API pass
allowed_routeson/key/generate. The whole gateway can be narrowed withgeneral_settings.allowed_routes.curl -X POST http://localhost:4000/key/generate \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"allowed_routes": ["/v1/chat/completions", "/v1/embeddings"], "models": ["claude-haiku-5-5"]}'A request to any other route with that key returns
403. -
Grant models by group instead of by name. Tag deployments with access groups in the config and grant the group on keys and teams. New models added to a group become available to every key that has it.
model_list:- model_name: claude-sonnet-5-5spanway_params:model: anthropic/claude-sonnet-5-5api_key: os.environ/ANTHROPIC_API_KEYmodel_info:access_groups: ["frontier-models"]curl -X POST http://localhost:4000/key/generate \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"models": ["frontier-models"]}'When models, MCP servers and agents live in the database, manage the bundle on the Access Groups page or with the
/v1/access_grouproutes instead, see access groups. -
Decide what team admins may edit. Open Settings, then Admin Settings, open the UI Settings tab and tick the fields under Team admin editable fields, or set
general_settings.team_admin_editable_team_fields. See choosing what team admins can edit below for the values. -
Block a caller without deleting anything.
/key/block,/team/blockand/customer/blockstop all traffic from a key, team or end user, and the matching/unblockroute lets it through again. In the Admin UI the key's actions menu has Block Key, the team's Settings tab has Block team, and the customer's row menu has Block.curl -X POST http://localhost:4000/team/block \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"team_id": "team-ds"}'
What you should see
A key with allowed_routes answers 403 on every route outside the list and works normally on the listed ones. A key granted an access group lists the group's models in GET /v1/models. A team admin who opens Edit Settings on their team sees only the fields you allowed, with the note "A proxy admin chose which settings team admins can change." A blocked team's keys answer 401 until it is unblocked. Every role check that refuses a call returns 403 with a message naming the route.
Tools, vector stores and search tools
object_permission on keys and teams lists the MCP servers, MCP tools, vector stores, agents and search tools a caller may use. With general_settings.vector_store_deny_by_default or search_tool_deny_by_default set to true, a vector store or search tool must be granted explicitly. A key needs its own grant and its team's.
Model access groups over the API
A model access group is a name tag on deployments, for example production-models. A key or team that lists the tag in its models may call every deployment that carries it, so adding a model to the tag gives it to all of them at once. Besides the config file, proxy admins manage the tags over the API. These are different from the access groups that bundle models, MCP servers and agents and are attached to teams and keys with /v1/access_group.
-
Create a tag on every deployment of some model names, or on chosen deployment ids with
model_ids.curl -X POST http://localhost:4000/access_group/new \-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \-d '{"access_group": "production-models", "model_names": ["claude-sonnet-5-5", "gpt-5.5"]}' -
List the tags with
GET /access_group/list, or read one withGET /access_group/production-models/info.curl http://localhost:4000/access_group/production-models/info -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -
Change which models carry the tag. The list you send replaces the old one.
curl -X PUT http://localhost:4000/access_group/production-models/update \-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \-d '{"model_names": ["claude-sonnet-5-5"]}' -
Remove the tag from every deployment with
DELETE /access_group/production-models/delete. Keys and teams that list it lose those models on their next request.
Expected result. Step 1 answers with the tag and the deployments it was added to, and a key created with "models": ["production-models"] can call each of them. Each tag can also carry a budget, see the Budget tab on Models + Endpoints and /access_group/{access_group}/budget.
| Method | Path | Summary |
|---|---|---|
| POST | /access_group/new | Create a model access group |
| GET | /access_group/list | List model access groups |
| GET | /access_group/{access_group}/info | Read one model access group |
| PUT | /access_group/{access_group}/update | Replace the models of an access group |
| DELETE | /access_group/{access_group}/delete | Delete a model access group |
| GET | /access_group/{access_group}/budget | Read an access group's shared budget |
| PUT | /access_group/{access_group}/budget | Set an access group's shared budget |
| DELETE | /access_group/{access_group}/budget | Clear an access group's shared budget |
Choosing what team admins can edit
By default a team admin can add and remove members and manage keys, but cannot change the team's own limits. A proxy admin can allow more with general_settings.team_admin_editable_team_fields, or from Settings, Admin Settings, UI Settings, Team admin editable fields in the Admin UI.
general_settings:
team_admin_editable_team_fields:
- tpm_limit
- rpm_limit
- max_budget
- raise_max_budget
- projects
- member_key_budgets
| Value | What a team admin may then do |
|---|---|
tpm_limit, rpm_limit | Change the team's token and request limits with /team/update. |
max_budget | Lower the team's budget. |
raise_max_budget | Also raise the team's budget, never above the organization's budget and never removing the cap. |
projects | Create and update projects in the team with /project/new and /project/update. |
member_key_budgets | Change budget fields (max_budget, budget_duration, soft_budget, budget_limits) on other members' keys with /key/update. |
Any other field in a team admin's /team/update request is rejected with an error that names the field. Spend is never editable by team admins, because the stored value lags the live counter. What ordinary members may do with team keys is a separate list, see team member permissions.
Errors
| Error | Cause | Fix |
|---|---|---|
403 Call not allowed. User not proxy admin OR team admin. or another message naming the route | The caller's role does not cover the route. | Use a key or session with the right role, or grant a custom role. |
403 naming a route on a key with allowed_routes | The route is not in the key's list. | Add it to allowed_routes, or use Full Access as the key type. |
401 or 403 naming a model | The model is not in the key's, project's, team's or organization's list, or in a group the key holds. | Add the model or the access group to the key or team. |
403 Team admins on this proxy do not have permission to update '<field>'. Ask a proxy admin to add it under Settings > UI > Team admin editable fields. | A team admin sent a field that is not in team_admin_editable_team_fields. | Ask a proxy admin to add the field, or leave it out of the request. |
400 saying the budget cannot be raised | A team admin raised max_budget without raise_max_budget, or above the organization's budget. | Add raise_max_budget, or ask a proxy admin. |
403 on /v1/vector_stores or a search tool | vector_store_deny_by_default or search_tool_deny_by_default is on and nothing granted it. | Add the store or tool to object_permission on the key and its team. |
401 on every request from a team's keys | The team is blocked. | Unblock it with /team/unblock or Unblock team. |
Related
- Users for the role list, and custom roles to define your own.
- Team member permissions for what members may do with team keys.
- Access groups for bundles of models, servers and agents.
- IP and route allow-lists for limiting where requests may come from.
- MCP access control for tool level permissions.
- Admin Settings page for the UI Settings tab.