{"openapi":"3.1.0","info":{"title":"zrouter AI API Gateway & FinOps Control Plane","version":"0.1.0","description":"Single-binary Rust AI API Gateway supporting OpenAI, Anthropic, Responses, Gemini, Embeddings, opt-in auto/* smart routing, Prometheus/OTel observability, and multi-tenant FinOps."},"servers":[{"url":"https://console.zrouter.space"}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer"},"AnthropicApiKey":{"type":"apiKey","in":"header","name":"x-api-key"},"GoogleApiKey":{"type":"apiKey","in":"header","name":"x-goog-api-key"}}},"paths":{"/v1/chat/completions":{"post":{"tags":["Gateway"],"summary":"OpenAI Chat Completions (supports auto/* smart routing & combos)","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"JSON or text/event-stream SSE response"}}}},"/v1/messages":{"post":{"tags":["Gateway"],"summary":"Anthropic Messages API with prompt caching and cross-provider translation","security":[{"AnthropicApiKey":[]},{"BearerAuth":[]}],"responses":{"200":{"description":"Anthropic JSON or SSE stream"}}}},"/v1/messages/count_tokens":{"post":{"tags":["Gateway"],"summary":"Deterministic Anthropic input token estimation","responses":{"200":{"description":"Estimated input_tokens"}}}},"/v1/responses":{"post":{"tags":["Gateway"],"summary":"OpenAI Responses API and Codex CLI compatibility","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Responses JSON or SSE stream"}}}},"/v1/embeddings":{"post":{"tags":["Gateway"],"summary":"OpenAI-compatible Embeddings proxy with usage ledger recording","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Embedding vectors and token usage"}}}},"/v1beta/models/{model}:generateContent":{"post":{"tags":["Gateway"],"summary":"Native Google Gemini ingress & cross-protocol translation","security":[{"GoogleApiKey":[]},{"BearerAuth":[]}],"responses":{"200":{"description":"Gemini candidates and usageMetadata"}}}},"/v1/models":{"get":{"tags":["Gateway"],"summary":"Tenant-scoped model catalogue including combos and auto/* profiles","responses":{"200":{"description":"OpenAI model list"}}}},"/api/routing/profiles":{"get":{"tags":["Smart Routing"],"summary":"List opt-in auto/* routing profiles and objective weights","responses":{"200":{"description":"Routing profiles metadata"}}}},"/api/routing/simulate":{"post":{"tags":["Smart Routing"],"summary":"Dry-run smart routing & CPU complexity classification with zero upstream calls","responses":{"200":{"description":"Features, classifier probabilities, and ranked candidates"}}}},"/api/routing/health":{"get":{"tags":["Observability"],"summary":"Live per-model EWMA latency, TTFT, and health scores","responses":{"200":{"description":"Model telemetry list"}}}},"/api/routing/shadow":{"get":{"tags":["Smart Routing"],"summary":"Counterfactual shadow routing savings telemetry","responses":{"200":{"description":"Shadow comparison stats and recent samples"}}}},"/api/providers/health":{"get":{"tags":["Observability"],"summary":"3-state circuit breaker and cooldown state per provider connection","responses":{"200":{"description":"Connection health list"}}}},"/api/finops/forecast":{"get":{"tags":["FinOps"],"summary":"Monthly spend projection, burn rate, top cost drivers, and anomaly alerts","responses":{"200":{"description":"FinOps forecast JSON"}}}},"/api/finops/export":{"get":{"tags":["FinOps"],"summary":"RBAC-scoped chargeback export in RFC-4180 CSV or JSON","responses":{"200":{"description":"CSV attachment or JSON rows"}}}},"/api/pricing/status":{"get":{"tags":["FinOps"],"summary":"Pricing sync freshness and embedded offline baseline count","responses":{"200":{"description":"Pricing status JSON"}}}},"/api/onboarding/snippets":{"get":{"tags":["DX"],"summary":"Copy-ready coding-agent (Claude Code, Codex, OpenCode) & SDK configs","responses":{"200":{"description":"Tailored setup snippets"}}}},"/api/live":{"get":{"tags":["Operations"],"summary":"Kubernetes liveness probe","responses":{"200":{"description":"Process alive"}}}},"/api/ready":{"get":{"tags":["Operations"],"summary":"Kubernetes readiness probe verifying live database ping","responses":{"200":{"description":"Ready"},"503":{"description":"Database unreachable"}}}},"/metrics":{"get":{"tags":["Observability"],"summary":"Prometheus text exposition metrics","responses":{"200":{"description":"Prometheus metrics text"}}}},"/v1/rerank":{"post":{"tags":["Gateway"],"summary":"Cohere/Jina-compatible pure-Rust BM25 + cosine hybrid document reranker","responses":{"200":{"description":"Ranked document scores"}}}},"/v1/moderations":{"post":{"tags":["Gateway"],"summary":"OpenAI-compatible moderation combining injection firewall and PII/secret checks","responses":{"200":{"description":"Moderation category results"}}}},"/v1/batches":{"get":{"tags":["Gateway"],"summary":"List tenant-scoped batch jobs","responses":{"200":{"description":"Batch job list"}}},"post":{"tags":["Gateway"],"summary":"Create a tenant-scoped OpenAI-compatible batch job","responses":{"201":{"description":"Created batch job"}}}},"/api/qa/topics":{"get":{"tags":["AI Q&A"],"summary":"List grounded zrouter Q&A knowledge topics and suggested questions","responses":{"200":{"description":"Topics and starter questions"}}}},"/api/qa/ask":{"post":{"tags":["AI Q&A"],"summary":"Ask zrouter grounded documentation and live runtime telemetry Q&A","responses":{"200":{"description":"Grounded answer with citations"}}}},"/api/prompts":{"get":{"tags":["Governance"],"summary":"List tenant-scoped versioned prompt templates","responses":{"200":{"description":"Prompt templates"}}},"post":{"tags":["Governance"],"summary":"Create or increment version of a prompt template","responses":{"201":{"description":"Saved prompt template"}}}},"/api/routing/rules":{"get":{"tags":["Smart Routing"],"summary":"Get declarative per-project custom routing rules","responses":{"200":{"description":"Routing rules list"}}},"put":{"tags":["Smart Routing"],"summary":"Replace declarative per-project custom routing rules","responses":{"200":{"description":"Updated rules"}}}},"/api/routing/feedback":{"post":{"tags":["Smart Routing"],"summary":"Record thumbs-up/down model feedback into online Beta-Binomial bandit","responses":{"200":{"description":"Updated bandit posterior"}}}},"/api/routing/bandit":{"get":{"tags":["Smart Routing"],"summary":"Inspect online bandit quality posteriors per model","responses":{"200":{"description":"Bandit arms snapshot"}}}},"/api/cache/stats":{"get":{"tags":["Performance"],"summary":"Exact and pure-Rust semantic cache hit rates and estimated tokens saved","responses":{"200":{"description":"Cache telemetry JSON"}}}},"/api/cache/flush":{"post":{"tags":["Performance"],"summary":"Flush semantic cache entries for the authorized project","responses":{"200":{"description":"Flush confirmation"}}}},"/api/finops/roi":{"get":{"tags":["FinOps"],"summary":"4-pillar ROI attribution (BYOK zero-markup, smart routing, prompt & semantic cache)","responses":{"200":{"description":"ROI breakdown JSON"}}}},"/api/finops/chargeback/by-tag":{"get":{"tags":["FinOps"],"summary":"Aggregate spend by costCenter, customerId, or env tag (JSON/CSV)","responses":{"200":{"description":"Tag chargeback breakdown"}}}},"/api/billing/wallets":{"get":{"tags":["Monetization"],"summary":"List tenant-scoped prepaid virtual credit wallets","responses":{"200":{"description":"Wallet list"}}},"post":{"tags":["Monetization"],"summary":"Create or idempotently top up a prepaid virtual credit wallet","responses":{"201":{"description":"Updated wallet"}}}},"/api/billing/invoices/export":{"get":{"tags":["Monetization"],"summary":"Export monthly usage statement in HTML, CSV, or JSON","responses":{"200":{"description":"Monthly statement"}}}},"/api/billing/meter-events":{"get":{"tags":["Monetization"],"summary":"Export idempotent Stripe Billing Meter or Lago usage events","responses":{"200":{"description":"Meter event batch"}}}},"/api/admin/security/posture":{"get":{"tags":["Security"],"summary":"Live 0-100 security posture scorecard across 8 runtime controls","responses":{"200":{"description":"Security posture JSON"}}}},"/api/admin/security/test-guardrails":{"post":{"tags":["Security"],"summary":"Dry-run test sample text against secret/PII redactor and injection firewall","responses":{"200":{"description":"Dry-run guardrail report"}}}},"/api/audit-logs":{"get":{"tags":["Security"],"summary":"List hash-chained tamper-evident security audit logs","responses":{"200":{"description":"Audit log entries + chain verification"}}}},"/api/audit-logs/verify":{"get":{"tags":["Security"],"summary":"Cryptographically verify SHA-256 audit log chain integrity","responses":{"200":{"description":"Chain valid"},"409":{"description":"Chain tampered"}}}}}}