questions/API key

How do I get a Flux-2-Klein-9b API key?

You don't need a Black Forest Labs API key to call Flux-2-Klein-9b — AIgateway provides one unified sk-aig-... key that routes to every provider. Sign in at aigateway.sh, copy the key from the dashboard, and use it with any OpenAI-compatible SDK. Direct Black Forest Labs keys still work via BYOK for customers who prefer their own provider contract.

How it works

Use AIgateway's unified key instead

Instead of creating a Black Forest Labs account, copying a separate API key, and managing a billing relationship for each provider, use one sk-aig-... key on AIgateway. It routes to Black Forest Labs (and every other provider) on your behalf, with usage aggregated on a single invoice.

Where to get the key

Sign in at aigateway.sh/signin, open the dashboard, click "New key". Keys are sk-aig-... format, scoped by default to the account, and can be rotated or revoked instantly. Production teams typically mint per-environment keys (dev, staging, prod) or per-user sub-account keys via the /v1/accounts API.

If you need a direct ${m.provider} key (BYOK)

AIgateway supports bring-your-own-keys on Enterprise. You paste your Black Forest Labs key into the dashboard; AIgateway proxies requests using your contract's pricing but still handles routing, evals, replays, and audit logging. Useful when you have committed spend with a provider you want to burn down.

Code example

Python
# pip install aigateway-py openai
# aigateway-py: sub-accounts, evals, replays, jobs, webhook verify.
# openai SDK: chat/embeddings/images/audio — drop-in compat per our SDK's own guidance.
from openai import OpenAI

client = OpenAI(
    base_url="https://api.aigateway.sh/v1",
    api_key="sk-aig-...",
)

img = client.images.generate(
    model="black-forest-labs/flux-2-klein-9b",
    prompt="A studio photo of a red ceramic mug on white marble",
    size="1024x1024",
)
print(img.data[0].url)
Node / TypeScript
// npm i aigateway-js openai
// aigateway-js: sub-accounts, evals, replays, jobs, webhook verify.
// openai SDK: chat/embeddings/images/audio — drop-in compat.
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.aigateway.sh/v1",
  apiKey: process.env.AIGATEWAY_KEY,
});

const img = await client.images.generate({
  model: "black-forest-labs/flux-2-klein-9b",
  prompt: "A studio photo of a red ceramic mug on white marble",
  size: "1024x1024",
});
console.log(img.data[0].url);

Related

FAQ

Is the AIgateway key compatible with OpenAI's Python SDK?

Yes. Instantiate OpenAI(base_url="https://api.aigateway.sh/v1", api_key="sk-aig-..."). Zero client-side code changes beyond base_url.

Can I have multiple Flux-2-Klein-9b API keys?

Yes. Mint one per environment (dev/staging/prod) or one per end-user via the sub-account API. Each key is independently rotatable and revocable; usage is aggregated or split per your preference.

How do I rotate the key if it leaks?

Revoke the compromised key in the dashboard (it stops authenticating instantly) and issue a new one. Because keys are opaque strings, there's no re-signing or cert rotation overhead.

Does the AIgateway key work for Black Forest Labs's other models too?

Yes — the same key routes to every model Black Forest Labs publishes, plus 100+ models across other labs. Pricing is per-model (published in /v1/models); the key is universal.

TRY IT NOW

One key, every model. Free tier, no card.

Get an AIgateway keyOpen the playground