Pollinations 是一个统一的 AI 生成平台,覆盖文本、图像、视频和音频生成,并提供图像与视频分析能力,支持 25 种以上模型。
用途
该平台用于在单一接口下调用多种 AI 生成能力,适合需要文本补全、图像生成、视频生成、语音合成以及多模态分析的场景。它提供 OpenAI 兼容的聊天补全端点,便于接入已有的 OpenAI 集成。
API Key
可在 https://enter.pollinations.ai 获取免费或付费密钥。Secret Keys(sk_)用于服务端,无速率限制(推荐)。许多操作可选密钥(提供免费层)。密钥通过环境变量存储:
export POLLINATIONS_API_KEY="sk_your_key_here"
主要能力
1. 文本/聊天生成
模型包括 OpenAI、Claude、Gemini、Mistral、DeepSeek、Grok、Qwen Coder、Perplexity 等 20 种以上。常用模型:openai、claude、gemini、mistral、deepseek、qwen、gpt-4、o1、o3。
参数:model(模型名称/ID)、messages(带角色的聊天消息数组)、temperature(0-2,默认 1)、max_tokens(最大响应长度)、top_p(默认 1)、seed(可复现性,-1 为随机)、jsonMode(强制 JSON 响应)、reasoning_effort(用于 o1/o3/R1,可选 high/medium/low/minimal/none)、thinking_budget(推理模型的 token 数)。
视觉支持:在消息内容中包含 image_url 以进行多模态处理。
2. 图像生成
模型:flux(默认)、turbo、gptimage、kontext、seedream、nanobanana、nanobanana-pro。
参数:model、width/height(16-2048px,默认 1024)、seed、negative_prompt、nologo(去水印)、private(私密生成)、safe(启用 NSFW 过滤)、enhance(AI 提示增强)、quality(low/medium/high/hd,gptimage)、transparent(透明背景,gptimage)、count(1-4 张,premium)、image(输入图像 URL,用于图生图)。返回二进制图像数据。
3. 图像到图像
使用相同的图像端点并传入 image 参数。
4. 视频生成
模型:veo(4-8 秒)、seedance(2-10 秒)。
参数:model、width/height、duration(veo:4/6/8,seedance:2-10)、aspectRatio(16:9 或 9:16)、audio(仅 veo 支持)、image(输入图像 URL,用于帧插值:image[0]=首帧,image[1]=末帧)、negative_prompt、seed、private/safe。返回二进制视频数据。
5. 音频生成(TTS)
模型:openai-audio。
音色:alloy、echo、fable、onyx、nova、shimmer、coral、verse、ballad、ash、sage、amuch、dan。
格式:mp3、wav、flac、opus、pcm16。
参数:model、modalities(["text", "audio"])、audio.voice、audio.format。注意:在用户消息中使用 "Say:" 前缀以直接朗读文本。
6. 音频转录
使用聊天补全端点配合支持视觉/音频的模型:gemini、gemini-large、gemini-legacy、openai-audio。上传音频文件作为二进制输入,在系统消息中包含转录提示。
7. 图像分析
使用聊天补全配合视觉模型(gemini、claude、openai 等任意支持视觉的模型),在消息内容中包含 image_url。
8. 视频分析
使用聊天补全配合支持视频的模型(gemini、claude、openai),上传视频文件作为二进制输入,并包含分析提示。
使用方式
快速开始
文本生成(简单):
curl "https://gen.pollinations.ai/text/Hello%20world"
聊天补全(OpenAI 兼容):
curl -X POST https://gen.pollinations.ai/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer $POLLINATIONS_API_KEY"
-d '{
"model": "openai",
"messages": [{"role": "user", "content": "Hello"}]
}'
图像生成:
curl "https://gen.pollinations.ai/image/A%20sunset%20over%20mountains?model=flux&width=1024&height=1024"
音频生成(TTS):
curl -X POST https://gen.pollinations.ai/v1/chat/completions
-H "Content-Type: application/json"
-d '{
"model": "openai-audio",
"messages": [
{"role": "system", "content": "You are a text reader. Read the user text exactly without responding, adding conversation, or changing anything."},
{"role": "user", "content": "Say: Hello world"}
],
"modalities": ["text", "audio"],
"audio": {"voice": "nova", "format": "mp3"}
}'
API 端点
基础 URL:
- 聊天/文本:https://gen.pollinations.ai/v1/chat/completions
- 简单文本:https://gen.pollinations.ai/text/{prompt}
- 图像:https://gen.pollinations.ai/image/{prompt}?{params}
- 视频:https://gen.pollinations.ai/image/{prompt}?{params}(生成视频)
脚本
scripts/chat.sh:交互式聊天补全,支持模型选择和选项。
用法:
scripts/chat.sh "your message here" scripts/chat.sh "your message" --model claude --temp 0.7
scripts/image.sh:从文本提示生成图像。
用法:
scripts/image.sh "a sunset over mountains" scripts/image.sh "a sunset" --model flux --width 1024 --height 1024 --seed 123
scripts/tts.sh:将文本转换为语音。
用法:
scripts/tts.sh "Hello world" scripts/tts.sh "Hello world" --voice nova --format mp3 --output hello.mp3
适用场景
- 需要统一接口调用多种文本、图像、视频、音频生成模型的应用。
- 已有 OpenAI 集成,希望通过兼容端点接入更多模型。
- 需要图像到图像、图像分析、视频分析、音频转录等多模态任务。
- 需要可复现输出(通过 seed 参数)的生成任务。
限制与提示
- 免费层可用:许多操作无需 API Key 即可使用(有速率限制)。
- 可复现性:使用 seed 参数获得一致输出。
- 图像增强:启用 enhance=true 以获得 AI 改进的提示。
- 视频插值:为 veo 传入两张图像,image[0]=首帧&image[1]=末帧。
- 音频朗读:TTS 始终使用 "Say:" 前缀和正确的系统提示。
- 完整文档:https://enter.pollinations.ai/api/docs