pollinations.ai API
Project description
PollinationAI_SDK
Documentation for gen.pollinations.ai - the pollinations.ai API gateway.
Quick Start
Get your API key at https://enter.pollinations.ai
Image Generation
curl 'https://gen.pollinations.ai/image/a%20cat?model=flux' \\
-H 'Authorization: Bearer YOUR_API_KEY'
Text Generation
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\"}]}'
Vision (Image Input)
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\": [{\"type\": \"text\", \"text\": \"Describe this image\"}, {\"type\": \"image_url\", \"image_url\": {\"url\": \"https://example.com/image.jpg\"}}]}]}'
Gemini Tools: gemini, gemini-large have code_execution enabled (can generate images/plots). gemini-search has google_search enabled. Responses may include content_blocks with image_url, text, or thinking types.
Simple Text Endpoint
curl 'https://gen.pollinations.ai/text/hello?key=YOUR_API_KEY'
Streaming
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\": \"Write a poem\"}], \"stream\": true}' \\
--no-buffer
Model Discovery
Always check available models before testing:
- Image models: /image/models
- Text models: /v1/models
Authentication
Two key types (both consume Pollen from your balance):
- Publishable Keys (
pk_): ⚠️ Beta - not yet ready for production use. For client-side apps, IP rate-limited (1 pollen per IP per hour). Warning: Exposing in public code will consume your Pollen if your app gets traffic. - Secret Keys (
sk_): Server-side only, no rate limits. Keep secret - never expose publicly.
Auth methods:
- Header:
Authorization: Bearer YOUR_API_KEY - Query param:
?key=YOUR_API_KEY
Account Management
Check your balance and usage:
# Check pollen balance
curl 'https://gen.pollinations.ai/account/balance' \\
-H 'Authorization: Bearer YOUR_API_KEY'
# Get profile info
curl 'https://gen.pollinations.ai/account/profile' \\
-H 'Authorization: Bearer YOUR_API_KEY'
# View usage history
curl 'https://gen.pollinations.ai/account/usage' \\
-H 'Authorization: Bearer YOUR_API_KEY'
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 0.3.0
- Package version: 1.0.2
- Generator version: 7.21.0-SNAPSHOT
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
Requirements.
Python 3.9+
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.GenPollinationsAiApi(api_client)
try:
api_response = api_instance.get_account_balance()
print("The response of GenPollinationsAiApi->get_account_balance:\n")
pprint(api_response)
except ApiException as e:
print("Exception when calling GenPollinationsAiApi->get_account_balance: %s\n" % e)
Documentation for API Endpoints
All URIs are relative to https://gen.pollinations.ai
| Class | Method | HTTP request | Description |
|---|---|---|---|
| GenPollinationsAiApi | get_account_balance | GET /account/balance | |
| GenPollinationsAiApi | get_account_key | GET /account/key | |
| GenPollinationsAiApi | get_account_profile | GET /account/profile | |
| GenPollinationsAiApi | get_account_usage | GET /account/usage | |
| GenPollinationsAiApi | get_account_usage_daily | GET /account/usage/daily | |
| GenPollinationsAiApi | get_generate_audio_by_text | GET /audio/{text} | |
| GenPollinationsAiApi | get_generate_audio_models | GET /audio/models | |
| GenPollinationsAiApi | get_generate_image_by_prompt | GET /image/{prompt} | |
| GenPollinationsAiApi | get_generate_image_models | GET /image/models | |
| GenPollinationsAiApi | get_generate_text_by_prompt | GET /text/{prompt} | |
| GenPollinationsAiApi | get_generate_text_models | GET /text/models | |
| GenPollinationsAiApi | get_generate_v1_models | GET /v1/models | |
| GenPollinationsAiApi | post_generate_v1_audio_speech | POST /v1/audio/speech | |
| GenPollinationsAiApi | post_generate_v1_audio_transcriptions | POST /v1/audio/transcriptions | |
| GenPollinationsAiApi | post_generate_v1_chat_completions | POST /v1/chat/completions |
Documentation For Models
- CacheControl
- CompletionUsage
- CompletionUsageCompletionTokensDetails
- CompletionUsagePromptTokensDetails
- ContentFilterResult
- ContentFilterResultHate
- ContentFilterResultJailbreak
- ContentFilterSeverity
- CreateSpeechRequest
- ErrorDetails
- GetAccountBalance200Response
- GetAccountKey200Response
- GetAccountKey200ResponsePermissions
- GetAccountProfile200Response
- GetAccountUsage200Response
- GetAccountUsage200ResponseUsageInner
- GetAccountUsageDaily200Response
- GetAccountUsageDaily200ResponseUsageInner
- GetGenerateImageModels500Response
- GetGenerateImageModels500ResponseError
- GetGenerateImageModels500ResponseErrorMessage
- GetGenerateTextByPrompt400Response
- GetGenerateTextByPrompt400ResponseError
- GetGenerateTextByPrompt400ResponseErrorMessage
- GetGenerateTextByPrompt401Response
- GetGenerateTextByPrompt401ResponseError
- GetGenerateTextByPrompt401ResponseErrorMessage
- GetGenerateTextByPrompt402Response
- GetGenerateTextByPrompt402ResponseError
- GetGenerateTextByPrompt402ResponseErrorMessage
- GetGenerateTextByPrompt403Response
- GetGenerateTextByPrompt403ResponseError
- GetGenerateTextByPrompt403ResponseErrorMessage
- GetGenerateV1Models200Response
- GetGenerateV1Models200ResponseDataInner
- GetGenerateV1Models500Response
- GetGenerateV1Models500ResponseError
- GetGenerateV1Models500ResponseErrorMessage
- MessageContentPart
- MessageContentPartAnyOf
- MessageContentPartAnyOf1
- MessageContentPartAnyOf1InputAudio
- MessageContentPartAnyOf2
- MessageContentPartAnyOf2File
- MessageContentPartAnyOfVideoUrl
- 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
- 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
- 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.2.tar.gz.
File metadata
- Download URL: pollinationai_sdk-1.0.2.tar.gz
- Upload date:
- Size: 107.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
981702ae607002a30dd418a67ec4cca35d7b0c1e6cf55f4ec7165bd97c566761
|
|
| MD5 |
eaf3b3cd296ea1249f4d225671fdbee8
|
|
| BLAKE2b-256 |
7520be2acb9b31f9bce53112a14ed1f3d34101979869c7cb3de1f1641eb8cfd7
|
Provenance
The following attestation bundles were made for pollinationai_sdk-1.0.2.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.2.tar.gz -
Subject digest:
981702ae607002a30dd418a67ec4cca35d7b0c1e6cf55f4ec7165bd97c566761 - Sigstore transparency entry: 991431416
- Sigstore integration time:
-
Permalink:
yehigo/Pollinations.ai_sdk@c78153f5b99e1be8c7a028747e025d10a321148e -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/yehigo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
buildAndPublish.yml@c78153f5b99e1be8c7a028747e025d10a321148e -
Trigger Event:
push
-
Statement type:
File details
Details for the file pollinationai_sdk-1.0.2-py3-none-any.whl.
File metadata
- Download URL: pollinationai_sdk-1.0.2-py3-none-any.whl
- Upload date:
- Size: 363.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06950716a23a8511afbe46e42ed1c79b45b8cb76c8b45448eff476b27898be7b
|
|
| MD5 |
a55eba51f6d2e35becf7e168a6af9300
|
|
| BLAKE2b-256 |
1e5a04586a6a69f52cebbc05fc20ca85f4894363c83b33fbb3585fe0dd438646
|
Provenance
The following attestation bundles were made for pollinationai_sdk-1.0.2-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.2-py3-none-any.whl -
Subject digest:
06950716a23a8511afbe46e42ed1c79b45b8cb76c8b45448eff476b27898be7b - Sigstore transparency entry: 991431418
- Sigstore integration time:
-
Permalink:
yehigo/Pollinations.ai_sdk@c78153f5b99e1be8c7a028747e025d10a321148e -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/yehigo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
buildAndPublish.yml@c78153f5b99e1be8c7a028747e025d10a321148e -
Trigger Event:
push
-
Statement type: