Custom LiteLLM providers for Pollinations.ai and AI Horde, two free image-generation APIs
Project description
litellm-free-image-providers
Custom LiteLLM providers for two genuinely free image-generation APIs that LiteLLM has no built-in support for:
- Pollinations.ai — a fast, unauthenticated, synchronous API. Good as a primary provider.
- AI Horde — a free, crowdsourced-worker API (submit a job, poll until a volunteer worker finishes it). Good as a fallback — it hides the submit-then-poll dance behind the same blocking
image_generation/aimage_generationcontract LiteLLM expects, so callers of/images/generationssee one call either way.
Both are commonly wired as a primary/fallback pair (Pollinations first, AI Horde behind it) in LiteLLM's router fallbacks config.
Why this exists
LiteLLM's /images/generations endpoint has no native provider for either of these APIs. LiteLLM does support registering custom providers via litellm.custom_provider_map + the litellm.llms.custom_llm.CustomLLM base class — that's a first-class, public LiteLLM extension mechanism, not a fork. This package packages that up as an installable dependency instead of code you'd otherwise have to copy-paste into your own deployment.
Installation
pip install litellm-free-image-providers
Usage
LiteLLM only picks up custom providers registered before a request for that provider is dispatched — typically via code that runs at process startup. The standard way to do that without touching LiteLLM's own source is a sitecustomize.py on the Python path: the interpreter's site module imports it automatically at startup, before your main program runs.
sitecustomize.py:
from litellm_free_image_providers import register_all
register_all()
Or register just one:
from litellm_free_image_providers import register_pollinations
register_pollinations()
Then reference them in your LiteLLM config.yaml like any other custom provider — the model string must be <provider>/<anything> (LiteLLM's async image-generation path needs the custom_llm_provider prefix baked into the model string itself, not just set via litellm_params.custom_llm_provider, since it doesn't forward that field through on the image-generation path):
model_list:
- model_name: pollinations-image
litellm_params:
model: pollinations_image_custom/flux
custom_llm_provider: pollinations_image_custom
timeout: 45
num_retries: 0
- model_name: ai-horde-image
litellm_params:
model: ai_horde_image_custom/stable_diffusion
custom_llm_provider: ai_horde_image_custom
timeout: 180
num_retries: 0
router_settings:
fallbacks:
- pollinations-image: ["pollinations-image", "ai-horde-image"]
num_retries: 0 on both is deliberate: LiteLLM's router retries the same deployment before ever falling back to the next one in the chain, so without this a failing pollinations-image call would burn a second attempt before AI Horde is even tried — worse latency for no benefit once a request has already failed once.
Development
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest
License
Project details
Release history Release notifications | RSS feed
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 litellm_free_image_providers-0.1.0.tar.gz.
File metadata
- Download URL: litellm_free_image_providers-0.1.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15fa91725a3c8ea827aacfb7a5402634c48eae51f1ec9363360f46c113f2d1c3
|
|
| MD5 |
50f07a9ef00d74411602ffdc507016ee
|
|
| BLAKE2b-256 |
d00202095b78de6305287fbcdeb7b9135624298fbde9df505e970e2de6b6a189
|
Provenance
The following attestation bundles were made for litellm_free_image_providers-0.1.0.tar.gz:
Publisher:
publish.yml on shqear93/litellm-free-image-providers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
litellm_free_image_providers-0.1.0.tar.gz -
Subject digest:
15fa91725a3c8ea827aacfb7a5402634c48eae51f1ec9363360f46c113f2d1c3 - Sigstore transparency entry: 2191507416
- Sigstore integration time:
-
Permalink:
shqear93/litellm-free-image-providers@c88f3864f86e49106e61f89ff81b7e8cc95a1e5e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shqear93
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c88f3864f86e49106e61f89ff81b7e8cc95a1e5e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file litellm_free_image_providers-0.1.0-py3-none-any.whl.
File metadata
- Download URL: litellm_free_image_providers-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.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 |
468a83348790dccbd21afbf6c4da3d259509ac143faecfdbeddda07e6d44ac94
|
|
| MD5 |
ff02bf60e99bf2a4790461946ca9495a
|
|
| BLAKE2b-256 |
fb4155ad084d51afa15ea4205afea406bb30149509e41078c894f0328fdac62b
|
Provenance
The following attestation bundles were made for litellm_free_image_providers-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on shqear93/litellm-free-image-providers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
litellm_free_image_providers-0.1.0-py3-none-any.whl -
Subject digest:
468a83348790dccbd21afbf6c4da3d259509ac143faecfdbeddda07e6d44ac94 - Sigstore transparency entry: 2191507515
- Sigstore integration time:
-
Permalink:
shqear93/litellm-free-image-providers@c88f3864f86e49106e61f89ff81b7e8cc95a1e5e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shqear93
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c88f3864f86e49106e61f89ff81b7e8cc95a1e5e -
Trigger Event:
workflow_dispatch
-
Statement type: