{"openapi":"3.1.0","info":{"title":"Leanroute API","version":"1.0.0","summary":"LLM gateway routing to 13 providers behind one OpenAI-compatible API.","description":"Route LLM calls to OpenAI, Anthropic, Google, xAI, DeepSeek, Groq, Meta, Qwen, GLM, Doubao, Kimi, Sarvam, and Krutrim through one API. Includes prompt caching, semantic caching, cross-provider failover, per-key spend caps, and MCP passthrough for Anthropic models.","termsOfService":"https://leanroute.dev/terms","contact":{"email":"support@leanroute.dev","url":"https://leanroute.dev"},"license":{"name":"Apache-2.0","url":"https://www.apache.org/licenses/LICENSE-2.0"}},"servers":[{"url":"https://api.leanroute.dev","description":"Production"}],"tags":[{"name":"chat","description":"OpenAI-shaped chat completions"},{"name":"embeddings","description":"OpenAI-shaped embeddings"},{"name":"models","description":"Available models"},{"name":"anthropic","description":"Anthropic-shaped messages (with mcp_servers passthrough)"},{"name":"mcp","description":"Model Context Protocol (Streamable HTTP transport)"},{"name":"platform","description":"Programmatic account management (admin-key auth)"}],"components":{"securitySchemes":{"RuntimeKey":{"type":"http","scheme":"bearer","bearerFormat":"gw_live_*","description":"Runtime gateway key for LLM traffic on /v1/*. Mint at https://leanroute.dev/dashboard/keys."},"AdminKey":{"type":"http","scheme":"bearer","bearerFormat":"gw_admin_*","description":"Admin gateway key for account management on /platform/v1/* and /mcp. Mint at https://leanroute.dev/dashboard/admin-keys."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"code":{"type":"string"}},"required":["message","code"]}}},"ChatCompletionRequest":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","description":"Provider-prefixed canonical id, e.g. `openai/gpt-5.6-luna`, `anthropic/claude-sonnet-4-6`, `google/gemini-2.5-flash`."},"messages":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["system","user","assistant","tool"]},"content":{"type":"string"}},"required":["role","content"]}},"temperature":{"type":"number","minimum":0,"maximum":2},"max_tokens":{"type":"integer","minimum":1},"stream":{"type":"boolean","default":false}}}}},"paths":{"/v1/chat/completions":{"post":{"tags":["chat"],"operationId":"createChatCompletion","summary":"Create a chat completion (OpenAI-compatible)","description":"Same wire shape as OpenAI's `POST /v1/chat/completions`. Model string is provider-prefixed (e.g. `anthropic/claude-sonnet-4-6`) so any of 13 upstream providers can be selected without swapping SDKs.","security":[{"RuntimeKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionRequest"}}}},"responses":{"200":{"description":"Success"},"402":{"description":"Insufficient credit — top up at /dashboard/billing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key class (admin key used on runtime endpoint).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/embeddings":{"post":{"tags":["embeddings"],"operationId":"createEmbeddings","summary":"Create embeddings (OpenAI-compatible)","security":[{"RuntimeKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","input"],"properties":{"model":{"type":"string","description":"Embedding model id, e.g. `openai/text-embedding-3-small` or `google/text-embedding-004`."},"input":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]}}}}}},"responses":{"200":{"description":"Success"}}}},"/v1/models":{"get":{"tags":["models"],"operationId":"listModels","summary":"List reachable models","description":"OpenAI-compatible list of models the caller can dispatch to (filtered by configured provider keys + BYOK).","security":[{"RuntimeKey":[]}],"responses":{"200":{"description":"OpenAI-shaped model list"}}}},"/anthropic/v1/messages":{"post":{"tags":["anthropic"],"operationId":"createAnthropicMessage","summary":"Anthropic Messages API (with mcp_servers passthrough)","description":"Anthropic-shaped endpoint. Point the official Anthropic SDK's base_url here. The `mcp_servers` field is forwarded end-to-end for Claude models — the only gateway that does this today.","security":[{"RuntimeKey":[]}],"responses":{"200":{"description":"Anthropic-shaped Message object"}}}},"/mcp":{"post":{"tags":["mcp"],"operationId":"mcpStreamableHttp","summary":"Model Context Protocol — Streamable HTTP transport","description":"MCP endpoint for agent clients (Claude Desktop, Cursor, Windsurf, Cline). Same 8 tools as `@leanroute/mcp-server` npm package minus `route_call` (which needs a runtime key). See https://leanroute.dev/docs/mcp-server.","security":[{"AdminKey":[]}],"responses":{"200":{"description":"MCP JSON-RPC response"}}}},"/platform/v1/pricing":{"get":{"tags":["platform"],"operationId":"getPricing","summary":"Full pricing catalog","security":[{"AdminKey":[]}],"responses":{"200":{"description":"Pricing catalog","content":{"application/json":{"schema":{"type":"object","properties":{"currency":{"type":"string","example":"USD"},"models":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string"},"tier":{"type":"string","nullable":true},"input_per_million_usd":{"type":"number"},"output_per_million_usd":{"type":"number"},"cached_input_discount":{"type":"number"},"vision":{"type":"boolean"}}}}}}}}}}}},"/platform/v1/usage":{"get":{"tags":["platform"],"operationId":"getUsage","summary":"Aggregated spend + token counts","security":[{"AdminKey":[]}],"parameters":[{"name":"from","in":"query","schema":{"type":"string","format":"date-time"},"description":"ISO date. Default: 30 days ago."},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"},"description":"ISO date. Default: now."},{"name":"group_by","in":"query","schema":{"type":"string","enum":["day","model","provider","key"]}}],"responses":{"200":{"description":"Aggregated usage"}}}},"/platform/v1/credit":{"get":{"tags":["platform"],"operationId":"getCredit","summary":"Prepaid-credit balance","description":"Read-only. Top-up initiation is dashboard-only for security — no programmatic path to spend the user's card.","security":[{"AdminKey":[]}],"responses":{"200":{"description":"Balance","content":{"application/json":{"schema":{"type":"object","properties":{"balance_usd":{"type":"string"},"bonus_credit_usd":{"type":"string"},"currency":{"type":"string","example":"USD"},"low_balance":{"type":"boolean"}}}}}}}}},"/platform/v1/keys":{"get":{"tags":["platform"],"operationId":"listRuntimeKeys","summary":"List runtime gateway keys","security":[{"AdminKey":[]}],"responses":{"200":{"description":"Runtime keys"}}},"post":{"tags":["platform"],"operationId":"createRuntimeKey","summary":"Mint a runtime gateway key (owner/admin only)","security":[{"AdminKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","maxLength":64}}}}}},"responses":{"200":{"description":"New key. `full_key` is returned exactly once — subsequent GETs return only the prefix."}}}},"/platform/v1/keys/{id}":{"delete":{"tags":["platform"],"operationId":"revokeRuntimeKey","summary":"Revoke a runtime gateway key (owner/admin only)","security":[{"AdminKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Revoked"},"404":{"description":"Not found"}}}}}}