Check a provider API key before saving it
Calls the provider with the candidate key and returns whether it was accepted along with the model catalog it exposes, without storing anything. Because it performs a network call on the caller's behalf, it is gated on being able to list the workspace's model sources (`models:read`). A key the provider rejects comes back as `valid: false` rather than as an error.
Authorization
apiKey Workspace API key created in Workspace settings → API keys. Scopes on the key bound what it can read and write.
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
curl -X POST "https://example.com/v1/workspaces/string/model-sources/validate-key" \ -H "Content-Type: application/json" \ -d '{ "kind": "openrouter", "key": { "apiKey": "string" } }'{ "data": { "valid": true, "models": [ { "id": "string", "label": "string", "description": "string", "contextLength": 0, "pricing": { "prompt": "string", "completion": "string" } } ] }}{ "_tag": "ApiNotFound", "error": "not_found", "message": "That item does not exist, or this key cannot see it.", "status": 404}{ "_tag": "ApiNotFound", "error": "not_found", "message": "That item does not exist, or this key cannot see it.", "status": 404}Add a model source
Encrypts the supplied provider API key, stores it under a label with the chosen selection of models, and records the addition in the workspace event log without any key material. Requires `models:write`. An empty key or a label longer than 120 characters is rejected as a validation error, and a workspace may hold only one source per provider kind, so a second one conflicts.
Update or rotate a model source
Applies a partial update to the label, enabled flag, or selected model ids, and re-seals the stored key when a new one is supplied, recording whether a rotation happened in the workspace event log. Requires `models:write`. Returns a not-found error for an unknown source and a validation error for a label outside 1 to 120 characters or an empty rotated key.