Skip to main content
POST
LLM Key Management

Overview

The LLM Key Management endpoints let you securely store encrypted LLM provider API keys in your Stratus account. These are optional — Formation provides a shared OpenRouter pool that handles all requests automatically when no native key is configured. Storing your own key bypasses the Formation pool entirely: you pay your provider directly and the 25% pool markup is not applied.
Key Resolution Priority: Stratus checks for keys in this order: (1) inline request headers, (2) vault-stored keys, (3) Formation’s pool. See Authentication - Key Resolution Priority for a full breakdown.

Why Store Your Own Keys?

No Markup

Bypass the Formation pool. Pay providers directly at your own rates — no 25% markup.

Privacy

Your keys are encrypted at rest using AES-256-GCM and never leave encrypted storage.

Secure Storage

Keys stored in Supabase Vault and validated on write.

Convenience

Store once, used automatically on every request — no need to pass headers.

Security Architecture

Encryption

  • Algorithm: AES-256-GCM (Galois/Counter Mode)
  • Storage: Supabase Vault (encrypted at rest)
  • Validation: Keys validated on storage (attempted API call to provider)
  • Caching: 5-minute in-memory cache for performance

Key Lifecycle

Vault Connection Required: These endpoints require active Vault connection. Check /health endpoint to verify vault: "connected" before use.

Endpoints

Store LLM Keys

Store encrypted LLM provider API keys. All fields are optional — provide any combination of the providers you want to use. Omitted keys remain unchanged.

Request

string
OpenAI API key (format: sk-proj-* or sk-*) — used for gpt-* models. Bypasses Formation pool for OpenAI requests.
string
Anthropic API key (format: sk-ant-*) — used for claude-* models. Bypasses Formation pool for Anthropic requests.
string
Google Gemini API key (format: AIza*) — used for gemini-* models. Bypasses Formation pool for Google requests.
string
OpenRouter API key (format: sk-or-*) — used as a native BYOK OpenRouter key. Bypasses Formation’s pool key entirely.
All fields are optional. You can supply any combination. Omitted keys remain unchanged (or unset if this is your first call). If no keys are stored, Formation’s shared pool handles requests automatically.

Response

Example


Get Key Status

Check which LLM keys are configured (does not return actual keys).

Request

No body required. Authentication via Authorization header.

Response

boolean
Whether Formation’s shared OpenRouter pool is available as a fallback. Always true for active accounts.
boolean
Whether an OpenAI API key is currently stored.
boolean
Whether an Anthropic API key is currently stored.
boolean
Whether a Google API key is currently stored.
boolean
Whether an OpenRouter API key is currently stored.
string | null
ISO 8601 timestamp of when the OpenAI key was last validated. null if no key stored.
string | null
ISO 8601 timestamp of when the Anthropic key was last validated. null if no key stored.
string | null
ISO 8601 timestamp of when the Google key was last validated. null if no key stored.
string | null
ISO 8601 timestamp of when the OpenRouter key was last validated. null if no key stored.

Example


Delete LLM Keys

Remove stored LLM keys from vault.

Request

Use the optional provider query parameter to delete a specific provider’s key. Omit to delete all keys.
string
Provider to delete: openai, anthropic, google, or openrouter.If omitted: Deletes all stored LLM keys.

Response

Example

Usage Workflow

Zero-Config Flow (Formation Pool)

No setup required. Make your first call immediately after getting a Stratus API key:

BYOK Setup Flow (Remove Markup)

Key Rotation

User Onboarding UI

How It Works with Predictions

When you make a prediction request, Stratus resolves the LLM key in priority order:
  1. Stratus receives request with your Stratus API key
  2. Checks for inline headers (X-OpenAI-Key, X-Anthropic-Key, X-Google-Key, X-OpenRouter-Key) — used immediately if present
  3. Checks vault for stored keys — used if found
  4. Falls back to Formation pool — Formation’s shared OpenRouter key is used; a 25% markup is applied to the credit cost
Cost transparency: The key_source and formation_markup_applied fields in every response tell you exactly how the request was billed.

Error Handling

Invalid Key Format

Solution: Verify key format matches provider requirements:
  • OpenAI: sk-proj-* or sk-*
  • Anthropic: sk-ant-*
  • Google: AIza*
  • OpenRouter: sk-or-*

Key Validation Failed

Cause: Key was rejected by provider during validation test Solution:
  • Verify key is active in provider dashboard
  • Check key has required permissions
  • Ensure no rate limits or billing issues

Vault Unavailable

Solution: Check /health endpoint for vault status. Wait for vault to reconnect or use alternative method (pass keys directly in requests).

Authentication Failed

Solution: Verify your Stratus API key is correct and active.

Security Best Practices

1. Validate Before Storage

Always validate keys work before storing:

2. Never Log or Expose Keys

3. Use HTTPS Always

4. Implement Key Expiry Checks

Comparison: Key Supply Methods

Inline Headers Example

Pass your key directly per-request at the highest priority. All four providers are supported:
Security Note: Passing keys directly in headers exposes them in logs and network traffic. Use stored keys for production.

Need Help?

Questions about LLM key management? Contact support@stratus.run