Assistant Billing

Provider Keys

Let customers bring their own AI provider credentials (BYOK). When set, the gateway uses customer credentials instead of platform providers — no balance deduction, costs tracked per API key budget.

Auth: Session token (JWT) or platform key with X-Workspace-Id header.

List Provider Key Status

GET /v1/platform/provider-keys

Returns which providers have customer-supplied credentials.

const providers = await billing.providerKeys.list()

Response

{
  "data": [
    {
      "providerId": "openai",
      "name": "OpenAI",
      "hasKey": true,
      "env": ["OPENAI_API_KEY"]
    },
    {
      "providerId": "anthropic",
      "name": "Anthropic",
      "hasKey": false,
      "env": ["ANTHROPIC_API_KEY"]
    }
  ]
}
FieldTypeRequiredDescription
providerIdstringAlwaysProvider identifier
namestringAlwaysHuman-readable provider name
hasKeybooleanAlwaysWhether the workspace has set credentials
envstring[]AlwaysEnvironment variable names for the provider

Set Provider Credentials

PUT /v1/platform/provider-keys/:providerId

Store or update credentials for a provider. Credentials are encrypted at rest (AES-256-GCM).

Path Parameters

ParamTypeRequiredDescription
providerIdstringYesProvider identifier (e.g. openai, anthropic)

Body Parameters

NameTypeRequiredDescription
credentialsobjectYesProvider-specific keys (e.g. { "api_key": "sk-..." })
await billing.providerKeys.set('openai', { api_key: 'sk-proj-...' })

Response

{
  "success": true
}

Test Provider Credentials

POST /v1/platform/provider-keys/:providerId/test

Validate stored credentials by making a test API call to the provider.

Path Parameters

ParamTypeRequiredDescription
providerIdstringYesProvider identifier
const result = await billing.providerKeys.test('openai')

Response (success)

{
  "valid": true
}

Response (failure)

{
  "valid": false,
  "error": "Invalid API key"
}

Remove Provider Credentials

DELETE /v1/platform/provider-keys/:providerId

Delete stored credentials. Gateway falls back to platform providers.

Path Parameters

ParamTypeRequiredDescription
providerIdstringYesProvider identifier
await billing.providerKeys.remove('openai')

Response

{
  "success": true
}