Loading...
Loading...
使用Pollinations.ai的免费开源API生成并保存图片。无需注册。支持基于URL的生成方式、自定义参数(宽度、高度、模型、种子值)以及自动文件保存功能。非常适合快速原型制作、营销素材生成和创意工作流。
npx skill4agent add supercent-io/skills-template pollinations-aihttps://image.pollinations.ai/prompt/{YOUR_PROMPT}?{PARAMETERS}widthheightmodelfluxturbostable-diffusionseednologotrueenhancetrue[主体], [风格], [光线], [氛围], [构图], [画质修饰词]一位父亲迎接美好假期,温暖的黄金时段光线,带有节日装饰的温馨室内背景,8K分辨率,细节丰富,电影级景深curl# 基础生成
curl "https://image.pollinations.ai/prompt/A_serene_mountain_landscape" -o mountain.jpg
# 带参数生成
curl "https://image.pollinations.ai/prompt/A_serene_mountain_landscape?width=1920&height=1080&model=flux&seed=42" -o mountain-hd.jpgimport requests
from urllib.parse import quote
def generate_image(prompt, output_file, width=1920, height=1080, model="flux", seed=None):
"""
使用Pollinations.ai生成图片并保存到文件
参数:
prompt: 要生成的图片描述
output_file: 图片保存路径
width: 图片宽度(像素)
height: 图片高度(像素)
model: AI模型('flux', 'turbo', 'stable-diffusion')
seed: 可选参数,用于结果复现
"""
# 对提示词进行URL编码
encoded_prompt = quote(prompt)
url = f"https://image.pollinations.ai/prompt/{encoded_prompt}"
# 构建参数
params = {
"width": width,
"height": height,
"model": model,
"nologo": "true"
}
if seed:
params["seed"] = seed
# 生成并保存
print(f"生成中: {prompt[:50]}...")
response = requests.get(url, params=params)
if response.status_code == 200:
with open(output_file, "wb") as f:
f.write(response.content)
print(f"✓ 已保存到 {output_file}")
return True
else:
print(f"✗ 错误: {response.status_code}")
return False
# 使用示例
generate_image(
prompt="一位父亲迎接美好假期,温暖光线,节日装饰",
output_file="holiday_father.jpg",
width=1920,
height=1080,
model="flux",
seed=12345
)prompts = [
"父亲在前门的写实照片,温暖光线,节日装饰",
"父亲在雪地中的数字插画,梦幻冬日仙境,迪士尼风格",
"父子的极简剪影,节日烟花,扁平化设计"
]
for i, prompt in enumerate(prompts):
generate_image(
prompt=prompt,
output_file=f"variant_{i+1}.jpg",
width=1920,
height=1080,
model="flux"
)import json
from datetime import datetime
metadata = {
"prompt": prompt,
"model": "flux",
"width": 1920,
"height": 1080,
"seed": 12345,
"output_file": "holiday_father.jpg",
"timestamp": datetime.now().isoformat()
}
with open("generation_metadata.json", "w") as f:
json.dump(metadata, f, indent=2)generate_image(
prompt="日落时分的宁静山地景观,16:9宽幅,极简风格,蓝色调柔和渐变,简洁线条,现代美学",
output_file="hero-image.jpg",
width=1920,
height=1080,
model="flux"
)generate_image(
prompt="未来感仪表盘UI,1:1正方形,简洁界面,柔和光线,专业质感,深色主题,微妙发光效果",
output_file="product-thumb.jpg",
width=1024,
height=1024,
model="flux"
)generate_image(
prompt="SaaS初创公司的LinkedIn横幅,现代渐变背景,抽象几何图形,紫蓝色调,左侧预留文字空间",
output_file="linkedin-banner.jpg",
width=1584,
height=396,
model="flux"
)# 使用不同种子值生成同提示词的4种变体
base_prompt = "一位父亲迎接美好假期,电影级光线"
for seed in [100, 200, 300, 400]:
generate_image(
prompt=base_prompt,
output_file=f"variation_seed_{seed}.jpg",
width=1920,
height=1080,
model="flux",
seed=seed
)fluxturbostable-diffusionurllib.parse.quote()generate_image(prompt="...", seed=12345, ...) # 每次输出都相同# Instagram: 1:1
generate_image(prompt="...", width=1080, height=1080)
# LinkedIn横幅: ~4:1
generate_image(prompt="...", width=1584, height=396)
# YouTube缩略图: 16:9
generate_image(prompt="...", width=1280, height=720)prompt = "包含品牌色深蓝色#2563EB和紫色#8B5CF6的景观图"import time
def generate_with_retry(prompt, output_file, max_retries=3):
for attempt in range(max_retries):
if generate_image(prompt, output_file):
return True
print(f"重试 {attempt + 1}/{max_retries}...")
time.sleep(2)
return False## 图片生成报告
### 请求信息
- **提示词**:[完整提示词文本]
- **模型**:flux
- **尺寸**:1920x1080
- **种子值**:12345
### 输出文件
1. `hero-image-v1.jpg` - 主要变体
2. `hero-image-v2.jpg` - 替代风格
3. `hero-image-v3.jpg` - 不同光线效果
### 元数据
- 生成时间:2026-02-13T14:30:00Z
- 迭代次数:3
- 选中版本:hero-image-v1.jpg
### 使用说明
- 最佳用途:网站首页横幅
- 格式:JPEG,1920x1080
- 可复现:是(种子值:12345)| Agent | 角色 | 工具 |
|---|---|---|
| Claude | 提示词工程、质量验证 | 编写、读取 |
| Codex | 脚本执行、批量处理 | Bash、编写 |
| Gemini | 风格分析、品牌一致性检查 | 读取、ask-gemini |
# 1. Claude:生成提示词和脚本
# 2. Codex:执行生成任务
bash -c "python generate_images.py"
# 3. Gemini:审核输出结果
ask-gemini "@outputs/ 分析生成图片的品牌一致性"#pollinations#image-generation#free#api#url-based#no-signup#creative