Migrate from OpenAI

Move from the OpenAI API to FluxRouter by changing the base URL, key, and model. Nothing else changes.

FluxRouter speaks the OpenAI API. If your code already calls OpenAI, you keep the same SDK and the same request shape. You change three things:

  1. Base URL to https://api.fluxrouter.ai/v1
  2. API key to your Flux key (sk-... from the dashboard)
  3. Model to flux-auto (or a specific flux-* id)

That's the whole migration. The endpoints (/chat/completions, /responses, /models), the request and response JSON, streaming, tools, and structured outputs all stay the same.

Get a Flux key

Sign up at /auth/sign-up, open the dashboard, and create an API key. It looks like sk-.... The examples below read it from a FLUX_API_KEY environment variable.

Migrate the Python SDK

Before (OpenAI)

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-openai-...",
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Say hello."}],
)

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

After (FluxRouter)

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-...",                          # your Flux key
    base_url="https://api.fluxrouter.ai/v1",   # the one line you change
)

response = client.chat.completions.create(
    model="flux-auto",                         # let Flux route, or pin a flux-* id
    messages=[{"role": "user", "content": "Say hello."}],
)

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

Migrate the Node SDK

Before (OpenAI)

ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Say hello." }],
});

console.log(response.choices[0].message.content);

After (FluxRouter)

ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.FLUX_API_KEY,            // your Flux key
  baseURL: "https://api.fluxrouter.ai/v1",     // the one line you change
});

const response = await client.chat.completions.create({
  model: "flux-auto",                          // let Flux route, or pin a flux-* id
  messages: [{ role: "user", content: "Say hello." }],
});

console.log(response.choices[0].message.content);

What stays the same

Everything except the three values above:

  • The OpenAI SDK and its method names (chat.completions.create, responses.create).
  • The endpoints: /v1/chat/completions, /v1/responses, /v1/models.
  • Auth header style: Authorization: Bearer sk-....
  • The request and response JSON, including streaming (stream: true), tool calls, and structured outputs.
  • Your prompts, message arrays, and parameters like temperature and max_tokens.

What to do about the model field

OpenAI model ids like gpt-4o are not Flux models. Pick one of these instead:

  • flux-auto (recommended): Flux routes each request to a sensible model for the prompt. Use this and you don't have to choose.
  • A tier alias (flux-fast, flux-standard, flux-reasoning, flux-image) or a flux-pinned-* id when you want the same backing model every time.

The authoritative list of model ids is GET https://api.fluxrouter.ai/v1/models. See Models for what each alias means.

Next steps

  • Models: every model alias and how flux-auto and pinning work.
  • Connect your tools: point an AI coding tool at Flux instead of code.