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.1
  • 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_image_models GET /image/models
GenPollinationsAiApi get_generate_image_prompt__s_s GET /image/{prompt}
GenPollinationsAiApi get_generate_text_models GET /text/models
GenPollinationsAiApi get_generate_text_prompt GET /text/{prompt}
GenPollinationsAiApi get_generate_v1_models GET /v1/models
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.1.tar.gz (100.0 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.1-py3-none-any.whl (324.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pollinationai_sdk-1.0.1.tar.gz
  • Upload date:
  • Size: 100.0 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.1.tar.gz
Algorithm Hash digest
SHA256 10f4b27ae5194aaa2c110f2ba14150f8bac206b7baaedf99095b0b191671cfdf
MD5 f73c59cc7f9d824d30360a7b8e2bea3b
BLAKE2b-256 7293145e34186002588d469e940a5ecedfef9ed2791c2ec38217cb2269bcc758

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pollinationai_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5415cd587fcbd82f4e1f2f521206bba4e351f42174ebe3759421fb6b994d45a
MD5 e84c007ba4eddc3543361ff1ca084b2e
BLAKE2b-256 a9f7eb4cc8c987ee3ff5a7b9629804760cd1b0ed1aa9496d4477dca8206a3a07

See more details on using hashes here.

Provenance

The following attestation bundles were made for pollinationai_sdk-1.0.1-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