Free AI chat & image generation β one clean HTTP API.
Powered by pollinations.ai β no account, no token, no sign-up needed upstream.
Features β’ Quick Start β’ API Reference β’ Deployment β’ License
| π¬ AI Chat | Conversational AI with full history support |
| π¨ Image Generation | Text-to-image via flux and more models |
| π Key Guard | x-api-key header + per-key rate limiting |
| β‘ Serverless | One-click deploy to Vercel β zero config |
| π Standalone Client | Use core/ directly, no Flask required |
# π¬ Chat
curl -X POST https://<your-project>.vercel.app/chat \
-H 'Content-Type: application/json' \
-H 'x-api-key: <redacted> \
-d '{"message": "Write a haiku about the ocean"}'
# π¨ Image
curl -X POST https://<your-project>.vercel.app/image \
-H 'Content-Type: application/json' \
-H 'x-api-key: <redacted> \
-d '{"prompt": "a cat astronaut", "width": 512, "height": 512}' \
-o cat.pngReplace
<your-project>with your Vercel deployment URL and ` with your API key.
All endpoints except / require the x-api-key header.
| Method | Path | Description |
|---|---|---|
GET |
/ |
Service info & endpoint list |
GET POST |
/chat |
Chat completion |
GET POST |
/image |
Image generation |
GET |
/models |
Available text models |
GET alternative
/chat?message=Hello!&model=openai
Pass history as a JSON-encoded query parameter for multi-turn chats.
Response
{
"response": "Hi there! How can I help?",
"model": "gpt-oss-20b",
"history": [ /* updated conversation */ ]
}{
"prompt": "a cat astronaut", // required
"width": 1024, // optional, 64β2048, default 1024
"height": 1024, // optional, 64β2048, default 1024
"model": "flux", // optional, default "flux"
"seed": 42, // optional, for reproducible results
"nologo": true, // optional, default true
"format": "url" // optional β return JSON instead of bytes
}Response (default): raw image bytes (image/jpeg).
Response (format: "url"):
{
"image_url": "https://image.pollinations.ai/prompt/...",
"content_type": "image/jpeg"
}More examples
# GET image
curl 'https://<your-project>.vercel.app/image?prompt=a%20sunset&width=512' \
-H 'x-api-key: <redacted> -o sunset.png
# Image as URL (no bytes proxied)
curl -X POST https://<your-project>.vercel.app/image \
-H 'Content-Type: application/json' \
-H 'x-api-key: <redacted> \
-d '{"prompt": "a cat astronaut", "format": "url"}'
# Available models
curl https://<your-project>.vercel.app/models \
-H 'x-api-key: <redacted>| Limit | Value |
|---|---|
| Per-key | 30 requests / 60 seconds |
| Upstream burst | HTTP 429 if pollinations throttles anonymous traffic |
git clone https://github.com/MR-RAHAD/pollinations-api.git
cd pollinations-api
vercel # link / create project
vercel --prod # deploy- Fork or push this repo to GitHub
- Vercel β Add New β Project β Import the repo
- Deploy β no build settings needed β¨
| Variable | Required | Default | Description |
|---|---|---|---|
API_KEY |
No | β | Your own guard key (added to the allowed list) |
POLL_RATE_LIMIT |
No | 30 |
Max requests per key per window |
POLL_RATE_WINDOW_SECONDS |
No | 60 |
Rate-limit window in seconds |
Set them in Vercel β Project β Settings β Environment Variables, then redeploy.
pollinations-api/
βββ api/
β βββ index.py # Flask app β routes, key guard, rate limiting
βββ core/
β βββ core/
β βββ __init__.py
β βββ pollinations.py # Upstream client β chat + image
βββ vercel.json # Serverless function config
βββ requirements.txt
βββ LICENSE
βββ README.md
The core/ client works without Flask:
from core.core.pollinations import PollinationsClient
client = PollinationsClient()
# Chat
print(client.ask("Tell me a joke")["response"])
# Image
img = client.image("a sunset over mountains", width=1024, height=1024)
open("sunset.jpg", "wb").write(img["content"])- Upstream (pollinations.ai) is free and anonymous β no account needed.
- Default text model:
openaiΒ· Default image model:flux. - If pollinations.ai changes its endpoints, update
core/core/pollinations.pyfrom the live site.
If you like this project and want more upgraded projects in the future:
- β Star this repository β your star keeps me motivated to build and share more
- π¬ Want a custom project built for you? Message me on Telegram: @rabbyhosainRahad
- π° Please note: custom project development is a paid service
This project is licensed under the MIT License.
Built with β€οΈ by Mohammad Rahad
{ "message": "Hello!", // required "model": "openai", // optional, default "openai" "history": [ // optional, for multi-turn conversations { "role": "user", "content": "Hi" }, { "role": "assistant", "content": "Hello!" } ] }