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
- 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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b92adc78bcaae54dbb711fce829a96b53fcffda3a7954177c93c81a3ad22216d
|
|
| MD5 |
e3bc78f95ee99f506b734e35273f3b1f
|
|
| BLAKE2b-256 |
4ad8403bddce85172056b34a24cab94f3cb4053d11cca00b02d7189e115d4b8f
|
Provenance
The following attestation bundles were made for pollinationai_sdk-1.0.3.tar.gz:
Publisher:
buildAndPublish.yml on yehigo/Pollinations.ai_sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pollinationai_sdk-1.0.3.tar.gz -
Subject digest:
b92adc78bcaae54dbb711fce829a96b53fcffda3a7954177c93c81a3ad22216d - Sigstore transparency entry: 1280669386
- Sigstore integration time:
-
Permalink:
yehigo/Pollinations.ai_sdk@f397a6d513ca63a00325351268728e617e2dccf4 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/yehigo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
buildAndPublish.yml@f397a6d513ca63a00325351268728e617e2dccf4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pollinationai_sdk-1.0.3-py3-none-any.whl.
File metadata
- Download URL: pollinationai_sdk-1.0.3-py3-none-any.whl
- Upload date:
- Size: 460.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d19382fe808140a0e6c3faf0820aa65cc4eec359f59c5e28cc4be135950f38ad
|
|
| MD5 |
2f27aede73c27da18d0a3cfbbdf281a3
|
|
| BLAKE2b-256 |
890c835a64642a33c8a3aabed24208d3a28f55f28f9f0497ccaa8655beb53f01
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pollinationai_sdk-1.0.3-py3-none-any.whl -
Subject digest:
d19382fe808140a0e6c3faf0820aa65cc4eec359f59c5e28cc4be135950f38ad - Sigstore transparency entry: 1280669390
- Sigstore integration time:
-
Permalink:
yehigo/Pollinations.ai_sdk@f397a6d513ca63a00325351268728e617e2dccf4 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/yehigo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
buildAndPublish.yml@f397a6d513ca63a00325351268728e617e2dccf4 -
Trigger Event:
push
-
Statement type: