Skip to main content
Provider keys allow you to use your own API keys from LLM providers like OpenAI, Anthropic, Google, etc. This enables you to leverage your existing relationships and pricing with providers.

Create Provider Key

provider
string
required
Provider ID (e.g., “openai”, “anthropic”, “google-vertex-ai”) or “custom” for custom providers
token
string
required
The provider’s API key
organizationId
string
required
ID of the organization this key belongs to
name
string
Custom name for the provider (lowercase a-z only, required for custom providers)
baseUrl
string
Custom base URL (for custom providers or proxy endpoints)
options
object
Provider-specific configuration options
providerKey
object
The created provider key with masked token
curl -X POST https://api.llmgateway.io/keys/provider \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "openai",
    "token": "sk-proj-...",
    "organizationId": "org_abc123"
  }'
{
  "providerKey": {
    "id": "pk_xyz789",
    "maskedToken": "sk-proj-...xyz",
    "provider": "openai",
    "name": null,
    "baseUrl": null,
    "options": null,
    "status": "active",
    "organizationId": "org_abc123",
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-01-15T10:30:00Z"
  }
}
Provider keys are validated before creation. The system will test the key by making a test API call to the provider.

List Provider Keys

Retrieve all provider keys for organizations you belong to.
providerKeys
array
Array of provider key objects with masked tokens
curl https://api.llmgateway.io/keys/provider \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"
{
  "providerKeys": [
    {
      "id": "pk_xyz789",
      "maskedToken": "sk-proj-...xyz",
      "provider": "openai",
      "name": null,
      "baseUrl": null,
      "options": null,
      "status": "active",
      "organizationId": "org_abc123",
      "createdAt": "2024-01-15T10:30:00Z",
      "updatedAt": "2024-01-15T10:30:00Z"
    },
    {
      "id": "pk_abc456",
      "maskedToken": "sk-ant-...def",
      "provider": "anthropic",
      "name": null,
      "baseUrl": null,
      "options": null,
      "status": "active",
      "organizationId": "org_abc123",
      "createdAt": "2024-01-14T09:15:00Z",
      "updatedAt": "2024-01-14T09:15:00Z"
    }
  ]
}

Update Provider Key Status

Activate or deactivate a provider key.
id
string
required
Provider key ID
status
'active' | 'inactive'
required
New status for the provider key
curl -X PATCH https://api.llmgateway.io/keys/provider/pk_xyz789 \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"status": "inactive"}'
{
  "message": "Provider key status updated to inactive",
  "providerKey": {
    "id": "pk_xyz789",
    "maskedToken": "sk-proj-...xyz",
    "provider": "openai",
    "name": null,
    "baseUrl": null,
    "options": null,
    "status": "inactive",
    "organizationId": "org_abc123",
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-01-16T14:20:00Z"
  }
}

Delete Provider Key

Soft-delete a provider key. The key will be marked as deleted and can no longer be used.
id
string
required
Provider key ID
curl -X DELETE https://api.llmgateway.io/keys/provider/pk_xyz789 \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"
{
  "message": "Provider key deleted successfully"
}

Supported Providers

The following providers are officially supported:
ProviderIDValidation
OpenAIopenaiAutomatic
AnthropicanthropicAutomatic
Google Vertex AIgoogle-vertex-aiAutomatic
Azure OpenAIazure-openaiAutomatic
AWS Bedrockaws-bedrockAutomatic
CoherecohereAutomatic
MistralmistralAutomatic
GroqgroqAutomatic
Together AItogether-aiAutomatic
CustomcustomManual
For a complete list of supported providers, see the Providers documentation.

Custom Providers

You can add custom OpenAI-compatible providers:
1

Set provider to 'custom'

Use "provider": "custom" in your request
2

Provide a unique name

Choose a unique name (lowercase a-z only) for your provider
3

Specify the base URL

Provide the base URL for the OpenAI-compatible API
4

Add your API key

Include the API key from your custom provider
curl -X POST https://api.llmgateway.io/keys/provider \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "custom",
    "name": "mycompany",
    "token": "custom-api-key",
    "baseUrl": "https://api.mycompany.com/v1",
    "organizationId": "org_abc123"
  }'
Custom providers are not automatically validated. Make sure your endpoint is OpenAI-compatible.

Error Responses

{
  "message": "A key for provider 'openai' already exists for this project"
}

Best Practices

Security
  • Rotate provider keys regularly
  • Use different keys for development and production
  • Monitor key usage via activity logs
  • Revoke keys immediately if compromised
Cost Management
  • Set usage limits on API keys that use these provider keys
  • Monitor spending through your provider’s dashboard
  • Enable auto-top-up to avoid service interruptions
High Availability
  • Configure multiple providers for redundancy
  • Use fallback routing in your Gateway API requests
  • Monitor provider status pages for outages

Build docs developers (and LLMs) love