Skip to content

About

Official Python SDK for FreeTheAI, the free OpenAI-compatible AI API: chat, streaming, tool calls, web search, image and video tasks, with built-in retries, fallback models, and rate-limit handling.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

FreeTheAI Python SDK

PyPI Python versions Tests MIT license Discord

Documentation · Getting started · Models · freetheai.org

FreeTheAI Python SDK

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 freetheai

Quickstart

Create 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"])

Built for the FreeTheAI API

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 your fallback_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 StreamInterruptedError with the partial text, never a silently short answer.
  • The daily check-in and daily limit raise CheckinRequiredError and DailyLimitError at 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.

Documentation

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

More from FreeTheAI

License

MIT

About

Official Python SDK for FreeTheAI, the free OpenAI-compatible AI API: chat, streaming, tool calls, web search, image and video tasks, with built-in retries, fallback models, and rate-limit handling.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages