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:
- OpenAI Chat (
OpenaiChating4f/Provider/needs_auth/OpenaiChat.py) – Accesses ChatGPT free tier without an API key. - OpenAI Account (
OpenaiAccounting4f/Provider/needs_auth/OpenaiAccount.py) – Paid OpenAI models requiring authentication. - OpenAI API (
OpenaiAPIing4f/Provider/needs_auth/OpenaiAPI.py) – Low-level completions endpoint. - Gemini (
Gemini/GeminiProing4f/Provider/needs_auth/Gemini.py) – Google’s Gemini model family. - Grok (
Groking4f/Provider/needs_auth/Grok.py) – xAI’s Grok series. - Perplexity (
Perplexitying4f/Provider/Perplexity.py) – Perplexity Labs LLMs. - Copilot (
Copilot/CopilotAccounting4f/Provider/Copilot.py) – GitHub Copilot code-focused models. - PollinationsAI (
PollinationsAIing4f/Provider/needs_auth/PollinationsAI.py) – General-purpose model aggregator. - Azure (
Azureing4f/Provider/needs_auth/Azure.py) – Azure OpenAI Service. - Qwen (
Qwening4f/Provider/Qwen.py) – Alibaba’s Qwen series. - DeepInfra (
DeepInfraing4f/Provider/DeepInfra.py) – DeepInfra hosted models. - Hugging Face (
HuggingFace,HuggingFaceMedia,HuggingFaceInferenceing4f/Provider/needs_auth/hf/__init__.py) – Hugging Face inference APIs. - Cloudflare (
Cloudflareing4f/Provider/Cloudflare.py) – Cloudflare Workers AI. - LMArena (
LMArenaing4f/Provider/needs_auth/LMArena.py) – LM-Arena multi-model playground.
Vision and Image Generation Providers
Several providers supported by gpt4free handle multimodal inputs and image synthesis:
- PollinationsImage (
PollinationsImageing4f/Provider/PollinationsImage.py) – Image generation via Pollinations. - BingCreateImages (
BingCreateImagesing4f/Provider/needs_auth/BingCreateImages.py) – Bing Image Creator integration. - StabilityAI_SD35Large (
StabilityAI_SD35Largeing4f/Provider/hf_space/StabilityAI_SD35Large.py) – Stability AI SD-3.5-large model. - DeepseekAI_JanusPro7b (
DeepseekAI_JanusPro7bing4f/Provider/hf_space/DeepseekAI_JanusPro7b.py) – DeepSeek image-capable model.
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:
- OpenAIFM (
OpenAIFMing4f/Provider/audio/OpenAIFM.py) – OpenAI’s voice models for text-to-speech. - gTTS (
gTTSing4f/Provider/audio/gTTS.py) – Google Text-to-Speech wrapper. - EdgeTTS (
EdgeTTSing4f/Provider/audio/EdgeTTS.py) – Microsoft Edge TTS integration. - MarkItDown (
MarkItDowning4f/Provider/audio/MarkItDown.py) – Markdown-to-audio conversion utility.
Search and Knowledge Retrieval Providers
To augment LLMs with real-time data, gpt4free supports several search providers:
- GoogleSearch (
GoogleSearching4f/Provider/search/GoogleSearch.py) – Google search via custom API. - SearXNG (
SearXNGing4f/Provider/search/SearXNG.py) – SearXNG public instance search. - DDGS (
DDGSing4f/Provider/search/DDGS.py) – DuckDuckGo Search API. - YouTube (
YouTubeing4f/Provider/search/YouTube.py) – YouTube video metadata retrieval. - CachedSearch (
CachedSearching4f/Provider/search/CachedSearch.py) – Cached wrapper around any search provider to reduce API calls.
Local and Self-Hosted Providers
For privacy-conscious deployments, gpt4free supports local execution:
- Local (
Localing4f/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:
- AnyProvider (
AnyProvidering4f/providers/any_provider.py) – The main router that implements free-first selection across all registered providers. - RetryProvider (
RetryProvidering4f/providers/retry_provider.py) – Automatically retries failed requests with exponential backoff. - RotatedProvider (
RotatedProvidering4f/providers/retry_provider.py) – Rotates through multiple providers until one succeeds. - IterListProvider (
IterListProvidering4f/providers/retry_provider.py) – Iterates through a list of providers sequentially.
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
AnyProviderprioritizes providers without authentication requirements when no API key is supplied. - Utility providers like
RotatedProviderandRetryProviderensure 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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →