Skip to content

guanyang/open-agent-hub / skills/baoyu-imagine

baoyu-imagine

Verified

AI image generation with OpenAI GPT Image 2, Azure OpenAI, Google, OpenRouter, DashScope, Z.AI GLM-Image, MiniMax, Jimeng, Seedream and Replicate APIs. Supports text-to-image, reference images, aspect ratios, and batch generation from saved prompt files. Sequential by default; use batch parallel generation when the user already has multiple prompts or wants stable multi-image throughput. Use when user asks to generate, create, or draw images.

FileKindSize
SKILL.mdskill md18.0 KB
references/codex-image2-fallback.mdmarkdown1.8 KB
references/codex-oauth-vs-openai-api-key.mdmarkdown1.9 KB
references/config/first-time-setup.mdmarkdown12.9 KB
references/config/preferences-schema.mdmarkdown4.1 KB
references/providers/dashscope.mdmarkdown4.5 KB
references/providers/minimax.mdmarkdown1.2 KB
references/providers/openrouter.mdmarkdown776 B
references/providers/replicate.mdmarkdown1.8 KB
references/providers/zai.mdmarkdown1.1 KB
references/usage-examples.mdmarkdown4.6 KB
scripts/build-batch.test.tsscript4.5 KB
scripts/build-batch.tsscript7.3 KB
scripts/main.test.tsscript17.4 KB
scripts/main.tsscript42.4 KB
scripts/providers/azure.test.tsscript5.3 KB
scripts/providers/azure.tsscript5.7 KB
scripts/providers/dashscope.test.tsscript11.3 KB
scripts/providers/dashscope.tsscript18.0 KB
scripts/providers/google.test.tsscript3.3 KB
scripts/providers/google.tsscript9.6 KB
scripts/providers/jimeng.test.tsscript2.7 KB
scripts/providers/jimeng.tsscript12.5 KB
scripts/providers/minimax.test.tsscript5.1 KB
scripts/providers/minimax.tsscript6.2 KB
scripts/providers/openai.test.tsscript5.4 KB
scripts/providers/openai.tsscript12.4 KB
scripts/providers/openrouter.test.tsscript5.3 KB
scripts/providers/openrouter.tsscript9.7 KB
scripts/providers/replicate.test.tsscript7.0 KB
scripts/providers/replicate.tsscript17.4 KB
scripts/providers/seedream.test.tsscript6.4 KB
scripts/providers/seedream.tsscript9.6 KB
scripts/providers/zai.test.tsscript5.2 KB
scripts/providers/zai.tsscript8.7 KB
scripts/types.tsscript2.1 KB

scripts/providers/openai.test.ts

View on GitHub
import assert from "node:assert/strict";
import test from "node:test";

import type { CliArgs } from "../types.ts";
import {
  buildOpenAIGenerationsBody,
  extractImageFromResponse,
  getDefaultModel,
  getOpenAIAspectRatio,
  getOpenAIImageApiDialect,
  getOpenAIResolution,
  getMimeType,
  getOpenAISize,
  getOrientationFromAspectRatio,
  inferAspectRatioFromSize,
  inferResolutionFromSize,
  parseAspectRatio,
  validateArgs,
} from "./openai.ts";

function makeArgs(overrides: Partial<CliArgs> = {}): CliArgs {
  return {
    prompt: null,
    promptFiles: [],
    imagePath: null,
    provider: null,
    model: null,
    aspectRatio: null,
    size: null,
    quality: "2k",
    imageSize: null,
    imageApiDialect: null,
    referenceImages: [],
    n: 1,
    batchFile: null,
    jobs: null,
    json: false,
    help: false,
    ...overrides,
  };
}

