OpenAI-compatible AI gateway by Octoprograms

One API for every model path.

OctoFlux is an OpenAI-compatible gateway that routes requests across configured providers, models, and API keys, with health-aware failover built in.

POST /v1/chat/completions · GET /v1/models · GET /v1/aliases · POST /v1/responses

Your applicationOpenAI SDKOctoFlux/v1/chat/completionsGroqproviderOpenRouterproviderNVIDIA NIMprovidermodelsconfiguredmodelsconfiguredmodelsconfigured

The problem

AI providers are powerful. Their differences are expensive.

Every provider brings its own credentials, limits, model catalog, availability, and failure behavior. Without a routing layer, switching providers becomes application work.

  • Provider-specific integrations

    Each SDK, header scheme, and model ID leaks into application code.

  • Rate-limited or unavailable keys

    A single throttled key stalls requests that another key could have served.

  • Model changes and upstream failures

    Catalogs shift and endpoints fail; your code absorbs the churn.

OctoFlux does not resolve every provider incompatibility. It supports OpenAI-compatible providers and configurable authentication headers.

The solution

Keep the integration stable. Change the infrastructure behind it.

Point an OpenAI-compatible client at OctoFlux once. Configure providers, models, aliases, and keys centrally, then let the gateway resolve each request.

Before

Application → Provider A
Application → Provider B
Application → Provider C

After

Application → OctoFlux → Provider A
                       → Provider B
                       → Provider C
  • One application-facing API
  • Centralized provider configuration
  • Explicit routing behavior
  • Key rotation
  • Error-aware failover

How it works

Watch a request find its path.

Request lifecycle — illustrative

  1. Application requestPOST /v1/chat/completionschecking
  2. AuthenticateOctoFlux client key verifiedchecking
  3. Resolve modelexact id, alias, or autochecking
  4. Build candidatesprovider → model → key, ordered by prioritycandidate
  5. Apply health and local limitscooldowns, request and token windowschecking
  6. Candidate 1 — Groq key A429 rate limited → key placed in cooldownrate limited
  7. Candidate 2 — OpenRouter key Ahealthy, selected for this requestselected
  8. Upstream responsestreamed back to the applicationresponse returned

Retries and failover depend on the error category. A request does not always try every provider — candidates stop as soon as one returns successfully or the configured attempts are exhausted.

The pipeline, in order

  1. 01Application
  2. 02Authenticate
  3. 03Resolve model, alias, or auto
  4. 04Build provider → model → key candidates
  5. 05Apply health and local limits
  6. 06Send upstream request
  7. 07Return response or fail over

Streaming responses forward chunk by chunk over SSE. Failover happens only before the first streamed byte.

Quick start

Keep your existing OpenAI client.

Python — OpenAI SDK (python code sample)
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8000/v1",
    api_key="OctoFlux-dev-key",
)

response = client.chat.completions.create(
    model="auto",
    messages=[
        {"role": "user", "content": "Hello"}
    ],
)

print(response.choices[0].message.content)

  • base_url points the OpenAI client to OctoFlux.
  • The client sends the OctoFlux client key.
  • model: "auto" lets the router consider enabled models across enabled providers.
  • The application does not need to know which provider serves the request.
curl (bash code sample)
curl \
  -H "Authorization: Bearer $OctoFlux_CLIENT_KEY" \
  -H "Content-Type: application/json" \
  -X POST \
  http://localhost:8000/v1/chat/completions \
  -d '{
    "model": "auto",
    "messages": [
      {
        "role": "user",
        "content": "Hello"
      }
    ]
  }'

Model routing

Choose a model directly. Or define the path once.

Exact model (json code sample)
{
  "model": "openai/gpt-oss-120b"
}

Exact model requests only fail over to another provider offering the same model ID. OctoFlux does not silently substitute another model.

Provider ecosystem

Configured providers and example model IDs.

Groq

groq

  • openai/gpt-oss-120b
  • openai/gpt-oss-20b

OpenRouter

openrouter

  • z-ai/glm-5.2:free
  • minimax/minimax-m3:free
  • thinkingmachines/inkling:free
  • nvidia/nemotron-3-ultra-550b-a55b:free

NVIDIA NIM

nvidia_nim

  • nvidia/nemotron-3.5-lightning-30b-a3b
  • google/gemma-4-31b-it

These are example configured model IDs, not permanent availability guarantees. Provider model catalogs change. OctoFlux can compare configured model IDs against a provider's /models response; NVIDIA NIM may return bare model names, so OctoFlux handles the corresponding publisher-prefixed configuration IDs.

Capabilities

Routing and failover, made explicit.

Health-aware routing

Track provider and key health, cooldowns, and recent probe results before selecting a route.

API-key rotation

Rotate configured keys using round-robin, least-used, or priority-based selection.

Error-aware failover

Retry rate limits, timeouts, connection failures, and server errors according to their failure category.

Local limits

Apply request, token, concurrency, and time-window limits before calling upstream providers.

Model aliases

Create explicit fallback paths when you intentionally want different model IDs tried in sequence.

Streaming support

Forward streaming responses chunk by chunk and fail over only before the first response byte.

Configuration-driven providers

Add OpenAI-compatible providers through YAML configuration instead of provider-specific application code.

Operational visibility

Inspect health, usage, model availability, logs, and runtime configuration through the existing admin API and dashboard.

Health and operations

Know what is available before the request arrives.

  • Provider and key health are tracked separately.
  • Health probes call the provider's /models endpoint.
  • Manual key tests are available through the admin API.
  • The admin dashboard displays model availability from the latest model-list result.
  • A listed model may still fail at completion time because of rate limits, quota, permissions, or upstream routing.

Endpoints

  • GET /health
  • GET /admin/status
  • GET /admin/usage
  • GET /metrics
  • POST /admin/providers/{provider_id}/keys/{key_name}/test
  • POST /admin/reload

Deployment

Run it where your application runs.

  • Local Python
  • Docker
  • Docker Compose
  • PM2 on Linux
  • Single-process by default
  • Provider credentials belong in environment variables.
  • .env must not be committed.
  • Runtime health, usage, and rate-limit state are in memory by default.
  • A single worker is recommended unless shared runtime state is implemented separately.
Docker (bash code sample)
docker compose up -d --build

Architecture

Built around explicit infrastructure decisions.

  • OpenAI-compatible request surface
  • Configuration-driven provider model
  • Deterministic routing pipeline
  • Error classification before retry
  • Health and cooldown state
  • Pooled HTTP clients per provider
  • Structured JSON logs
  • No mandatory database, Redis, or Kafka
  • Docker-ready deployment
  • Mocked upstream tests with no required real provider calls

Help keep OctoFlux flowing.

OctoFlux is built in the open for developers who want a simpler way to work with AI providers. If it saves you time, consider supporting its continued development.