API Keys, Spend Limits & Access
Every client request—including Chat (/) and MCP (/mcp)—authenticates with an API Key (/api-keys). Keys isolate model visibility, rate limits, spend budgets, and platform tool privileges per client or team.

Prerequisites
- At least one enabled Model Route: Prepare the
Model IDs you want the key to access.
Steps
Create and scope an API key
Open Setup → API Keys → Create key (or click an existing key to edit at
/api-keys/[id]):- Name & Expiration: Set a descriptive label and optional expiration timestamp.
- Allowed models: Leave Allow all models checked, or restrict the key to specific logical models. (On
Connect clients, a key must allow at least one eligible inference or image route.) - RPM limit: Leave blank for unlimited, or enter an integer request limit enforced across a strict 60-second sliding window (one client request = one count, regardless of stream length).
Set and reset Spend limits (
spend_limit)Optionally assign a positive decimal Spend limit in your configured currency (USD or custom currency). Before accepting inference or MCP work, Stravia checks available budget before applying RPM admission.
- You can explicitly reset accumulated spend (
POST /api/v1/api-keys/{id}/spend/reset) after confirmation. - Resetting spend zeroes the key's spend counter without deleting historical billing records, usage charts, or disabling the key.
- You can explicitly reset accumulated spend (
Separate MCP access from Transparent Injection
Stravia exposes two independent tool-permission controls on every API key:
- MCP access (
mcp_access_enabled): Allows MCP clients connecting to/mcpto authenticate with this key and calltools/list/tools/callfor enabled platform capabilities. Enabling MCP access does not turn on transparent injection. - Transparent tool injection (
transparent_injection_enabled+transparent_injections[]): When the master switch is on, Stravia exposes a baseStraviaReadreader (for upstream-referenced files) plus whichever capabilities you explicitly select:web_search— injectsStraviaSearch/ web search capability into ordinary inference requests.media_understanding— enables image/document/audio understanding tools when the client's chosen model lacks native support or needs extraction.media_generation— exposes image generation (StraviaGenerateImage/generate).history_recall— lets the model search and read past interactions viastravia://history/(read-only; never exposed over/mcp).
History recall shares conversations per API keyhistory_recallscopes access by API key principal, not per end user. Any caller sharing the same API key can read prior conversations and tool arguments recorded under that key withinlog_retention_days.- MCP access (
Verify
Copy the generated key (e.g., sk-stravia-demo-not-a-real-key in documentation examples) and call /v1/models or send a test chat request. Verify the key only lists and invokes its authorized models.
Troubleshooting
- Client receives
402/ spend limit exceeded or429RPM error: Check the key's remaining spend budget or 60-second sliding request rate on/api-keys. - Legacy
inject_*fields rejected via Admin API: Since v0.7.0,inject_web_search,inject_media_understanding, andinject_media_generationbooleans are removed; usetransparent_injections: [...]instead.
Next
- Platform Capabilities Overview — learn when to choose transparent injection vs. MCP.
- MCP Server & History Recall — inspect
StraviaReadbodysyntax andstravia://history/paths.