Docs · OpenAI SDK
One argument changes
FreeModel is an AI model gateway: one key for 477 models across dozens of providers, routed by task with free capacity tried first. If you already call the OpenAI API from code, you already know every line below. The only difference is where the client points.
Python
from openai import OpenAI
client = OpenAI(
base_url="https://freemodel.online/v1",
api_key="sk-your-key",
)
r = client.chat.completions.create(
model="auto/best-chat",
messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)
Node
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://freemodel.online/v1",
apiKey: "sk-your-key",
});
const r = await client.chat.completions.create({
model: "auto/best-chat",
messages: [{ role: "user", content: "Hello" }],
});
console.log(r.choices[0].message.content);
Note the spelling difference: the Python SDK takes base_url, the Node one
takes baseURL. Both stop at /v1.
What still works
Because the shape is unchanged, everything you normally use keeps working:
- Streaming.
stream: trueis passed through. - Tool calling. Every id in
/v1/modelssupports it. - Usage reporting.
usagecomes back on the response. - Error handling. Failures arrive in the OpenAI error shape, so your
existing
except/catchbranches still match.
What changes is which model answers. If you name one, you get it. If you name a route, the router picks per request and a provider failure moves the call on rather than raising.
Models worth using from code
| Route | When |
|---|---|
auto/best-coding | Code generation, patches, refactors |
auto/best-reasoning | Multi-step analysis before an answer |
auto/best-free | Batch jobs where cost beats latency |
auto/cheap | High-volume, low-stakes calls |
A route is not a guarantee about which model you get — it is a guarantee about what the router optimises for. See Routing for the order of decisions.