Use the official GPT4Free.js client right in the browser—no backend needed
npm install @gpt4free/g4f.dev
---
For full install guides—choose your method:
- Git Install
- Docker
- Requirements
For rapid starts, you can use either Python or JavaScript (web).
---
Python example for chat completion (with and without web search):
``python
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?
---
Generate images with a single call (returns URLs or base64):
`python
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}")
`
---
Use the official JS client right in the browser—no backend needed.
For text generation:
`html`
And for image generation:
`html`
Examples
1. Text generation:
`bash`
g4f client "Explain quantum computing in simple terms"
2. Image description:
`bash`
g4f client image.jpg "Describe this image"
3. Image generation (with supported models):
`bash``
g4f client -m flux -O output.jpg "A futuristic cityscape"
---
- API endpoints and usage *new
- Available Providers & Models
- Selecting a Provider
- Provider Documentation
- API docs (full spec)
- File API Documentation (Files and Documents)
- Media Documentation (Audio, Image and Video)
- Vision Support (Image Upload)
- Image Editing & Variation
- Authentication, Configuration Guide (.har and cookies)
- Advanced: Create your own Provider
- Integrations: LangChain, PydanticAI
- GUI/WebUI, Phone, Backend API
- Troubleshooting
---
- Open Source: GitHub: gpt4free/g4f.dev
- Contribute & Report Bugs: PRs & issues are welcome!
- Project Website: https://g4f.dev/
- 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!