feat(design): honor OPENAI_BASE_URL for every design API call

One resolver, openaiUrl() in design/src/auth.ts, now builds every OpenAI
URL the design binary, its prototype and its live model check use. Setting
OPENAI_BASE_URL sends image generation and screenshot analysis to an
OpenAI-compatible gateway; unset or blank keeps api.openai.com. The
prototype script now goes through receiptedFetch, so its egress is
receipted like the rest, and receipts already record the gateway host.

A source scan keeps any design file outside auth.ts from hardcoding an
OpenAI API URL again, and a request-shape test proves the gateway reaches
both the vision and image endpoints.

Co-authored-by: JackJin <1037461232@qq.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
committed 2026-10-08 14:52:38 +00:00
1 parent 0668443f36
commit b150736602
14 files changed
+83 -23

No files matched your search

+3 -2
View File
@@ -22,6 +22,7 @@ import {
imageToolModel,
visionRequestBody,
} from "../src/models";
import { openaiUrl } from "../src/auth";
import { receiptedFetch } from "../src/receipted-fetch";
const TINY_PNG = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkAAIAAAoAAv/lxKUAAAAASUVORK5CYII=";
@@ -78,7 +79,7 @@ let image = TINY_PNG;
failed = true;
}
if (body) {
const r = await post("live-check-image-request", "https://api.openai.com/v1/responses", body, 240_000);
const r = await post("live-check-image-request", openaiUrl("responses"), body, 240_000);
const item = r.json?.output?.find((o: any) => o.type === "image_generation_call");
const pass = r.ok && typeof item?.result === "string" && item.result.length > 0;
if (pass) image = item.result;
@@ -101,7 +102,7 @@ let image = TINY_PNG;
{ type: "text", text: "Reply with exactly one word: PASS." },
],
}], 20);
const r = await post("live-check-vision-request", "https://api.openai.com/v1/chat/completions", body, 120_000);
const r = await post("live-check-vision-request", openaiUrl("chat/completions"), body, 120_000);
const choice = r.json?.choices?.[0];
const content = String(choice?.message?.content ?? "").trim();
const pass = r.ok && content.length > 0;