Visual References (Pexels)
Download visual references from Pexels to inspect style, mood, and composition before generating.
When to use
Use when:
- - The brief mentions a specific style, mood, palette, or visual reference ("I want something minimalist", "editorial style", "something like X")
- The client wants aesthetic coherence with something real or existing
- The brief is visually vague and searching references would improve the result
Don't use when:
- - The brief is straightforward with no visual ambiguity (colors, text, and layout already defined)
- You already have references in INLINECODE0
- It's a minor edit of a previously delivered image
- The brief doesn't mention style and the image is functional/technical
Prerequisites
Requires the PEXELS_API_KEY environment variable (free Pexels API key). The script will fail if the key is not configured. Get one at https://pexels.com/api.
Basic usage
CODEBLOCK0
Options
| Flag | Default | Description |
|---|
| INLINECODE2 | 5 | Number of images |
| INLINECODE3 |
/tmp/visual-refs | Output folder |
|
--orientation | — |
landscape,
portrait,
square |
|
--list-only | — | List URLs only, no download |
Output directory rule (MANDATORY)
ALWAYS use --output /tmp/visual-refs as the output directory. Do NOT invent unique folder names like visual-refs-salon-v2, visual-refs-v3, etc. The script automatically cleans the output folder before each search, so using the same folder every time is safe and prevents accumulation of old references.
Examples
CODEBLOCK1
IMPORTANT: Usage limits
- - Maximum 3 searches per task. One main query, up to two refinements. Do NOT run dozens of searches looking for the perfect reference.
- Use
--count 5 (not 5) to keep it fast. - Pick the best reference from what you get and move on to generation. The references are inspiration, not the final product.
Workflow when you decide to use it
- 1. Receive brief with vague style or mentioned inspiration
- Translate query to English — Pexels works best in English
- Run ONE search with INLINECODE14
- Do NOT review or pick — pass ALL 3 references directly to generateimage
- Generate with ALL references as inputimages (MANDATORY):
generate_image(
prompt: "description of the NEW asset to generate (subject, scene, format) — do NOT describe the references, the model sees them",
input_images: ["/path/to/ref_01_xxx.jpg", "/path/to/ref_02_xxx.jpg", "/path/to/ref_03_xxx.jpg"],
...
)
The generation model sees all references and picks the best style elements. Your prompt describes WHAT to create, not the style — the style comes from the reference images.
IMPORTANT: Do NOT waste tokens reviewing references with read. Do NOT pick a favorite. Pass all downloaded references as input_images and let the generation model decide.
Alternative: user picks references (only when requested)
If the brief explicitly asks to see references first ("enséñame referencias", "muéstrame antes de generar", "quiero elegir yo"), use this flow instead:
- 1. Search and download references as usual
- Send ALL reference images in a SINGLE message via
sessions_send:
sessions_send(sessionKey="<REPLY_TO>", message="5 referencias de salón editorial:\n\nArchivo: /tmp/visual-refs/ref_01_xxx.jpg\nArchivo: /tmp/visual-refs/ref_02_xxx.jpg\nArchivo: /tmp/visual-refs/ref_03_xxx.jpg\nArchivo: /tmp/visual-refs/ref_04_xxx.jpg\nArchivo: /tmp/visual-refs/ref_05_xxx.jpg\n\n¿Cuál te gusta? Puedo usar una, mezclar varias, o buscar otras.", timeoutSeconds=0)
- 3. Wait for user response before generating
- Generate with the references the user chose as INLINECODE18
CRITICAL: Send references EXACTLY ONCE. Do NOT send them individually AND again in a summary. Do NOT re-send references you already sent. One single message with all file paths, that's it.
Only use this alternative flow when the user EXPLICITLY asks to see references first. Default is always: search → pass all → generate.
Script output
- - Images downloaded to
--output as ref_01_<id>.jpg, ref_02_<id>.jpg... - INLINECODE22 with metadata: path, description, author
- Attribution printed to stdout (required by Pexels guidelines)
Limits
- - Demo plan: 50 requests/hour — more than enough for creative use
- Downloaded resolution: ~1080px (regular) — optimal for visual reference
- Attribution: required for public apps, not for internal/creative use
Effective queries
- - Always in English — better results
- Be specific:
"hero shot luxury car black studio" > INLINECODE24 - Include mood:
"cozy home interior warm light bokeh", INLINECODE26 - By sector:
"restaurant food flat lay", "fashion editorial outdoor", INLINECODE29
视觉参考(Pexels)
在生成前从Pexels下载视觉参考,以检查风格、氛围和构图。
使用时机
适用场景:
- - 需求中提及特定风格、氛围、色调或视觉参考(我想要极简风格、编辑风格、类似X的效果)
- 客户希望与真实或现有内容保持美学一致性
- 需求描述视觉上模糊不清,搜索参考能提升最终效果
不适用场景:
- - 需求明确,无视觉模糊性(颜色、文字和布局已定义)
- 你已在input_images中拥有参考图片
- 仅是对之前交付图片的微小修改
- 需求未提及风格,且图片为功能性/技术性内容
前置条件
需要PEXELSAPIKEY环境变量(免费Pexels API密钥)。若未配置密钥,脚本将运行失败。可在https://pexels.com/api获取密钥。
基本用法
bash
python3 ~/.openclaw/workspace/skills/visual-references/scripts/visual_ref.py 查询词 [选项]
选项
| 标志 | 默认值 | 描述 |
|---|
| --count N | 5 | 图片数量 |
| --output DIR |
/tmp/visual-refs | 输出文件夹 |
| --orientation | — | landscape(横向)、portrait(纵向)、square(方形) |
| --list-only | — | 仅列出URL,不下载 |
输出目录规则(必选)
始终使用--output /tmp/visual-refs作为输出目录。 不要自行创建类似visual-refs-salon-v2、visual-refs-v3等独特文件夹名称。脚本会在每次搜索前自动清理输出文件夹,因此每次使用同一文件夹是安全的,可防止旧参考文件堆积。
示例
bash
房地产主图参考
python3 visual_ref.py luxury real estate minimalist nordic --count 5 --orientation landscape --output /tmp/visual-refs
社交媒体方形缩略图
python3 visual_ref.py personal branding outdoor golden hour --count 5 --orientation square --output /tmp/visual-refs
仅列出,不下载
python3 visual_ref.py product photography white background --list-only
重要:使用限制
- - 每个任务最多搜索3次。 一次主要查询,最多两次优化。不要为了寻找完美参考而进行数十次搜索。
- 使用--count 5(而非其他数量)以保持高效。
- 从搜索结果中选取最佳参考,然后进入生成环节。参考图片是灵感来源,而非最终成品。
决定使用后的工作流程
- 1. 接收需求,其中包含模糊的风格描述或提及的灵感来源
- 将查询词翻译为英文——Pexels在英文环境下效果最佳
- 执行一次搜索,使用--count 5
- 不要审查或挑选——直接将所有3张参考图片传递给generateimage
- 将所有参考图片作为inputimages进行生成(必选):
generate_image(
prompt: 描述要生成的新素材(主题、场景、格式)——不要描述参考图片,模型会自行查看,
inputimages: [/path/to/ref01xxx.jpg, /path/to/ref02xxx.jpg, /path/to/ref03_xxx.jpg],
...
)
生成模型会查看所有参考图片并选取最佳风格元素。你的prompt描述的是要创建什么内容,而非风格——风格来自参考图片。
重要提示: 不要使用read浪费token审查参考图片。不要挑选偏好图片。将所有下载的参考图片作为input_images传递,让生成模型自行决定。
替代方案:用户挑选参考(仅在用户要求时)
如果需求明确要求先查看参考(enséñame referencias、muéstrame antes de generar、quiero elegir yo),请使用以下流程:
- 1. 按常规搜索并下载参考图片
- 通过sessions_send在单条消息中发送所有参考图片:
sessionssend(sessionKey=TO>, message=5张编辑风格客厅参考:\n\n文件:/tmp/visual-refs/ref01xxx.jpg\n文件:/tmp/visual-refs/ref02xxx.jpg\n文件:/tmp/visual-refs/ref03xxx.jpg\n文件:/tmp/visual-refs/ref04xxx.jpg\n文件:/tmp/visual-refs/ref05xxx.jpg\n\n你喜欢哪张?我可以使用一张、混合多张,或搜索其他参考。, timeoutSeconds=0)
- 3. 等待用户回复后再进行生成
- 使用用户选择的参考图片作为input_images进行生成
关键:仅发送参考图片一次。 不要单独发送后又汇总再次发送。不要重复发送已发送过的参考图片。仅发送一条包含所有文件路径的消息即可。
仅当用户明确要求先查看参考时才使用此替代流程。默认流程始终是:搜索 → 传递所有 → 生成。
脚本输出
- - 图片下载至--output目录,命名为ref01.jpg、ref02.jpg...
- refs_meta.json包含元数据:路径、描述、作者
- 归属信息输出至stdout(Pexels指南要求)
限制
- - 演示计划:每小时50次请求——创意使用完全足够
- 下载分辨率:约1080px(常规)——适合作为视觉参考
- 归属信息:公开应用需要,内部/创意使用不需要
有效查询技巧
- - 始终使用英文——效果更佳
- 具体明确:hero shot luxury car black studio优于car
- 包含氛围:cozy home interior warm light bokeh、cold corporate office minimal
- 按行业分类:restaurant food flat lay、fashion editorial outdoor、tech startup office