test("OpenAI aspect-ratio parsing and size selection match model families", () => {
  assert.equal(getDefaultModel(), "gpt-image-2");
  assert.deepEqual(parseAspectRatio("16:9"), { width: 16, height: 9 });
  assert.equal(parseAspectRatio("wide"), null);
  assert.equal(parseAspectRatio("0:1"), null);

  assert.equal(getOpenAISize("dall-e-3", "16:9", "2k"), "1792x1024");
  assert.equal(getOpenAISize("dall-e-3", "9:16", "normal"), "1024x1792");
  assert.equal(getOpenAISize("dall-e-2", "16:9", "2k"), "1024x1024");
  assert.equal(getOpenAISize("gpt-image-1.5", "16:9", "2k"), "1536x1024");
  assert.equal(getOpenAISize("gpt-image-1.5", "4:3", "2k"), "1024x1024");
  assert.equal(getOpenAISize("gpt-image-2", "16:9", "2k"), "2048x1152");
  assert.equal(getOpenAISize("gpt-image-2", "9:16", "2k"), "1152x2048");
  assert.equal(getOpenAISize("gpt-image-2", "4:3", "2k"), "2048x1536");
  assert.equal(getOpenAISize("gpt-image-2", "2.35:1", "normal"), "1248x528");
  assert.equal(inferAspectRatioFromSize("1536x1024"), "3:2");
  assert.equal(inferResolutionFromSize("1536x1024"), "2K");
  assert.equal(getOpenAIAspectRatio({ aspectRatio: null, size: "2048x1152" }), "16:9");
  assert.equal(getOpenAIResolution({ imageSize: null, size: "2048x1152", quality: "normal" }), "2K");
  assert.equal(getOrientationFromAspectRatio("16:9"), "landscape");
  assert.equal(getOrientationFromAspectRatio("9:16"), "portrait");
  assert.equal(getOrientationFromAspectRatio("1:1"), null);
  assert.equal(getOpenAIImageApiDialect({ imageApiDialect: null }), "openai-native");
});

test("OpenAI generations body switches between native and ratio-metadata dialects", () => {
  assert.deepEqual(
    buildOpenAIGenerationsBody("Draw a skyline", "gpt-image-2", {
      aspectRatio: "16:9",
      size: null,
      quality: "2k",
      imageSize: null,
      imageApiDialect: null,
    }),
    {
      model: "gpt-image-2",
      prompt: "Draw a skyline",
      size: "2048x1152",
      quality: "high",
    },
  );

  assert.deepEqual(
    buildOpenAIGenerationsBody("Draw a skyline", "gemini-3-pro-image-preview", {
      aspectRatio: "16:9",
      size: null,
      quality: "2k",
      imageSize: null,
      imageApiDialect: "ratio-metadata",
    }),
    {
      model: "gemini-3-pro-image-preview",
      prompt: "Draw a skyline",
      size: "16:9",
      metadata: {
        resolution: "2K",
        orientation: "landscape",
      },
    },
  );

  assert.deepEqual(
    buildOpenAIGenerationsBody("Draw a portrait", "gemini-3-pro-image-preview", {
      aspectRatio: null,
      size: "1152x2048",
      quality: "normal",
      imageSize: null,
      imageApiDialect: "ratio-metadata",
    }),
    {
      model: "gemini-3-pro-image-preview",
      prompt: "Draw a portrait",
      size: "9:16",
      metadata: {
        resolution: "2K",
        orientation: "portrait",
      },
    },
  );
});

test("OpenAI validates gpt-image-2 custom size constraints", () => {
  assert.doesNotThrow(() =>
    validateArgs("gpt-image-2", makeArgs({ size: "3840x2160" })),
  );
  assert.doesNotThrow(() =>
    validateArgs("gpt-image-2-2026-04-21", makeArgs({ aspectRatio: "2.35:1" })),
  );

  assert.throws(
    () => validateArgs("gpt-image-2", makeArgs({ size: "1024x576" })),
    /total pixels/,
  );
  assert.throws(
    () => validateArgs("gpt-image-2", makeArgs({ size: "1025x1024" })),
    /multiples of 16px/,
  );
  assert.throws(
    () => validateArgs("gpt-image-2", makeArgs({ aspectRatio: "4:1" })),
    /must not exceed 3:1/,
  );
});

test("OpenAI mime-type detection covers supported reference image extensions", () => {
  assert.equal(getMimeType("frame.png"), "image/png");
  assert.equal(getMimeType("frame.jpg"), "image/jpeg");
  assert.equal(getMimeType("frame.webp"), "image/webp");
  assert.equal(getMimeType("frame.gif"), "image/gif");
});

test("OpenAI response extraction supports base64 and URL download flows", async (t) => {
  const originalFetch = globalThis.fetch;
  t.after(() => {
    globalThis.fetch = originalFetch;
  });

  const fromBase64 = await extractImageFromResponse({
    data: [{ b64_json: Buffer.from("hello").toString("base64") }],
  });
  assert.equal(Buffer.from(fromBase64).toString("utf8"), "hello");

  globalThis.fetch = async () =>
    new Response(Uint8Array.from([1, 2, 3]), {
      status: 200,
      headers: { "Content-Type": "application/octet-stream" },
    });

  const fromUrl = await extractImageFromResponse({
    data: [{ url: "https://example.com/image.png" }],
  });
  assert.deepEqual([...fromUrl], [1, 2, 3]);

  await assert.rejects(
    () => extractImageFromResponse({ data: [{}] }),
    /No image in response/,
  );
});
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall