Skip to main content

API Key Management

Mesachat uses a flexible, scope-based API key system for AI provider access.

Key Types

TypeDescription
GlobalPlatform-provided keys shared across the platform
BYOKBring Your Own Key — your personal API keys

Supported Providers

  • OpenAI
  • Anthropic
  • Google (Gemini)

Adding Your Own Key (BYOK)

  1. Go to SettingsAPI Keys
  2. Click Add Key
  3. Select the provider
  4. Paste your API key
  5. Choose the scope (Tenant, Bot Group, or Bot)
  6. Click Save

Your key is encrypted with AES-256-GCM before storage.

Key Resolution Order

When Mesachat needs an API key, it checks scopes from most specific to least specific:

Bot BYOK → Bot Global → Tenant BYOK → Tenant Global

If your bot has a BYOK key, that's used first. Otherwise, it falls back through the hierarchy.

Key Validation

Mesachat periodically validates stored keys:

  • Active — Key is valid and working
  • Invalid — Key failed validation (check provider dashboard)
  • Expired — Key has passed its expiration date

Security

  • Keys are encrypted at rest using AES-256-GCM
  • Key hashes (SHA-256) are stored for identification without exposing the key
  • Keys are never exposed in API responses — only the last 4 characters are shown