One-line switch: OpenAI SDK → Modelflare

Create a key, then set base_url. One key for text, image, and video — with group failover and per-request cost tracking.

Three steps

  1. Create an API key in the console, in a non-default group that lists the model you want to call.
  2. Point your OpenAI client at https://modelflare.dev/v1.
  3. Use an exact model ID enabled on your group (the Quickstart uses gpt-5.6-sol).
Model ids must be enabled on the key’s group — otherwise the request fails even when the JSON is valid (a 403 means the key cannot use that model or group). Live prices and availability live in the console.

Environment variable (recommended)

export MODELFLARE_API_KEY="YOUR_MODELFLARE_API_KEY"
# base_url is always https://modelflare.dev/v1

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["MODELFLARE_API_KEY"],
    base_url="https://modelflare.dev/v1",
)

r = client.chat.completions.create(
    model="gpt-5.6-sol",
    messages=[{"role": "user", "content": "Hello from Hugging Face"}],
)
print(r.choices[0].message.content)

Streaming (Python)

stream = client.chat.completions.create(
    model="gpt-5.6-sol",
    messages=[{"role": "user", "content": "Say hi in one line"}],
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta.content or ""
    print(delta, end="", flush=True)

Node.js / TypeScript

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.MODELFLARE_API_KEY,
  baseURL: "https://modelflare.dev/v1",
});

const r = await client.chat.completions.create({
  model: "gpt-5.6-sol",
  messages: [{ role: "user", content: "Hello from Hugging Face" }],
});
console.log(r.choices[0].message.content);

curl

curl https://modelflare.dev/v1/chat/completions \
  -H "Authorization: Bearer $MODELFLARE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.6-sol","messages":[{"role":"user","content":"ping"}]}'

Troubleshooting

HF visitors: sign up on the console for pricing, keys, and usage. Interactive Chat Spaces need HF PRO; use the console + API for now. More recipes: api-recipes.