Skip to main content

pollinations.ai API

Project description

PollinationAI_SDK

Documentation for gen.pollinations.ai - the pollinations.ai API gateway.

📝 Edit docs

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:

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:

  1. Header: Authorization: Bearer YOUR_API_KEY
  2. 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

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.2.tar.gz (107.4 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.2-py3-none-any.whl (363.6 kB view details)

Uploaded Python 3

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

Hashes for pollinationai_sdk-1.0.2.tar.gz
Algorithm Hash digest
SHA256 981702ae607002a30dd418a67ec4cca35d7b0c1e6cf55f4ec7165bd97c566761
MD5 eaf3b3cd296ea1249f4d225671fdbee8
BLAKE2b-256 7520be2acb9b31f9bce53112a14ed1f3d34101979869c7cb3de1f1641eb8cfd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pollinationai_sdk-1.0.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pollinationai_sdk-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 06950716a23a8511afbe46e42ed1c79b45b8cb76c8b45448eff476b27898be7b
MD5 a55eba51f6d2e35becf7e168a6af9300
BLAKE2b-256 1e5a04586a6a69f52cebbc05fc20ca85f4894363c83b33fbb3585fe0dd438646

See more details on using hashes here.

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

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