Objective
Extend the current Ask Sage-to-OpenAI compatibility service into a deployable multi-provider gateway architecture that can route OpenAI-compatible clients to Ask Sage, Groq, Google Gemini, Mistral, OpenRouter, and future providers while centrally accounting for utilization.
The preferred implementation is to evaluate and, if accepted, deploy LiteLLM as the public/client-facing gateway while retaining the existing Ask Sage proxy as an OpenAI-compatible backend adapter. Do not duplicate mature routing, virtual-key, budget, and accounting features inside the Ask Sage translation layer without a documented reason.
Current state
The repository currently translates OpenAI-compatible /v1/chat/completions, /v1/models, and selected audio endpoints to Ask Sage. It can pass through a best-effort upstream usage object when Ask Sage returns one, but it has no durable request ledger, per-client virtual keys, provider routing, budgets, quota awareness, Prometheus metrics, or consolidated cost dashboard.
Scope
- Document and implement the selected gateway topology:
- clients and coding CLIs -> multi-provider gateway;
- gateway -> Groq, Gemini, Mistral, OpenRouter;
- gateway -> existing Ask Sage proxy as a custom OpenAI-compatible backend;
- optional future local/Ollama-compatible backends.
- Preserve the existing Ask Sage protocol translation as a bounded adapter rather than mixing unrelated provider-specific request code into it.
- Add provider model aliases and explicit routing classes, including:
- free/preferred models;
- paid models;
- fallback chains;
- models prohibited from automatic paid fallback.
- Add gateway authentication using per-client or per-workload virtual keys. Never expose provider API keys to downstream clients.
- Add utilization accounting for all traffic that traverses the gateway:
- request count, status, latency, provider, model;
- input, output, reasoning, and cached tokens when reported;
- provider-reported or calculated cost when available;
- rate-limit headers and retry information where safe;
- attribution by virtual key, project, client, and correlation ID.
- Add budgets and limits:
- per-key/project RPM and TPM;
- daily/monthly spend caps;
- explicit free-only keys that cannot route to paid models;
- paid keys with bounded maximum spend;
- fail-closed behavior when cost classification is unknown.
- Export metrics for the existing monitoring stack and provide a minimal dashboard or documented query set.
- Support container deployment using Docker or Podman and retain compatibility with RHEL 9/OpenShift deployment patterns already represented in the repository.
- Keep all credential values in an approved external secret store or deployment secret mechanism. Commit only identifiers, schemas, examples with placeholders, and retrieval procedures.
Utilization boundary
The gateway can account accurately for requests that pass through it. It cannot infer traffic sent directly to provider APIs, and it may not know exact account-wide free-tier balance when a provider does not expose that information programmatically. Distinguish:
- gateway-observed utilization;
- provider-reported token/cost data;
- provider account/project dashboards or quota APIs;
- estimates based on model pricing;
- unknown or unavailable quota state.
Never represent estimated cost or remaining free allowance as authoritative.
Acceptance criteria
Security and cost risks
- This work handles credentials and can incur paid inference charges. Provider keys, gateway master keys, database credentials, and virtual-key values must never enter Git history, GitHub comments, CI logs, or artifacts.
- Free-tier availability and model classifications change. Free/paid policy must be configuration-driven and fail closed when stale or ambiguous.
- A public gateway without authentication could spend provider credits. No externally reachable deployment may start without authentication and bounded limits.
- Prompt and response logging must be disabled by default or separately approved because application content may be sensitive.
Coordination
Actor: web-agent/chatgpt/gpt-5.6-thinking
Session: 2026-08-08T16:46:48Z / multi-provider-gateway-web-01
Branch: none
State: planned
Cross-repository consumer: SupraCraft/minecraft-infra Colab orchestration will use a short-lived gateway virtual key and base URL by default; the corresponding issue will be cross-linked after creation.
Objective
Extend the current Ask Sage-to-OpenAI compatibility service into a deployable multi-provider gateway architecture that can route OpenAI-compatible clients to Ask Sage, Groq, Google Gemini, Mistral, OpenRouter, and future providers while centrally accounting for utilization.
The preferred implementation is to evaluate and, if accepted, deploy LiteLLM as the public/client-facing gateway while retaining the existing Ask Sage proxy as an OpenAI-compatible backend adapter. Do not duplicate mature routing, virtual-key, budget, and accounting features inside the Ask Sage translation layer without a documented reason.
Current state
The repository currently translates OpenAI-compatible
/v1/chat/completions,/v1/models, and selected audio endpoints to Ask Sage. It can pass through a best-effort upstreamusageobject when Ask Sage returns one, but it has no durable request ledger, per-client virtual keys, provider routing, budgets, quota awareness, Prometheus metrics, or consolidated cost dashboard.Scope
Utilization boundary
The gateway can account accurately for requests that pass through it. It cannot infer traffic sent directly to provider APIs, and it may not know exact account-wide free-tier balance when a provider does not expose that information programmatically. Distinguish:
Never represent estimated cost or remaining free allowance as authoritative.
Acceptance criteria
free-onlypolicy cannot fall through to a paid model or provider.Security and cost risks
Coordination
Actor:
web-agent/chatgpt/gpt-5.6-thinkingSession:
2026-08-08T16:46:48Z / multi-provider-gateway-web-01Branch:
noneState:
plannedCross-repository consumer:
SupraCraft/minecraft-infraColab orchestration will use a short-lived gateway virtual key and base URL by default; the corresponding issue will be cross-linked after creation.