Pollinations AI - Image, Music & Video Generation
A comprehensive skill for generating images, music, and video using the Pollinations AI API.
Overview
Pollinations.ai provides free AI generation with API key support. This skill enables:
- - Image Generation - Create images from text prompts using state-of-the-art models
- Music/Audio Generation - Generate background music and audio tracks
- Video Generation - Create videos from text descriptions
Prerequisites
1. Get an API Key
Visit pollinations.ai to get your free API key.
2. Set Environment Variable
Add to your shell profile (~/.bashrc or ~/.zshrc):
CODEBLOCK0
Then reload:
CODEBLOCK1
3. Install Dependencies
CODEBLOCK2
Security Configuration
Required Environment Variables
| Variable | Required | Description |
|---|
| INLINECODE2 | Yes | Your API key from pollinations.ai |
Optional Environment Variables
| Variable | Default | Description |
|---|
| INLINECODE3 | (none) | Chat ID for Telegram sending. If not set, --telegram flag is disabled |
| INLINECODE4 |
.,
/tmp | Comma-separated list of allowed output directories |
|
OPENCLAW_WORKSPACE |
~/.openclaw/workspace | Workspace directory for output files |
Note: The --telegram flag requires TELEGRAM_CHAT_ID to be explicitly set. If not set, the feature is disabled for security.
Available Scripts
| Script | Purpose |
|---|
| INLINECODE11 | Generate images from text prompts |
| INLINECODE12 |
Generate music and audio |
|
pollinations_video_gen.py | Generate videos from text |
Usage
Image Generation
CODEBLOCK3
Parameters:
| Parameter | Description | Default |
|---|
| INLINECODE14 | Text description of desired image | (required) |
| INLINECODE15 |
AI model to use | flux |
|
--width | Image width in pixels | 1024 |
|
--height | Image height in pixels | 1024 |
|
--enhance | Enable AI prompt enhancement | false |
|
--seed | Fixed random seed for reproducibility | random |
|
--safe | Enable safe mode | false |
|
--output | Output filename | output.jpg |
|
--telegram | Send result via Telegram (requires TELEGRAM
CHATID) | false |
Music/Audio Generation
CODEBLOCK4
Parameters:
| Parameter | Description | Default |
|---|
| INLINECODE23 | Description of desired music | (required) |
| INLINECODE24 |
Audio model | suno-4 |
|
--duration | Length in seconds | 30 |
|
--output | Output filename | output.mp3 |
Video Generation
CODEBLOCK5
Parameters:
| Parameter | Description | Default |
|---|
| INLINECODE27 | Description of desired video | (required) |
| INLINECODE28 |
Video model | suno-4 |
|
--duration | Length in seconds | 10 |
|
--aspectRatio | Video aspect ratio (16:9 or 9:16) | 16:9 |
|
--output | Output filename | output.mp4 |
Supported Models
Image Models
| Model | Description | Quality |
|---|
| INLINECODE32 | Default high-quality model | ⭐⭐⭐⭐⭐ |
| INLINECODE33 |
Latest flux (FREE) | ⭐⭐⭐⭐⭐ |
|
zimage | Fast generation | ⭐⭐⭐⭐ |
|
nanobanana | Creative/artistic | ⭐⭐⭐⭐ |
|
gptimage | OpenAI-based | ⭐⭐⭐⭐ |
|
seedream | High detail | ⭐⭐⭐⭐ |
Audio Models
| Model | Description |
|---|
| INLINECODE38 | Latest (recommended) ⭐ |
| INLINECODE39 |
Previous version |
|
suno-3 | Legacy model |
Video Models
| Model | Description |
|---|
| INLINECODE41 | Music video generation ⭐ |
| INLINECODE42 |
Google video AI |
|
seedance | High quality |
|
wan | Open source option |
|
ltx-2 | Fast generation |
Security Features
This skill includes several security measures:
- 1. Path Traversal Protection - All output paths are validated against allowed directories
- Environment Variable Validation - Telegram sending requires explicit opt-in
- No Hardcoded Credentials - All credentials come from environment variables
- File Access Whitelist - Only configured directories can be written to
Troubleshooting
| Error | Cause | Solution |
|---|
| 401 Unauthorized | Missing or invalid API key | Set POLLINATIONS_API_KEY correctly |
| 403 Forbidden |
API key lacks permission | Check your key permissions at pollinations.ai |
| 429 Too Many Requests | Rate limit exceeded | Wait before making more requests |
| 402 Payment Required | Insufficient balance | Add credits at pollinations.ai |
References
- - API Documentation: https://gen.pollinations.ai/api/docs
- Pollinations Website: https://pollinations.ai/
Pollinations AI - 图像、音乐与视频生成
一个使用Pollinations AI API生成图像、音乐和视频的综合技能。
概述
Pollinations.ai提供免费的AI生成服务,支持API密钥。本技能支持:
- - 图像生成 - 使用最先进的模型从文本提示创建图像
- 音乐/音频生成 - 生成背景音乐和音频轨道
- 视频生成 - 从文本描述创建视频
前提条件
1. 获取API密钥
访问pollinations.ai获取免费API密钥。
2. 设置环境变量
添加到您的shell配置文件(~/.bashrc或~/.zshrc):
bash
export POLLINATIONSAPIKEY=yourapikey_here
然后重新加载:
bash
source ~/.bashrc
3. 安装依赖
bash
pip install requests Pillow
安全配置
必需的环境变量
| 变量 | 必需 | 描述 |
|---|
| POLLINATIONSAPIKEY | 是 | 来自pollinations.ai的API密钥 |
可选的环境变量
| 变量 | 默认值 | 描述 |
|---|
| TELEGRAMCHATID | (无) | 用于Telegram发送的聊天ID。如果未设置,--telegram标志将被禁用 |
| ALLOWEDOUTPUTDIRS |
., /tmp | 允许的输出目录列表,以逗号分隔 |
| OPENCLAW_WORKSPACE | ~/.openclaw/workspace | 输出文件的工作空间目录 |
注意: --telegram标志需要显式设置TELEGRAMCHATID。如果未设置,该功能将被禁用以确保安全。
可用脚本
| 脚本 | 用途 |
|---|
| pollinationsimagegen.py | 从文本提示生成图像 |
| pollinationsaudiogen.py |
生成音乐和音频 |
| pollinations
videogen.py | 从文本生成视频 |
使用方法
图像生成
bash
基本用法
python pollinations
imagegen.py 一只可爱的猫 --output cat.jpg
使用特定模型和增强功能
python pollinations
imagegen.py 赛博朋克城市夜景 --model flux --enhance --width 1920 --height 1080 --output city.jpg
使用不同模型
python pollinations
imagegen.py 你的提示 --model zimage
python pollinations
imagegen.py 你的提示 --model flux-2-dev # 免费层级
参数:
| 参数 | 描述 | 默认值 |
|---|
| prompt | 所需图像的文本描述 | (必需) |
| --model |
使用的AI模型 | flux |
| --width | 图像宽度(像素) | 1024 |
| --height | 图像高度(像素) | 1024 |
| --enhance | 启用AI提示增强 | false |
| --seed | 固定随机种子以实现可重复性 | 随机 |
| --safe | 启用安全模式 | false |
| --output | 输出文件名 | output.jpg |
| --telegram | 通过Telegram发送结果(需要TELEGRAM
CHATID) | false |
音乐/音频生成
bash
从提示生成音乐
python pollinations
audiogen.py 欢快的电子舞曲 --output music.mp3
自定义时长
python pollinations
audiogen.py 平静的钢琴旋律 --duration 60 --output piano.mp3
参数:
| 参数 | 描述 | 默认值 |
|---|
| prompt | 所需音乐的描述 | (必需) |
| --model |
音频模型 | suno-4 |
| --duration | 时长(秒) | 30 |
| --output | 输出文件名 | output.mp3 |
视频生成
bash
生成视频
python pollinations
videogen.py 一只猫在玩球 --output video.mp4
自定义时长和宽高比
python pollinations
videogen.py 海浪 --duration 30 --aspectRatio 16:9 --output ocean.mp4
参数:
| 参数 | 描述 | 默认值 |
|---|
| prompt | 所需视频的描述 | (必需) |
| --model |
视频模型 | suno-4 |
| --duration | 时长(秒) | 10 |
| --aspectRatio | 视频宽高比(16:9或9:16) | 16:9 |
| --output | 输出文件名 | output.mp4 |
支持的模型
图像模型
| 模型 | 描述 | 质量 |
|---|
| flux | 默认高质量模型 | ⭐⭐⭐⭐⭐ |
| flux-2-dev |
最新flux(免费) | ⭐⭐⭐⭐⭐ |
| zimage | 快速生成 | ⭐⭐⭐⭐ |
| nanobanana | 创意/艺术风格 | ⭐⭐⭐⭐ |
| gptimage | 基于OpenAI | ⭐⭐⭐⭐ |
| seedream | 高细节 | ⭐⭐⭐⭐ |
音频模型
| 模型 | 描述 |
|---|
| suno-4 | 最新版本(推荐)⭐ |
| suno-3.5 |
先前版本 |
| suno-3 | 旧版模型 |
视频模型
Google视频AI |
| seedance | 高质量 |
| wan | 开源选项 |
| ltx-2 | 快速生成 |
安全特性
本技能包含多项安全措施:
- 1. 路径遍历保护 - 所有输出路径都经过允许目录验证
- 环境变量验证 - Telegram发送需要显式选择启用
- 无硬编码凭证 - 所有凭证来自环境变量
- 文件访问白名单 - 只能写入已配置的目录
故障排除
| 错误 | 原因 | 解决方案 |
|---|
| 401 未授权 | API密钥缺失或无效 | 正确设置POLLINATIONSAPIKEY |
| 403 禁止访问 |
API密钥权限不足 | 在pollinations.ai检查密钥权限 |
| 429 请求过多 | 超出速率限制 | 等待后再发起更多请求 |
| 402 需要付款 | 余额不足 | 在pollinations.ai充值 |
参考
- - API文档:https://gen.pollinations.ai/api/docs
- Pollinations网站:https://pollinations.ai/