Skip to main content
Install the official SDK.
pip install openai
Set base_url to the FreeModel OpenAI-compatible endpoint.
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxx",
    base_url="https://api.freemodel.app/v1",
)

response = client.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[
        {"role": "user", "content": "Give me one API reliability tip."}
    ],
)

print(response.choices[0].message.content)
To stream, pass stream=True and iterate over the returned events.
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxx",
    base_url="https://api.freemodel.app/v1",
)

stream = client.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[{"role": "user", "content": "Say hello in three words."}],
    stream=True,
)

for event in stream:
    content = event.choices[0].delta.content
    if content:
        print(content, end="")
See Chat completions for request options.