Skip to content

CanvasAnvil is an open source AI diagram maker and flowchart generator - an infinite-canvas diagram editor and self-hosted drawio alternative that writes editable .drawio files. Text to diagram, then fix nodes, layout and labels in place. Also AI presentations, interior design CAD/BOM, posters and infographics.

refactor(skill): drop the multi-vendor image layer, keep OpenAI

codingFeng101d6b9980d7a69
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6198750..8228504 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ exist once instead of per workspace.
- Removed the poster, product and infographic canvases, narrowing the product to Flow, Interior Design and PPT.
- Removed the multi-provider model layer and the vendor picker. All model access goes through one OpenAI-compatible transport.
- Removed the Next.js port that shadowed the Vite client, and roughly 900 lines of unreachable code the old `PptWorkspace` was hiding.
+- Removed the nine-vendor image registry the `cad-skill` and `ppt-skill` packages still carried, along with the `provider` config key it read. Eight of those vendors had no base URL to reach and each skill shipped its own byte-identical copy of the table. The endpoint now follows from the model's name -- `gpt-image-*` and `dall-e-*` use the images endpoint, everything else answers through chat -- and `baseUrl` points at whichever OpenAI-compatible gateway serves it.
### Added
diff --git a/skill/cad-skill/SKILL.md b/skill/cad-skill/SKILL.md
index 73ed612..17709fa 100644
--- a/skill/cad-skill/SKILL.md
+++ b/skill/cad-skill/SKILL.md
@@ -11,19 +11,7 @@ Use when the task requires one step in an interior-design workflow.
## First-Use Reminder
-On the first use of this skill in a conversation, remind the user that image generation is configurable and tell them which model vendors are supported in `config/image-provider.json`.
-
-Supported vendors:
-
-- `openai`
-- `aliyun`
-- `tencent`
-- `bytedance`
-- `zhipu`
-- `google`
-- `xai`
-- `bfl`
-- `adobe`
+On the first use of this skill in a conversation, remind the user that image generation reads `config/image-provider.json`, and that it must be filled in before any image can be produced.
## Order
@@ -120,10 +108,10 @@ Supported vendors:
- `prompts/elevation-index-and-interior-elevations.md`
- `prompts/detail-drawings.md`
- Do not reuse one prompt for all seven outputs.
-- For every analysis board or sheet, first produce a dedicated image prompt with the host model, then pass that image prompt to the configured image provider.
+- For every analysis board or sheet, first produce a dedicated image prompt with the host model, then pass that image prompt to the configured image model.
- Require `config/image-provider.json` before image generation.
- Do not ask the user to paste API keys into chat.
-- Stop and tell the user to fill `config/image-provider.json` when provider, apiKey, or model is missing.
+- Stop and tell the user to fill `config/image-provider.json` when apiKey or model is missing.
## Scripts
diff --git a/skill/cad-skill/config/image-provider.json b/skill/cad-skill/config/image-provider.json
index ffb9855..41163c5 100644
--- a/skill/cad-skill/config/image-provider.json
+++ b/skill/cad-skill/config/image-provider.json
@@ -1,5 +1,4 @@
{
- "provider": "",
"apiKey": "",
"baseUrl": "",
"model": ""
diff --git a/skill/cad-skill/references/image-provider-config.md b/skill/cad-skill/references/image-provider-config.md
index 1429047..34fe3a0 100644
--- a/skill/cad-skill/references/image-provider-config.md
+++ b/skill/cad-skill/references/image-provider-config.md
@@ -1,16 +1,18 @@
-# Image Provider Config
+# Image Config
Image generation uses `config/image-provider.json`.
+Only OpenAI-compatible endpoints are supported. There is no vendor field:
+point `baseUrl` at whichever compatible gateway serves the model.
+
## Required keys
-- `provider`
- `apiKey`
- `model`
## Optional keys
-- `baseUrl`
+- `baseUrl` -- defaults to `https://api.openai.com/v1`
## File Path
@@ -20,27 +22,20 @@ Image generation uses `config/image-provider.json`.
```json
{
- "provider": "openai",
"apiKey": "YOUR_KEY",
"baseUrl": "https://api.openai.com/v1",
"model": "gpt-image-1"
}
```
-## Supported providers
+## Endpoint
-- `openai`
-- `aliyun`
-- `tencent`
-- `bytedance`
-- `zhipu`
-- `google`
-- `xai`
-- `bfl`
-- `adobe`
+Chosen from the model name, not from configuration:
-## Rule
+- `gpt-image-*` and `dall-e-*` use the images endpoint
+- every other model returns its image through chat completions
-Do not ask the user to paste API keys into chat.
+## Rule
-If image generation is requested and `config/image-provider.json` is missing or incomplete, stop and tell the user to fill that file.
+- do not ask the user to paste API keys into chat
+- if `apiKey` or `model` is missing, stop and tell the user to fill the config file
diff --git a/skill/cad-skill/scripts/generate-cad-image.mjs b/skill/cad-skill/scripts/generate-cad-image.mjs
index 0f00e0f..b80b422 100644
--- a/skill/cad-skill/scripts/generate-cad-image.mjs
+++ b/skill/cad-skill/scripts/generate-cad-image.mjs
@@ -3,7 +3,7 @@
import fs from "node:fs";
import path from "node:path";
import { generateImageThroughGateway } from "./lib/gateway.mjs";
-import { getDefaultBaseUrl } from "./lib/provider-registry.mjs";
+import { OPENAI_DEFAULT_BASE_URL } from "./lib/image-route.mjs";
function parseArgs(argv) {
const args = {
@@ -72,18 +72,16 @@ async function main() {
if (!String(prompt || "").trim()) fail("Missing prompt. Use --prompt or --prompt-file.");
const rawConfig = loadConfig(args.configFile);
- const provider = String(rawConfig.provider || "").trim().toLowerCase();
const apiKey = String(rawConfig.apiKey || "").trim();
const model = String(rawConfig.model || "").trim();
- const baseUrl = String(rawConfig.baseUrl || getDefaultBaseUrl(provider) || "").trim();
+ const baseUrl = String(rawConfig.baseUrl || OPENAI_DEFAULT_BASE_URL).trim();
- if (!provider || !apiKey || !model) {
- fail("Missing image provider configuration. Required: provider, apiKey, model. Fill config/image-provider.json.");
+ if (!apiKey || !model) {
+ fail("Missing image configuration. Required: apiKey, model. Fill config/image-provider.json.");
}
const dataUrl = await generateImageThroughGateway({
channel: {
- provider,
apiKey,
baseUrl,
model,
diff --git a/skill/cad-skill/scripts/lib/gateway.mjs b/skill/cad-skill/scripts/lib/gateway.mjs
index 236159e..92a27a2 100644
--- a/skill/cad-skill/scripts/lib/gateway.mjs
+++ b/skill/cad-skill/scripts/lib/gateway.mjs
@@ -1,4 +1,4 @@
-import { resolveImageRoute } from "./provider-registry.mjs";
+import { resolveImageRoute } from "./image-route.mjs";
function joinUrl(baseUrl, endpoint) {
const base = String(baseUrl || "").trim().replace(/\/+$/, "");
diff --git a/skill/cad-skill/scripts/lib/image-route.d.mts b/skill/cad-skill/scripts/lib/image-route.d.mts
new file mode 100644
index 0000000..6591e7e
--- /dev/null
+++ b/skill/cad-skill/scripts/lib/image-route.d.mts
@@ -0,0 +1,18 @@
+/** The endpoint shape an image request takes. */
+export type ImageProtocol = "openai-images" | "openai-chat-image";
+
+export interface ImageRoute {
+ protocol: ImageProtocol;
+}
+
+/** Where image requests go when the config leaves `baseUrl` blank. */
+export declare const OPENAI_DEFAULT_BASE_URL: "https://api.openai.com/v1";
+
+/**
+ * Picks the endpoint from the model's name. Takes no vendor: every model is
+ * reached over an OpenAI-compatible endpoint.
+ */
+export declare function resolveImageRoute(
+ /** The config object as read from disk; any leftover keys are ignored. */
+ channel?: { model?: unknown; [key: string]: unknown } | null,
+): ImageRoute;
diff --git a/skill/cad-skill/scripts/lib/image-route.mjs b/skill/cad-skill/scripts/lib/image-route.mjs
new file mode 100644
index 0000000..2ef4fcc
--- /dev/null
+++ b/skill/cad-skill/scripts/lib/image-route.mjs
@@ -0,0 +1,22 @@
+/**
+ * Which endpoint an image model is reached through.
+ *
+ * Every model goes through an OpenAI-compatible endpoint, but two shapes
+ * exist: `gpt-image-*` and `dall-e-*` are served by the dedicated images
+ * endpoint, while every other model returns its image through chat
+ * completions. That is a difference in the model's own API, not in who
+ * hosts it -- pointing `baseUrl` at a compatible gateway changes neither.
+ */
+
+export const OPENAI_DEFAULT_BASE_URL = "https://api.openai.com/v1";
+
+const IMAGES_ENDPOINT_MODELS = [/gpt-image/i, /dall-e/i];
+
+export function resolveImageRoute(channel) {
+ const model = String(channel?.model || "");
+ return {
+ protocol: IMAGES_ENDPOINT_MODELS.some((pattern) => pattern.test(model))
+ ? "openai-images"
+ : "openai-chat-image",
+ };
+}
diff --git a/skill/cad-skill/scripts/lib/provider-registry.mjs b/skill/cad-skill/scripts/lib/provider-registry.mjs
deleted file mode 100644
index d15cd5b..0000000
--- a/skill/cad-skill/scripts/lib/provider-registry.mjs
+++ /dev/null
@@ -1,51 +0,0 @@
-function matchesRule(provider, model, rules) {
- const normalizedProvider = String(provider || "").toLowerCase();
- const normalizedModel = String(model || "");
- return rules.some(
- (rule) =>
- rule.provider === normalizedProvider &&
- rule.patterns.some((pattern) => pattern.test(normalizedModel)),
- );
-}
-
-const IMAGE_OPENAI_IMAGES_RULES = [
- { provider: "openai", patterns: [/gpt-image/i, /dall-e/i] },
-];
-
-const IMAGE_REFERENCE_RULES = [
- { provider: "openai", patterns: [/gpt-image/i] },
- { provider: "aliyun", patterns: [/wan/i, /qwen-image/i] },
- { provider: "bytedance", patterns: [/seedream/i] },
- { provider: "zhipu", patterns: [/glm-image/i, /cogview/i] },
- { provider: "tencent", patterns: [/hunyuan/i] },
-];
-
-const IMAGE_PROVIDER_OPTIONS = [
- { id: "openai", defaultBaseUrl: "https://api.openai.com/v1" },
- { id: "aliyun", defaultBaseUrl: "" },
- { id: "tencent", defaultBaseUrl: "" },
- { id: "bytedance", defaultBaseUrl: "" },
- { id: "zhipu", defaultBaseUrl: "" },
- { id: "google", defaultBaseUrl: "" },
- { id: "xai", defaultBaseUrl: "" },
- { id: "bfl", defaultBaseUrl: "" },
- { id: "adobe", defaultBaseUrl: "" },
-];
-
-export function getDefaultBaseUrl(provider) {
- return IMAGE_PROVIDER_OPTIONS.find((item) => item.id === provider)?.defaultBaseUrl || "";
-}
-
-export function resolveImageRoute(channel) {
- const provider = String(channel.provider || "").toLowerCase();
- if (!IMAGE_PROVIDER_OPTIONS.some((item) => item.id === provider)) {
- throw new Error(`Unsupported image provider: ${provider}`);
- }
-
- return {
- protocol: matchesRule(provider, channel.model, IMAGE_OPENAI_IMAGES_RULES)
- ? "openai-images"
- : "openai-chat-image",
- supportsReferenceImages: matchesRule(provider, channel.model, IMAGE_REFERENCE_RULES),
- };
-}
diff --git a/skill/ppt-skill/SKILL.md b/skill/ppt-skill/SKILL.md
index c298366..6be5124 100644
--- a/skill/ppt-skill/SKILL.md
+++ b/skill/ppt-skill/SKILL.md
@@ -16,19 +16,8 @@ Use when the task requires:
## First-Use Reminder
-On the first use of this skill in a conversation, remind the user that image generation is configurable.
-
-Image-model vendors supported in `config/image-provider.json`:
-
-- `openai`
-- `aliyun`
-- `tencent`
-- `bytedance`
-- `zhipu`
-- `google`
-- `xai`
-- `bfl`
-- `adobe`
+On the first use of this skill in a conversation, remind the user that image generation reads
+`config/image-provider.json`, and that it must be filled in before any image can be produced.
## Order
@@ -89,11 +78,11 @@ Supported delivery modes:
If the user does not specify an export mode, recommend `pdf` and `image_ppt` first.
-## Provider Contract
+## Image Contract
- Image generation uses `config/image-provider.json`.
-- Template generation and slide generation use the same image-provider config unless the user explicitly defines a split configuration.
-- Require `provider`, `apiKey`, and `model`.
+- Template generation and slide generation use the same image config unless the user explicitly defines a split configuration.
+- Require `apiKey` and `model`.
- Do not ask the user to paste API keys into chat.
- If image generation is requested and config is missing or incomplete, stop and tell the user to fill the config file.
diff --git a/skill/ppt-skill/config/image-provider.json b/skill/ppt-skill/config/image-provider.json
index ffb9855..41163c5 100644
--- a/skill/ppt-skill/config/image-provider.json
+++ b/skill/ppt-skill/config/image-provider.json
@@ -1,5 +1,4 @@
{
- "provider": "",
"apiKey": "",
"baseUrl": "",
"model": ""
diff --git a/skill/ppt-skill/references/image-provider-config.md b/skill/ppt-skill/references/image-provider-config.md
index c8a0cc9..59411fc 100644
--- a/skill/ppt-skill/references/image-provider-config.md
+++ b/skill/ppt-skill/references/image-provider-config.md
@@ -1,16 +1,18 @@
-# Image Provider Config
+# Image Config
Image generation uses `config/image-provider.json`.
+Only OpenAI-compatible endpoints are supported. There is no vendor field:
+point `baseUrl` at whichever compatible gateway serves the model.
+
## Required keys
-- `provider`
- `apiKey`
- `model`
## Optional keys
-- `baseUrl`
+- `baseUrl` -- defaults to `https://api.openai.com/v1`
## File Path
@@ -20,15 +22,21 @@ Image generation uses `config/image-provider.json`.
```json
{
- "provider": "openai",
"apiKey": "YOUR_KEY",
"baseUrl": "https://api.openai.com/v1",
"model": "gpt-image-1"
}
```
+## Endpoint
+
+Chosen from the model name, not from configuration:
+
+- `gpt-image-*` and `dall-e-*` use the images endpoint
+- every other model returns its image through chat completions
+
## Rule
- template generation and slide generation read the same config file by default
- do not ask the user to paste API keys into chat
-- if `provider`, `apiKey`, or `model` is missing, stop and tell the user to fill the config file
+- if `apiKey` or `model` is missing, stop and tell the user to fill the config file
diff --git a/skill/ppt-skill/scripts/generate-ppt-deck-images.mjs b/skill/ppt-skill/scripts/generate-ppt-deck-images.mjs
index 4895de0..61f0e36 100644
--- a/skill/ppt-skill/scripts/generate-ppt-deck-images.mjs
+++ b/skill/ppt-skill/scripts/generate-ppt-deck-images.mjs
@@ -7,7 +7,7 @@ import {
decodeDataUrl,
ensureDir,
imageExtensionFromMime,
- loadImageProviderConfig,
+ loadImageConfig,
readJson,
resolveFromCwd,
safeSlug,
@@ -61,7 +61,7 @@ async function main() {
const prompts = normalizePromptPayload(payload).filter((item) => item && typeof item === "object");
if (prompts.length === 0) fail("No slide prompts found in prompts file.");
- const channel = loadImageProviderConfig(args.configFile);
+ const channel = loadImageConfig(args.configFile);
const outDir = resolveFromCwd(args.outDir);
ensureDir(outDir);
const slidesDir = path.join(outDir, "slides");
@@ -102,7 +102,6 @@ async function main() {
type: "ppt_slide_manifest",
name: args.name,
generatedAt: new Date().toISOString(),
- provider: channel.provider,
model: channel.model,
promptsFile: path.relative(outDir, promptsPath).replace(/\\/g, "/"),
slides,
diff --git a/skill/ppt-skill/scripts/generate-ppt-template-image.mjs b/skill/ppt-skill/scripts/generate-ppt-template-image.mjs
index a4efcfc..21ecb0f 100644
--- a/skill/ppt-skill/scripts/generate-ppt-template-image.mjs
+++ b/skill/ppt-skill/scripts/generate-ppt-template-image.mjs
@@ -7,7 +7,7 @@ import {
decodeDataUrl,
ensureDir,
imageExtensionFromMime,
- loadImageProviderConfig,
+ loadImageConfig,
readJson,
resolveFromCwd,
safeSlug,
@@ -88,7 +88,7 @@ async function main() {
if (!prompt) fail("Resolved template prompt is empty.");
- const channel = loadImageProviderConfig(args.configFile);
+ const channel = loadImageConfig(args.configFile);
const dataUrl = await generateImageThroughGateway({
channel,
prompt,
@@ -123,7 +123,6 @@ async function main() {
imageFile: path.basename(outputPath),
promptSource: promptSource || null,
generatedAt: new Date().toISOString(),
- provider: channel.provider,
model: channel.model,
},
null,
diff --git a/skill/ppt-skill/scripts/lib/common.mjs b/skill/ppt-skill/scripts/lib/common.mjs
index b859087..fc263d5 100644
--- a/skill/ppt-skill/scripts/lib/common.mjs
+++ b/skill/ppt-skill/scripts/lib/common.mjs
@@ -1,6 +1,6 @@
import fs from "node:fs";
import path from "node:path";
-import { getDefaultBaseUrl as getDefaultImageBaseUrl } from "./provider-registry.mjs";
+import { OPENAI_DEFAULT_BASE_URL } from "./image-route.mjs";
export function fail(message) {
console.error(message);
@@ -24,26 +24,21 @@ export function resolveFromCwd(inputPath) {
return path.resolve(process.cwd(), inputPath);
}
-export function loadImageProviderConfig(configFile) {
+export function loadImageConfig(configFile) {
const target = configFile
? resolveFromCwd(configFile)
: resolveFromCwd(path.join("config", "image-provider.json"));
if (!fs.existsSync(target)) {
- fail(`Missing provider config file: ${target}`);
+ fail(`Missing image config file: ${target}`);
}
const raw = readJson(target);
- const provider = String(raw.provider || "").trim().toLowerCase();
const apiKey = String(raw.apiKey || "").trim();
const model = String(raw.model || "").trim();
- const baseUrl = String(raw.baseUrl || getDefaultImageBaseUrl(provider) || "").trim();
- if (!provider || !apiKey || !model) {
- fail("Missing image provider configuration. Required: provider, apiKey, model.");
- }
- if (provider === "custom") {
- fail("Custom image providers are not supported in ppt-skill.");
+ const baseUrl = String(raw.baseUrl || OPENAI_DEFAULT_BASE_URL).trim();
+ if (!apiKey || !model) {
+ fail("Missing image configuration. Required: apiKey, model.");
}
return {
- provider,
apiKey,
model,
baseUrl,
diff --git a/skill/ppt-skill/scripts/lib/gateway.mjs b/skill/ppt-skill/scripts/lib/gateway.mjs
index ae80df7..5b0c19c 100644
--- a/skill/ppt-skill/scripts/lib/gateway.mjs
+++ b/skill/ppt-skill/scripts/lib/gateway.mjs
@@ -1,4 +1,4 @@
-import { resolveImageRoute } from "./provider-registry.mjs";
+import { resolveImageRoute } from "./image-route.mjs";
function joinUrl(baseUrl, endpoint) {
const base = String(baseUrl || "").trim().replace(/\/+$/, "");
diff --git a/skill/ppt-skill/scripts/lib/image-route.d.mts b/skill/ppt-skill/scripts/lib/image-route.d.mts
new file mode 100644
index 0000000..6591e7e
--- /dev/null
+++ b/skill/ppt-skill/scripts/lib/image-route.d.mts
@@ -0,0 +1,18 @@
+/** The endpoint shape an image request takes. */
+export type ImageProtocol = "openai-images" | "openai-chat-image";
+
+export interface ImageRoute {
+ protocol: ImageProtocol;
+}
+
+/** Where image requests go when the config leaves `baseUrl` blank. */
+export declare const OPENAI_DEFAULT_BASE_URL: "https://api.openai.com/v1";
+
+/**
+ * Picks the endpoint from the model's name. Takes no vendor: every model is
+ * reached over an OpenAI-compatible endpoint.
+ */
+export declare function resolveImageRoute(
+ /** The config object as read from disk; any leftover keys are ignored. */
+ channel?: { model?: unknown; [key: string]: unknown } | null,
+): ImageRoute;
diff --git a/skill/ppt-skill/scripts/lib/image-route.mjs b/skill/ppt-skill/scripts/lib/image-route.mjs
new file mode 100644
index 0000000..2ef4fcc
--- /dev/null
+++ b/skill/ppt-skill/scripts/lib/image-route.mjs
@@ -0,0 +1,22 @@
+/**
+ * Which endpoint an image model is reached through.
+ *
+ * Every model goes through an OpenAI-compatible endpoint, but two shapes
+ * exist: `gpt-image-*` and `dall-e-*` are served by the dedicated images
+ * endpoint, while every other model returns its image through chat
+ * completions. That is a difference in the model's own API, not in who
+ * hosts it -- pointing `baseUrl` at a compatible gateway changes neither.
+ */
+
+export const OPENAI_DEFAULT_BASE_URL = "https://api.openai.com/v1";
+
+const IMAGES_ENDPOINT_MODELS = [/gpt-image/i, /dall-e/i];
+
+export function resolveImageRoute(channel) {
+ const model = String(channel?.model || "");
+ return {
+ protocol: IMAGES_ENDPOINT_MODELS.some((pattern) => pattern.test(model))
+ ? "openai-images"
+ : "openai-chat-image",
+ };
+}
diff --git a/skill/ppt-skill/scripts/lib/provider-registry.mjs b/skill/ppt-skill/scripts/lib/provider-registry.mjs
deleted file mode 100644
index d15cd5b..0000000
--- a/skill/ppt-skill/scripts/lib/provider-registry.mjs
+++ /dev/null
@@ -1,51 +0,0 @@
-function matchesRule(provider, model, rules) {
- const normalizedProvider = String(provider || "").toLowerCase();
- const normalizedModel = String(model || "");
- return rules.some(
- (rule) =>
- rule.provider === normalizedProvider &&
- rule.patterns.some((pattern) => pattern.test(normalizedModel)),
- );
-}
-
-const IMAGE_OPENAI_IMAGES_RULES = [
- { provider: "openai", patterns: [/gpt-image/i, /dall-e/i] },
-];
-
-const IMAGE_REFERENCE_RULES = [
- { provider: "openai", patterns: [/gpt-image/i] },
- { provider: "aliyun", patterns: [/wan/i, /qwen-image/i] },
- { provider: "bytedance", patterns: [/seedream/i] },
- { provider: "zhipu", patterns: [/glm-image/i, /cogview/i] },
- { provider: "tencent", patterns: [/hunyuan/i] },
-];
-
-const IMAGE_PROVIDER_OPTIONS = [
- { id: "openai", defaultBaseUrl: "https://api.openai.com/v1" },
- { id: "aliyun", defaultBaseUrl: "" },
- { id: "tencent", defaultBaseUrl: "" },
- { id: "bytedance", defaultBaseUrl: "" },
- { id: "zhipu", defaultBaseUrl: "" },
- { id: "google", defaultBaseUrl: "" },
- { id: "xai", defaultBaseUrl: "" },
- { id: "bfl", defaultBaseUrl: "" },
- { id: "adobe", defaultBaseUrl: "" },
-];
-
-export function getDefaultBaseUrl(provider) {
- return IMAGE_PROVIDER_OPTIONS.find((item) => item.id === provider)?.defaultBaseUrl || "";
-}
-
-export function resolveImageRoute(channel) {
- const provider = String(channel.provider || "").toLowerCase();
- if (!IMAGE_PROVIDER_OPTIONS.some((item) => item.id === provider)) {
- throw new Error(`Unsupported image provider: ${provider}`);
- }
-
- return {
- protocol: matchesRule(provider, channel.model, IMAGE_OPENAI_IMAGES_RULES)
- ? "openai-images"
- : "openai-chat-image",
- supportsReferenceImages: matchesRule(provider, channel.model, IMAGE_REFERENCE_RULES),
- };
-}
diff --git a/tests/skill-image-route.test.ts b/tests/skill-image-route.test.ts
new file mode 100644
index 0000000..ea4a77d
--- /dev/null
+++ b/tests/skill-image-route.test.ts
@@ -0,0 +1,58 @@
+import assert from "node:assert/strict";
+import { test } from "node:test";
+import {
+ OPENAI_DEFAULT_BASE_URL,
+ resolveImageRoute,
+} from "../skill/cad-skill/scripts/lib/image-route.mjs";
+import * as pptRoute from "../skill/ppt-skill/scripts/lib/image-route.mjs";
+
+/**
+ * How the skills reach an image model.
+ *
+ * Only OpenAI-compatible endpoints are supported, so nothing here reads a
+ * vendor: the endpoint follows from the model's own name. The skills used to
+ * carry a nine-vendor registry that decided this from configuration, and
+ * eight of those entries had no base URL to reach in the first place.
+ */
+
+test("gpt-image and dall-e go to the images endpoint", () => {
+ for (const model of ["gpt-image-1", "gpt-image-2", "dall-e-3", "DALL-E-2"]) {
+ assert.equal(resolveImageRoute({ model }).protocol, "openai-images", model);
+ }
+});
+
+test("any other model returns its image through chat", () => {
+ for (const model of ["gpt-5.5", "gpt-4o", "some-vision-model"]) {
+ assert.equal(resolveImageRoute({ model }).protocol, "openai-chat-image", model);
+ }
+});
+
+test("a missing model does not throw, it just takes the chat route", () => {
+ // Config validation is the caller's job; routing must not be where it fails.
+ assert.equal(resolveImageRoute({}).protocol, "openai-chat-image");
+ assert.equal(resolveImageRoute({ model: "" }).protocol, "openai-chat-image");
+ assert.equal(resolveImageRoute(undefined).protocol, "openai-chat-image");
+});
+
+test("the route is decided by the model alone, never by a vendor field", () => {
+ // A leftover `provider` in someone's config file must change nothing.
+ const withVendor = resolveImageRoute({ model: "gpt-image-1", provider: "aliyun" });
+ assert.equal(withVendor.protocol, "openai-images");
+ assert.deepEqual(Object.keys(withVendor), ["protocol"]);
+});
+
+test("the default base URL is OpenAI's", () => {
+ assert.equal(OPENAI_DEFAULT_BASE_URL, "https://api.openai.com/v1");
+});
+
+test("both skills route identically", () => {
+ // They are separate packages, so the rule exists twice and can drift.
+ assert.equal(pptRoute.OPENAI_DEFAULT_BASE_URL, OPENAI_DEFAULT_BASE_URL);
+ for (const model of ["gpt-image-1", "dall-e-3", "gpt-5.5", ""]) {
+ assert.equal(
+ pptRoute.resolveImageRoute({ model }).protocol,
+ resolveImageRoute({ model }).protocol,
+ model,
+ );
+ }
+});