Skip to content
gpt4freePublic

About

g4f.dev – free and convenient AI endpoints you can use directly in your apps, scripts, and even right in your browser. chatgpt, deepseek, grok or gemini https://discord.gg/qXA4Wf4Fsm

Resources

Stars

191 stars

Watchers

2 watching

Forks

Latest commit

 

History

1,559 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

g4f.dev Documentation

1000066426

Welcome to the official g4f.dev docs for GPT4Free – free and convenient AI endpoints you can use directly in your apps, scripts, and even right in your browser. Here you’ll find a clear overview, quick examples, and entry points to deeper docs for every major feature.


Installation & Setup

For full install guides—choose your method:

Downloads

  • Desktop (Windows, macOS, Linux): Download the g4f-go launcher. It is a small self-contained binary that installs CPython and g4f on first run, so no system Python is required.
  • Android: Download the G4F Android APK for the native app, or use the g4f-go Termux build on ARM64 devices.
  • All builds: Browse every published asset on the GitHub releases page.

The homepage detects your operating system and links to the matching build automatically.

For rapid starts, you can use either Python or JavaScript (web).


Getting Started

📝 Text Generation

Python example for chat completion (with and without web search):

from g4f.client import Client

client = Client()
response = client.chat.completions.create(
    model="gpt-4.1",  # Try "gpt-4o", "deepseek-v3", etc.
    messages=[{"role": "user", "content": "Hello"}],
    web_search=False
)
print(response.choices[0].message.content)

Output:

Hello! How can I assist you today?

🎨 Image Generation

Generate images with a single call (returns URLs or base64):

from g4f.client import Client

client = Client()
response = client.images.generate(
    model="flux",  # Other models: 'dalle-3', 'gpt-image', etc.
    prompt="a white siamese cat",
    response_format="url"
)
print(f"Generated image URL: {response.data[0].url}")

More Python client info →

and Async client →


🧙‍♂️ Using GPT4Free.js

Use the official JS client right in the browser—no backend needed.

For text generation:

<script type="module">
    import Client from 'https://g4f.dev/dist/js/client.js';

    const client = new Client();
    const result = await client.chat.completions.create({
        model: 'gpt-4.1',  // Or "gpt-4o", "deepseek-v3"
        messages: [{ role: 'user', content: 'Explain quantum computing' }]
    });
    console.log(result.choices[0].message.content);
</script>

And for image generation:

<script type="module">
    import Client from 'https://g4f.dev/dist/js/client.js';

    const client = new Client();
    const response = await client.images.generate({
        model: "flux", // Or "dalle-3", "gpt-image"
        prompt: "a white siamese cat"
    });
    const imageUrl = response.data[0].url;
    console.log(`Generated Image URL: ${imageUrl}`);
    // Example: document.body.innerHTML += `<img src="${imageUrl}" />`;
</script>

See more JS client usage →

💻 Using CLI Client

Examples

  1. Text generation:

    g4f client "Explain quantum computing in simple terms"
  2. Image description:

    g4f client image.jpg "Describe this image"
  3. Image generation (with supported models):

    g4f client -m flux -O output.jpg "A futuristic cityscape"

CLI Client documentation →


Deep Dives


Community & Links

  • Open Source: GitHub: gpt4free/g4f.dev

  • Contribute & Report Bugs: PRs & issues are welcome!

  • Project Website: https://g4f.dev/

  • Legal: The homepage and documentation may display ads served by Google AdSense. Conversations are stored locally on your device by default, with optional end-to-end encrypted cloud sync available for members. Usage logs and parts of prompts may be stored for up to 14 days to detect abuse and multiple accounts; account data of optional member accounts is kept for at least 90 days. See the Privacy Policy and Terms of Service.

  • Pollinations AI:

    GitHub: pollinations/pollinations


GPT4Free and g4f.dev are continuously improving. Have fun building, and let the bots do the heavy lifting for you!

← Back to g4f.dev

About

g4f.dev – free and convenient AI endpoints you can use directly in your apps, scripts, and even right in your browser. chatgpt, deepseek, grok or gemini https://discord.gg/qXA4Wf4Fsm

Resources

Stars

191 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages