Documentation · Getting started · Models · freetheai.org
The official Python client for FreeTheAI, a free OpenAI-compatible AI API. One key gives you dozens of chat models, streaming, tool calls, web search with sourced answers, and image and video tasks.
pip install freetheaiCreate a key at freetheai.org, do the daily check-in for free models, and set FREETHEAI_API_KEY.
from freetheai import FreeTheAI
client = FreeTheAI()
reply = client.chat.completions.create(
model="fta/zai/glm-5.3",
messages=[{"role": "user", "content": "Write a haiku about open models."}],
)
print(reply["choices"][0]["message"]["content"])Stream it:
for text in client.chat.completions.stream_text(model="fta/kimi/k3", messages=messages):
print(text, end="", flush=True)Search the web:
answer = client.answer("What changed in Python 3.14?")
print(answer["answer"], answer["sources"])Generic OpenAI clients treat every error the same. This one knows how the FreeTheAI API answers:
- Busy models wait for the server's
Retry-After, or move straight to yourfallback_models. - Concurrency limits are learned on the first refusal; extra calls queue instead of failing.
- Long replies are fetched as a stream and assembled, so they don't hit idle timeouts.
- Cut-off streams raise
StreamInterruptedErrorwith the partial text, never a silently short answer. - The daily check-in and daily limit raise
CheckinRequiredErrorandDailyLimitErrorat once, with the link or reset time. - Mistyped model IDs come back with suggestions; a missing
fta/prefix is fixed for you.
client = FreeTheAI(fallback_models=["fta/zai/glm-5.3-flash", "fta/mmx/minimax-m3"])Read Reliability for the full list.
| Guide | |
|---|---|
| Getting started | Key, check-in, first request |
| Chat and streaming | Parameters, streaming, reasoning, images |
| Tool calls | Function calling step by step |
| Web search | Results and sourced answers |
| Images and video | Media tasks |
| Async | AsyncFreeTheAI |
| Errors | Every error class and what to do |
| Configuration | All client options |
- JavaScript / TypeScript SDK (docs) and Go SDK (docs)
- Free stock widgets for live price cards and charts
- Cookbook (docs): runnable examples
- Setup guides for SillyTavern, JanitorAI, Claude Code, Cline, and more
- API status and Discord
MIT
