AgentSkillsCN

openai-image-gen

利用 OpenAI Images API(gpt-image-1.5 或 gpt-image-1),并从 .env 中读取 OPENAI_API_KEY,为 Obsidian 风格的战役日志与背景故事条目生成并保存图像/面板。

SKILL.md
--- frontmatter
name: openai-image-gen
description: Generate and save images/panels for Obsidian-style campaign logs and lore entries using the OpenAI Images API (gpt-image-1.5 or gpt-image-1) with OPENAI_API_KEY from .env.

OpenAI Image Generation (Panels + Portraits)

Use this skill whenever the game rules require frequent image generation (scene panels, action shots, character portraits) and you need to save the image to the repo and embed it into Markdown.

Quickstart

Generate a new image from text:

  • python3 .codex/skills/openai-image-gen/scripts/generate_image.py --prompt "..." --out "codex/worlds/<World>/campaigns/<Campaign>/assets/001_establishing.png"

Generate a scene panel that keeps characters consistent (auto-resolves their lore reference images and uses the edits endpoint):

  • python3 .codex/skills/openai-image-gen/scripts/generate_panel.py --world <World> --character "Zorn" --character "Klik" --prompt "..." --out "codex/worlds/<World>/campaigns/<Campaign>/assets/010_squad_encounter.png"

Generate using reference images (for visual continuity) via the edits endpoint:

  • python3 .codex/skills/openai-image-gen/scripts/generate_image.py --prompt "..." --input-image "path/to/ref1.png" --input-image "path/to/ref2.png" --out "codex/worlds/<World>/campaigns/<Campaign>/assets/002_action.png"

Embedding into logs (Obsidian-friendly)

From campaign_logs/*.md, embed panels like:

  • ![Caption](../assets/001_establishing.png)

Prompting rules (to keep the world consistent)

  • Use the world’s ART_STYLE.md “deconstructed style” keywords.
  • Prefer concrete, visual descriptions (lighting, materials, camera, mood).
  • For known entities: describe their consistent features + pass their existing images as --input-image.

Environment

  • Reads OPENAI_API_KEY from the environment.
  • If not present, tries to load it from a repo .env file (simple KEY=VALUE parsing).

Scripts

  • scripts/generate_image.py: Create an image using gpt-image-1.5 (fallback to gpt-image-1) and write it to disk.
  • scripts/generate_panel.py: Wrapper that resolves lore reference images (characters) and calls generate_image.py with --input-image for visual consistency.
  • scripts/verify_markdown_images.py: Verify that all image links in a Markdown file exist on disk.