Skip to content
h4ks-comPublic

About

REST API for gpt4free

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

g4f-api

Alternative API for getting text completions from the g4f project

Live at

Run

docker compose up --build

Or locally, reading settings from .env (see .env.example):

uv run python3 -m backend.run

Then make requests:

curl -X POST http://localhost:8000/api/completions \
  -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "Hello!"}]}'

Without model or provider query params the API picks one and falls back through others until it gets an answer. GET /api/providers and GET /api/models list what is currently available, and GET /api/provider-failures shows why the rest were dropped.

Providers

Providers are discovered automatically at startup: every g4f provider that is marked working, needs no credentials, and never drives a headless browser. A background task probes them on boot and hourly, keeping only the ones that answer.

Probe them by hand with:

uv run python3 test_providers.py

Tests

uv run python -m pytest -n 10 tests/

About

REST API for gpt4free

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages