Skip to main content

Pollinations API

Project description

PollinationAI_SDK

Introduction

Generate text, images, video, and audio with a single API. OpenAI-compatible — use any OpenAI SDK by changing the base URL.

Base URL: https://gen.pollinations.ai

Get your API key: enter.pollinations.ai

Overview

Capability Endpoint Format
✍️ Text Generation POST /v1/chat/completions OpenAI-compatible
✍️ Simple Text GET /text/{prompt} Plain text
🖼️ Image Generation GET /image/{prompt} JPEG / PNG
🎬 Video Generation GET /video/{prompt} MP4
🔊 Text-to-Speech GET /audio/{text} MP3
🔊 Music Generation GET /audio/{text} MP3
🔊 Transcription POST /v1/audio/transcriptions JSON
🤖 Model Discovery GET /v1/models JSON

Quick Start

Generate an Image

Paste this URL in your browser — no code needed:

https://gen.pollinations.ai/image/a%20cat%20in%20space

Or use it directly in HTML:

<img src=\"https://gen.pollinations.ai/image/a%20cat%20in%20space\" />

Generate Text (OpenAI-compatible)

curl https://gen.pollinations.ai/v1/chat/completions \\
  -H \"Authorization: Bearer YOUR_API_KEY\" \\
  -H \"Content-Type: application/json\" \\
  -d '{\"model\": \"openai\", \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]}'

Generate Speech

curl \"https://gen.pollinations.ai/audio/Hello%20world?voice=nova\" \\
  -H \"Authorization: Bearer YOUR_API_KEY\" -o speech.mp3

🔐 Authentication

All generation requests require an API key from enter.pollinations.ai. Model listing endpoints work without authentication.

Two key types:

Type Prefix Use case Rate limits
Secret sk_ Server-side apps None
Publishable pk_ Client-side apps (beta) 1 pollen/IP/hour

How to authenticate:

# Option 1: Authorization header (recommended)
curl -H \"Authorization: Bearer YOUR_API_KEY\" ...

# Option 2: Query parameter
curl \"https://gen.pollinations.ai/text/hello?key=YOUR_API_KEY\"

Warning: Never expose secret keys (sk_) in client-side code. Use publishable keys (pk_) for frontend apps.

❌ Errors

All errors return JSON with a consistent format:

{
  \"status\": 400,
  \"success\": false,
  \"error\": {
    \"code\": \"BAD_REQUEST\",
    \"message\": \"Description of what went wrong\"
  }
}
Status Meaning
400 Invalid parameters or malformed request
401 Missing or invalid API key
402 Insufficient pollen balance
403 API key lacks required permission
500 Internal server error

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 0.3.0
  • Package version: 1.0.3
  • Generator version: 7.22.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

Requirements.

Python 3.10+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import PollinationAI_SDK

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import PollinationAI_SDK

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import PollinationAI_SDK
from PollinationAI_SDK.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://gen.pollinations.ai
# See configuration.py for a list of all supported configuration parameters.
configuration = PollinationAI_SDK.Configuration(
    host = "https://gen.pollinations.ai"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization (API Key): bearerAuth
configuration = PollinationAI_SDK.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)


# Enter a context with an instance of the API client
with PollinationAI_SDK.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = PollinationAI_SDK.AccountApi(api_client)
    id = 'id_example' # str | 

    try:
        # Revoke API Key
        api_instance.delete_account_keys_by_id(id)
    except ApiException as e:
        print("Exception when calling AccountApi->delete_account_keys_by_id: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://gen.pollinations.ai

Class Method HTTP request Description
AccountApi delete_account_keys_by_id DELETE /account/keys/{id} Revoke API Key
AccountApi get_account_balance GET /account/balance Get Balance
AccountApi get_account_key GET /account/key Get API Key Info
AccountApi get_account_keys GET /account/keys List API Keys
AccountApi get_account_profile GET /account/profile Get Profile
AccountApi get_account_usage GET /account/usage Get Usage History
AccountApi get_account_usage_daily GET /account/usage/daily Get Daily Usage
AccountApi post_account_keys POST /account/keys Create API Key
AudioGenerationApi get_generate_audio_by_text GET /audio/{text} Generate Audio
AudioGenerationApi post_generate_v1_audio_speech POST /v1/audio/speech Text to Speech (OpenAI-compatible)
AudioGenerationApi post_generate_v1_audio_transcriptions POST /v1/audio/transcriptions Transcribe Audio
ImageGenerationApi get_generate_image_by_prompt GET /image/{prompt} Generate Image
ImageGenerationApi post_generate_v1_images_edits POST /v1/images/edits Edit Image (OpenAI-compatible)
ImageGenerationApi post_generate_v1_images_generations POST /v1/images/generations Generate Image (OpenAI-compatible)
MediaStorageApi delete_by_hash DELETE /{hash} Delete media
MediaStorageApi get_by_hash GET /{hash} Retrieve media
MediaStorageApi head_by_hash HEAD /{hash} Check if media exists
MediaStorageApi post_upload POST /upload Upload media
ModelsApi get_generate_audio_models GET /audio/models List Audio Models
ModelsApi get_generate_image_models GET /image/models List Image & Video Models
ModelsApi get_generate_text_models GET /text/models List Text Models (Detailed)
ModelsApi get_generate_v1_models GET /v1/models List Models (OpenAI-compatible)
TextGenerationApi get_generate_text_by_prompt GET /text/{prompt} Simple Text Generation
TextGenerationApi post_generate_v1_chat_completions POST /v1/chat/completions Chat Completions
VideoGenerationApi get_generate_video_by_prompt GET /video/{prompt} Generate Video

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

bearerAuth

  • Type: Bearer authentication (API Key)

Author

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

pollinationai_sdk-1.0.3.tar.gz (155.5 kB view details)

Uploaded Source

Built Distribution

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

pollinationai_sdk-1.0.3-py3-none-any.whl (460.2 kB view details)

Uploaded Python 3

File details

Details for the file pollinationai_sdk-1.0.3.tar.gz.

File metadata

  • Download URL: pollinationai_sdk-1.0.3.tar.gz
  • Upload date:
  • Size: 155.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pollinationai_sdk-1.0.3.tar.gz
Algorithm Hash digest
SHA256 b92adc78bcaae54dbb711fce829a96b53fcffda3a7954177c93c81a3ad22216d
MD5 e3bc78f95ee99f506b734e35273f3b1f
BLAKE2b-256 4ad8403bddce85172056b34a24cab94f3cb4053d11cca00b02d7189e115d4b8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pollinationai_sdk-1.0.3.tar.gz:

Publisher: buildAndPublish.yml on yehigo/Pollinations.ai_sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pollinationai_sdk-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pollinationai_sdk-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d19382fe808140a0e6c3faf0820aa65cc4eec359f59c5e28cc4be135950f38ad
MD5 2f27aede73c27da18d0a3cfbbdf281a3
BLAKE2b-256 890c835a64642a33c8a3aabed24208d3a28f55f28f9f0497ccaa8655beb53f01

See more details on using hashes here.

Provenance

The following attestation bundles were made for pollinationai_sdk-1.0.3-py3-none-any.whl:

Publisher: buildAndPublish.yml on yehigo/Pollinations.ai_sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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