Skip to content

Commit 1fe121a

Browse files
committed
feat(enterprise/coderd): add AI Bridge providers and keys HTTP CRUD
Implements the AI Bridge provider configuration HTTP CRUD endpoints under /api/v2/aibridge/providers and the per-provider keys sub-resource under /api/v2/aibridge/providers/{idOrName}/keys. The routes are registered before the aibridged catch-all so /providers and reserved sub-paths (proxy, interceptions, sessions, models, clients) are not shadowed by the proxy. Handlers: GET /aibridge/providers POST /aibridge/providers GET /aibridge/providers/{idOrName} PATCH /aibridge/providers/{idOrName} DELETE /aibridge/providers/{idOrName} GET /aibridge/providers/{idOrName}/keys POST /aibridge/providers/{idOrName}/keys DELETE /aibridge/providers/{idOrName}/keys/{keyID} Validation rejects non-conforming names, reserved names, unknown provider types, and non-http(s) base URLs. Settings (Bedrock region/model/access-key/access-key-secret) are stored as a single JSON blob that is encrypted by dbcrypt; both Bedrock secrets are write-only and never appear in responses, and rotation skips unchanged secrets when the caller omits them on PATCH. API key bearer auth has moved off of ai_providers and onto the new ai_provider_keys table. Bedrock providers reject key creation because they authenticate via the settings blob; OpenAI/Anthropic providers accept 0..N keys to enable failover. The Delete handler verifies the URL provider parents the key and returns 404 otherwise to avoid leaking IDs across providers. The Create response and the List response omit the plaintext API key; clients must keep their own copy. Tests: TestAIProvidersCRUD adds BedrockSecretsHidden alongside the existing CRUD coverage to assert that bedrock_access_key and bedrock_access_key_secret never appear in responses. TestAIProviderKeysCRUD covers create/list/delete, the Bedrock rejection, missing api_key validation, the cross-provider delete isolation, omitted plaintext in responses, owner-only access, and unknown-provider lookup.
1 parent fb7c328 commit 1fe121a

7 files changed

Lines changed: 2825 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)