Unofficial OpenAI-compatible Python SDK for Pollinations.AI
Pollinations.AI brings open, multimodal generative AI for text, chat, image, audio, vision, TTS, and more — no API key required! This SDK lets you call Pollinations.AI with familiar OpenAI Python syntax, as a drop-in replacement for the openai package.
pip install .(PyPI package coming soon — stay tuned!)
from pollinations import Pollinations
client = Pollinations()
# Chat completion (OpenAI-compatible)
# Non-stream
resp = client.chat.completions.create(
prompt="Why you should donate to Pollinations AI",
seed= 42,
# "json": "true", # Optional: Get response as JSON string
# "system": "Explain things like I'm five.", # Optional
# "referrer": "MyPythonApp" # Optional for referrer-based authentication
)
print(resp)
# Image generation
img_url = client.images.generate(prompt="Cat in a spacesuit, digital art")
print("Image URL:", img_url)
# List available models
print(client.models.list())- OpenAI-compatible syntax (
chat,images,audio,models) - Streaming support
- Attribute access (
res.choices[0].message.content) - Lightweight: only
requestsdependency - Built-in retry, no default caching
- Fully typed, Python 3.10+
MIT — see LICENSE
Disclaimer: This is an unofficial, community-maintained SDK for the Pollinations API. It is not affiliated with or endorsed by Pollinations.ai.