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
- CacheControl
- CompletionUsage
- CompletionUsageCompletionTokensDetails
- CompletionUsagePromptTokensDetails
- ContentFilterResult
- ContentFilterResultHate
- ContentFilterResultJailbreak
- ContentFilterSeverity
- CreateImageRequest
- CreateImageRequestImage
- CreateImageResponse
- CreateImageResponseDataInner
- CreateSpeechRequest
- DeleteByHash200Response
- DeleteByHash400Response
- ErrorDetails
- GetAccountBalance200Response
- GetAccountKey200Response
- GetAccountKey200ResponsePermissions
- GetAccountProfile200Response
- GetAccountUsage200Response
- GetAccountUsage200ResponseUsageInner
- GetAccountUsageDaily200Response
- GetAccountUsageDaily200ResponseUsageInner
- GetGenerateImageModels500Response
- GetGenerateImageModels500ResponseError
- GetGenerateImageModels500ResponseErrorMessage
- GetGenerateTextByPrompt400Response
- GetGenerateTextByPrompt400ResponseError
- GetGenerateTextByPrompt400ResponseErrorMessage
- GetGenerateTextByPrompt401Response
- GetGenerateTextByPrompt401ResponseError
- GetGenerateTextByPrompt401ResponseErrorMessage
- GetGenerateTextByPrompt402Response
- GetGenerateTextByPrompt402ResponseError
- GetGenerateTextByPrompt402ResponseErrorMessage
- GetGenerateTextByPrompt403Response
- GetGenerateTextByPrompt403ResponseError
- GetGenerateTextByPrompt403ResponseErrorMessage
- GetGenerateTextByPrompt429Response
- GetGenerateTextByPrompt429ResponseError
- GetGenerateTextByPrompt429ResponseErrorMessage
- GetGenerateV1Models200Response
- GetGenerateV1Models200ResponseDataInner
- GetGenerateV1Models500Response
- GetGenerateV1Models500ResponseError
- GetGenerateV1Models500ResponseErrorMessage
- MessageContentPart
- MessageContentPartAnyOf
- MessageContentPartAnyOf1
- MessageContentPartAnyOf1InputAudio
- MessageContentPartAnyOf2
- MessageContentPartAnyOf2File
- MessageContentPartAnyOfVideoUrl
- PostAccountKeysRequest
- PostGenerateV1AudioTranscriptions200Response
- PostGenerateV1ChatCompletions200Response
- PostGenerateV1ChatCompletions200ResponseChoicesInner
- PostGenerateV1ChatCompletions200ResponseChoicesInnerLogprobs
- PostGenerateV1ChatCompletions200ResponseChoicesInnerLogprobsContentInner
- PostGenerateV1ChatCompletions200ResponseChoicesInnerLogprobsContentInnerTopLogprobsInner
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessage
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessageAudio
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessageContentBlocksInner
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessageContentBlocksInnerAnyOf
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessageContentBlocksInnerAnyOf1
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessageContentBlocksInnerAnyOf1ImageUrl
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessageContentBlocksInnerAnyOf2
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessageContentBlocksInnerAnyOf3
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessageContentBlocksInnerAnyOf4
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessageToolCallsInner
- PostGenerateV1ChatCompletions200ResponseChoicesInnerMessageToolCallsInnerFunction
- PostGenerateV1ChatCompletions200ResponsePromptFilterResultsInner
- PostGenerateV1ChatCompletions400Response
- PostGenerateV1ChatCompletions400ResponseError
- PostGenerateV1ChatCompletions400ResponseErrorMessage
- PostGenerateV1ChatCompletions401Response
- PostGenerateV1ChatCompletions401ResponseError
- PostGenerateV1ChatCompletions401ResponseErrorMessage
- PostGenerateV1ChatCompletions402Response
- PostGenerateV1ChatCompletions402ResponseError
- PostGenerateV1ChatCompletions402ResponseErrorMessage
- PostGenerateV1ChatCompletions403Response
- PostGenerateV1ChatCompletions403ResponseError
- PostGenerateV1ChatCompletions403ResponseErrorMessage
- PostGenerateV1ChatCompletions429Response
- PostGenerateV1ChatCompletions429ResponseError
- PostGenerateV1ChatCompletions429ResponseErrorMessage
- PostGenerateV1ChatCompletionsRequest
- PostGenerateV1ChatCompletionsRequestAudio
- PostGenerateV1ChatCompletionsRequestFunctionCall
- PostGenerateV1ChatCompletionsRequestFunctionCallAnyOf
- PostGenerateV1ChatCompletionsRequestFunctionsInner
- PostGenerateV1ChatCompletionsRequestMessagesInner
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOf
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOf1
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOf1Content
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOf2
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOf3
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOf3FunctionCall
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOf3ToolCallsInner
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOf3ToolCallsInnerFunction
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOf4
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOf5
- PostGenerateV1ChatCompletionsRequestMessagesInnerAnyOfContent
- PostGenerateV1ChatCompletionsRequestResponseFormat
- PostGenerateV1ChatCompletionsRequestResponseFormatAnyOf
- PostGenerateV1ChatCompletionsRequestResponseFormatAnyOf1
- PostGenerateV1ChatCompletionsRequestResponseFormatAnyOf1JsonSchema
- PostGenerateV1ChatCompletionsRequestResponseFormatAnyOf2
- PostGenerateV1ChatCompletionsRequestStop
- PostGenerateV1ChatCompletionsRequestStreamOptions
- PostGenerateV1ChatCompletionsRequestThinking
- PostGenerateV1ChatCompletionsRequestToolChoice
- PostGenerateV1ChatCompletionsRequestToolChoiceAnyOf
- PostGenerateV1ChatCompletionsRequestToolChoiceAnyOfFunction
- PostGenerateV1ChatCompletionsRequestToolsInner
- PostGenerateV1ChatCompletionsRequestToolsInnerAnyOf
- PostGenerateV1ChatCompletionsRequestToolsInnerAnyOf1
- PostGenerateV1ChatCompletionsRequestToolsInnerAnyOfFunction
- PostUpload200Response
- PostUpload401Response
- ValidationErrorDetails
Documentation For Authorization
Authentication schemes defined for the API:
bearerAuth
- Type: Bearer authentication (API Key)
Author
Metadata
Release files for PollinationAI-SDK 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pollinationai_sdk-1.0.3.tar.gz | 155.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pollinationai_sdk-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 615.7 kB
Release files / pollinationai_sdk-1.0.3.tar.gz
| Download URL | pollinationai_sdk-1.0.3.tar.gz |
|---|---|
| Size | 155.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b92adc78bcaae54dbb711fce829a96b53fcffda3a7954177c93c81a3ad22216d
|
|
BLAKE2b-256 checksum How to use checksums |
4ad8403bddce85172056b34a24cab94f3cb4053d11cca00b02d7189e115d4b8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 12, 2026.
Transparency logRelease files / pollinationai_sdk-1.0.3-py3-none-any.whl
| Download URL | pollinationai_sdk-1.0.3-py3-none-any.whl |
|---|---|
| Size | 460.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d19382fe808140a0e6c3faf0820aa65cc4eec359f59c5e28cc4be135950f38ad
|
|
BLAKE2b-256 checksum How to use checksums |
890c835a64642a33c8a3aabed24208d3a28f55f28f9f0497ccaa8655beb53f01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 12, 2026.
Transparency logSecurity for PollinationAI-SDK 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pollinationai_sdk-1.0.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.