Complete List of Providers Supported by gpt4free: 70+ AI Backends Explained

The gpt4free library supports more than 70 different providers spanning chat, vision, audio, video, search, and local execution, all unified behind a single async-generator interface.

The xtekky/gpt4free repository abstracts a vast ecosystem of AI backends through a dynamic provider architecture. Every provider supported by gpt4free inherits from BaseProvider or AsyncGeneratorProvider and implements a standardized interface, allowing developers to call any model with consistent syntax while the framework handles routing, retries, and fallback logic automatically.

How the gpt4free Provider Architecture Works

Provider Registration and Discovery

Providers are automatically discovered and registered via g4f/Provider/__init__.py. This module constructs __modules__, __providers__, and __map__ dictionaries that map provider names to their corresponding classes. To add a new provider supported by gpt4free, you simply create a class inheriting from BaseProvider, place it in the g4f/Provider/ directory, and expose it in __init__.py.

Model Mapping and Routing Logic

The AnyProvider router (implemented in g4f/providers/any_provider.py) consults the provider map to resolve model names to concrete backends. The AnyModelProviderMixin (lines 14-55) aggregates every model name across all providers, stores them in model_map, and builds alias tables. When AnyProvider.create_async_generator (lines 430-480) receives a request, it filters out non-working providers, applies a free-first sort (prioritizing providers without needs_auth), and hands the sorted list to RotatedProvider for automatic retry and streaming.

Chat and LLM Providers Supported by gpt4free

The majority of providers supported by gpt4free focus on text generation and conversational AI:

Vision and Image Generation Providers

Several providers supported by gpt4free handle multimodal inputs and image synthesis:

The CreateImagesProvider base class in g4f/providers/create_images.py provides the general image-generation helper interface that these providers extend.

Audio and Text-to-Speech Providers

For voice synthesis and audio processing, gpt4free includes specialized providers:

Search and Knowledge Retrieval Providers

To augment LLMs with real-time data, gpt4free supports several search providers:

Local and Self-Hosted Providers

For privacy-conscious deployments, gpt4free supports local execution:

  • Local (Local in g4f/Provider/local/Local.py) – Abstract base class for self-hosted providers.
  • Ollama – Concrete implementation running models locally via Ollama (extends Local).

These providers allow you to run models like Llama, Mistral, or other open-source weights entirely on your own hardware without external API calls.

Utility and Routing Providers

The framework includes meta-providers that manage other providers:

These utility providers ensure high availability by transparently handling provider failures and rate limits.

How to Use gpt4free Providers in Python

The unified interface allows you to interact with any provider using the same async patterns. Here are practical examples covering different provider categories:

import asyncio
import g4f

# 1. Simple chat completion with automatic routing (free-first)

async def chat_demo():
    response = await g4f.ChatCompletion.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Explain quantum entanglement"}],
        stream=False
    )
    print(response)

# 2. Image generation via Pollinations provider

async def image_demo():
    img_bytes = await g4f.Image.create(
        prompt="A cyberpunk city at sunset, ultra-realistic",
        model="sd-3.5-large",
        size="1024x1024"
    )
    with open("city.png", "wb") as f:
        f.write(img_bytes)

# 3. Text-to-speech using OpenAI voice models

async def tts_demo():
    audio = await g4f.Audio.create(
        text="Hello, I am your AI assistant.",
        voice="alloy"
    )
    with open("hello.mp3", "wb") as f:
        f.write(audio)

# 4. Direct provider usage (bypassing the router)

async def explicit_provider():
    # Use Copilot directly for code-focused tasks

    resp = await g4f.Copilot.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": "Write a Python function to compute Fibonacci numbers"}]
    )
    print(resp)

# Execute examples

asyncio.run(chat_demo())

All await calls invoke the provider's create_async_generator method, yielding either complete strings (when stream=False) or incremental chunks (when stream=True).

Summary

  • gpt4free supports 70+ providers across chat, vision, audio, video, search, and local execution categories.
  • Dynamic registration occurs via g4f/Provider/__init__.py, which builds __map__ for automatic discovery.
  • Free-first routing in AnyProvider prioritizes providers without authentication requirements when no API key is supplied.
  • Utility providers like RotatedProvider and RetryProvider ensure high availability through automatic failover.
  • Unified interface allows seamless switching between remote APIs (OpenAI, Gemini, Grok) and local models (Ollama) using identical async patterns.

Frequently Asked Questions

How many providers does gpt4free support?

The gpt4free framework currently ships with more than 70 concrete providers, with the exact count growing as the community adds new integrations. The dynamic registration system in g4f/Provider/__init__.py automatically discovers any new provider class placed in the directory.

Do I need an API key to use gpt4free providers?

No. The AnyProvider router implements a free-first strategy that prioritizes providers without needs_auth attributes when no API key is supplied. However, certain high-performance providers like OpenaiAccount, GeminiPro, and Azure require authentication and offer more reliable service tiers.

How do I add a custom provider to gpt4free?

Create a Python class inheriting from BaseProvider or AsyncGeneratorProvider, implement the create_async_generator method, and place the file in g4f/Provider/. Then expose the class in g4f/Provider/__init__.py. The provider will automatically appear in Provider.__map__ and become routable via AnyProvider.

Can I use gpt4free providers for local model hosting?

Yes. The Local provider base class in g4f/Provider/local/Local.py supports self-hosted models via Ollama. This allows you to run open-source weights like Llama or Mistral entirely on your own hardware without external API calls, using the same async interface as cloud providers.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →