Skip to main content

pollinations.ai | Free AI Image, Text, and Audio Generation

Project description

pollinations.ai - Free AI Image, Text, and Audio Generation

License Python Versions

pollinations.ai: (https://pollinations.ai/)

Work with the best generative AI from Pollinations using this Python SDK. 🐝

Installing

pip install pollinations
pip install pollinations.ai

# Linux/macOS
python3 -m pip install pollinations
python3 -m pip install pollinations.ai

# Windows
py -3 -m pip install pollinations
py -3 -m pip install pollinations.ai

Usage

Image Generation

View Code Example
import pollinations

"""
(method) def __init__(
    self: Self@Image,
    model: ImageModel | None = "flux",
    width: Width | None = 1024,
    height: Height | None = 1024,
    seed: Seed | None = "random",
    nologo: NoLogo | None = False,
    private: Private | None = False,
    enhance: Enhance | None = False,
    safe: Safe | None = False,
    referrer: Referrer | None = "pollinations.py",
    *any_kwargs_will_be_passed_in_request: Args,
    **kwargs: Kwargs,
) -> None
"""

model = pollinations.Image()

"""
(method) def __call__(
    self: Self@Image,
    prompt: Prompt,
    negative: Negative | None = "",
    *args: Args,
    file: Filename | None = "pollinations-image.jpeg",
    save: Save = False,
    *kwargs: Kwargs
) -> PILImage
"""

image = model("A dog and cat.")
image.save("my_image.jpeg")
# Alternatively:
# image = model.Generate("A dog and cat.", file="my_image.jpeg", save=True)
(Async) View Code Example
import pollinations

"""
(method) def __init__(
    self: Self@Image,
    model: ImageModel | None = "flux",
    width: Width | None = 1024,
    height: Height | None = 1024,
    seed: Seed | None = "random",
    nologo: NoLogo | None = False,
    private: Private | None = False,
    enhance: Enhance | None = False,
    safe: Safe | None = False,
    referrer: Referrer | None = "pollinations.py",
    *any_kwargs_will_be_passed_in_request: Args,
    **kwargs: Kwargs,
) -> None
"""

model = pollinations.Image()

"""
(method) async def Async(
    self: Self@Image,
    prompt: Prompt,
    negative: Negative | None = "",
    *args: Args,
    file: Filename | None = "pollinations-image.jpeg",
    save: Save = False,
    *kwargs: Kwargs
) -> PILImage
"""

image = await model.Async("A dog and cat.")
image.save("my_image.jpeg")
# Alternatively:
# image = await model.Async("A dog and cat.", file="my_image.jpeg", save=True)

Text Generation

View Code Example
import pollinations

"""
(method) def __init__(
    self: Self@Text,
    model: Model | None = "openai",
    system: System | None = "You are a helpful AI assistant.",
    contextual: Contextual | None = False,
    messages: Messages | None = [],
    private: Private | None = False,
    seed: Seed | None = "random",
    reasoning_effort: ReasoningEffort | None = "medium",
    tools: Tools | None = [],
    tool_choices: ToolChoice | None = [],
    voice: Voice | None = None,
    json_mode: JsonMode | None = False,
    referrer: Referrer | None = "pollinations.py",
    openai_endpoint: UseOpenAIEndpoint | None = False,
    *any_kwargs_will_be_passed_in_request: Args,
    **kwargs: Kwargs,
) -> None
"""

model = pollinations.Text()

"""
(method) def __call__(
    self: Self@Text,
    prompt: Prompt | None = None,
    *any_kwargs_will_be_passed_in_request: Args,
    stream: Stream | None = False,
    **kwargs: Kwargs
) -> Output
"""

print(model("Hello, what is 1 + 1?"))
# Alternatively:
# print(model.Generate("Hello, what is 1 + 1?"))


# Streaming
for token in model("Hello, what is 1 + 1?", stream=True):
    print(token, end="", flush=True)
    
# Alternatively:
# for token in model.Generate("Hello, what is 1 + 1?", stream=True):
#     print(token, end="", flush=True)
(Async) View Code Example
import pollinations

"""
(method) def __init__(
    self: Self@Text,
    model: Model | None = "openai",
    system: System | None = "You are a helpful AI assistant.",
    contextual: Contextual | None = False,
    messages: Messages | None = [],
    private: Private | None = False,
    seed: Seed | None = "random",
    reasoning_effort: ReasoningEffort | None = "medium",
    tools: Tools | None = [],
    tool_choices: ToolChoice | None = [],
    voice: Voice | None = None,
    json_mode: JsonMode | None = False,
    referrer: Referrer | None = "pollinations.py",
    openai_endpoint: UseOpenAIEndpoint | None = False,
    *any_kwargs_will_be_passed_in_request: Args,
    **kwargs: Kwargs,
) -> None
"""

model = pollinations.Text()

"""
(method) async def Async(
    self: Self@Text,
    prompt: Prompt | None = None,
    *any_kwargs_will_be_passed_in_request: Args,
    stream: Stream | None = False,
    **kwargs: Kwargs
) -> Output
"""

print(await model.Async("Hello, what is 1 + 1?"))

# Streaming
async for token in await model.Async("Hello, what is 1 + 1?", stream=True):
    print(token, end="", flush=True)

Audio Transcription

View Code Examples
import pollinations

"""
(method) def __init__(
    self: Self@Text,
    model: Model | None = "openai",
    system: System | None = "You are a helpful AI assistant.",
    contextual: Contextual | None = False,
    messages: Messages | None = [],
    private: Private | None = False,
    seed: Seed | None = "random",
    reasoning_effort: ReasoningEffort | None = "medium",
    tools: Tools | None = [],
    tool_choices: ToolChoice | None = [],
    voice: Voice | None = None,
    json_mode: JsonMode | None = False,
    referrer: Referrer | None = "pollinations.py",
    openai_endpoint: UseOpenAIEndpoint | None = False,
    *any_kwargs_will_be_passed_in_request: Args,
    **kwargs: Kwargs,
) -> None
"""

model = pollinations.Text()

"""
(method) def Transcribe(
    self: Self@Text,
    file: Filename,
    *any_kwargs_will_be_passed_in_request: Args,
    **kwargs: Kwargs
) -> Output
"""

print(model.Transcribe("my_audio.mp3"))
(Async) View Code Examples
import pollinations

"""
(method) def __init__(
    self: Self@Text,
    model: Model | None = "openai",
    system: System | None = "You are a helpful AI assistant.",
    contextual: Contextual | None = False,
    messages: Messages | None = [],
    private: Private | None = False,
    seed: Seed | None = "random",
    reasoning_effort: ReasoningEffort | None = "medium",
    tools: Tools | None = [],
    tool_choices: ToolChoice | None = [],
    voice: Voice | None = None,
    json_mode: JsonMode | None = False,
    referrer: Referrer | None = "pollinations.py",
    openai_endpoint: UseOpenAIEndpoint | None = False,
    *any_kwargs_will_be_passed_in_request: Args,
    **kwargs: Kwargs,
) -> None
"""

model = pollinations.Text()

"""
(method) def Transcribe(
    self: Self@Text,
    file: Filename,
    *any_kwargs_will_be_passed_in_request: Args,
    **kwargs: Kwargs
) -> Output
"""

print(await model.TranscribeAsync("my_audio.mp3"))

Audio Generation

Coming soon

Feed Reading

View Code Example
import pollinations

"""
(method) def __init__(
    self: Self@Feed,
    type: FeedType = "image",
    max_data: MaxData | None = None,
    *args: Args, 
    **kwargs: Kwargs
) -> None
"""

feed = pollinations.Feed()
# feed = pollinations.Feed("text", 10)  # Optionally specify type and amount

"""
(method) def __call__(
    self: Self@Feed,
    *args: Args, 
    **kwargs: Kwargs
) -> Iterator[Data]
"""

for item in feed():
    print(len(feed.data), item.data)

# Alternatively:
# for item in feed.Get():
#     print(len(feed.data), item.data)
(Async) View Code Example
import pollinations

"""
(method) def __init__(
    self: Self@Feed,
    type: FeedType = "image",
    max_data: MaxData | None = None,
    *args: Args, 
    **kwargs: Kwargs
) -> None
"""

feed = pollinations.Feed()
# feed = pollinations.Feed("text", 10)  # Optionally specify type and amount

"""
(method) async def Async(
    self: Self@Feed,
    *args: Args, 
    **kwargs: Kwargs
) -> AsyncIterator[Data]
"""

async for item in feed.Async():
    print(len(feed.data), item.data)

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pollinations-4.5.1.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pollinations-4.5.1-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

Details for the file pollinations-4.5.1.tar.gz.

File metadata

  • Download URL: pollinations-4.5.1.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pollinations-4.5.1.tar.gz
Algorithm Hash digest
SHA256 435158cde2922c93d054ff8f40ab8096b865f3e210aee7f135eba713a3ef4021
MD5 c0e632770bfb090ce0b02b77b098e0b6
BLAKE2b-256 43d66b6b5fae16edfa2b33198af3f1e8aa8abd3d3576a4d23016406d81968aaf

See more details on using hashes here.

File details

Details for the file pollinations-4.5.1-py3-none-any.whl.

File metadata

  • Download URL: pollinations-4.5.1-py3-none-any.whl
  • Upload date:
  • Size: 34.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pollinations-4.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d30ad9b0bb0e262093ec8b8ff9d9bd90736bdfdcb2222f5608943ee85b548c6f
MD5 e99e92bb169d24f748e82a3c5096a471
BLAKE2b-256 c56f88750859dfd25d506e9b7e15a4fe41642a1bc0b7071198fc9353120abefd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page