chore(cli): retire nano-banana-2 and gpt-image-2.5 from media-use generate (#8314)

* chore(cli): retire nano-banana-2 and gpt-image-2.5 from media-use generate

Both have a newer model that replaces them. Asking for either now stops before any
request is sent and names the model to use instead. The price table, the --model help
and the media-use skill reference no longer list them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* chore(cli): drop a redundant comment

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* fix(cli): check a media-use generate request before pricing it

A request the command would refuse is refused with its own message, whether or
not --max-credits is given.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
James Russo
2026-11-20 20:28:52 +00:00
committed by GitHub
co-authored by Claude Fable 5.2
parent aa05198583
commit 5e1008124b
7 changed files with 72 additions and 33 deletions
@@ -0,0 +1,40 @@
import { mkdtempSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("../../cloud/auth.js", () => ({
resolveCloudAuthHeaders: async () => ({ "x-api-key": "k" }),
refreshIfNeeded: async <T>(credential: T) => credential,
resolveCloudBaseUrl: () => "https://api.test",
}));
const { default: generate } = await import("./generate.js");
beforeEach(() => {
vi.stubEnv("HYPERFRAMES_CONFIG_DIR", mkdtempSync(join(tmpdir(), "hf-generate-test-")));
});
afterEach(() => {
vi.unstubAllGlobals();
vi.unstubAllEnvs();
vi.restoreAllMocks();
});
describe("media-use generate", () => {
it.each([
["nano-banana-2", "nano-banana-2.1"],
["gpt-image-2.5", "gpt-image-2.6"],
])("names %s's replacement even with --max-credits, and sends nothing", async (model, next) => {
const fetched = vi.fn();
vi.stubGlobal("fetch", fetched);
const out: string[] = [];
vi.spyOn(console, "log").mockImplementation((line: string) => void out.push(line));
const args = { type: "image", prompt: "a cup", out: "cup.png", model, "max-credits": "50" };
await expect(generate.run!({ args, rawArgs: [] } as never)).rejects.toThrow("Command failed");
const printed = JSON.parse(out.join("\n"));
expect(printed.ok).toBe(false);
expect(printed.error).toBe(`${model} is no longer offered here`);
expect(printed.fix).toBe(`--model ${next}`);
expect(fetched).not.toHaveBeenCalled();
});
});
@@ -131,7 +131,7 @@ export default defineCommand({
model: {
type: "string",
description:
"image: nano-banana-2.1 (default), nano-banana-2, gpt-image-2.5, gpt-image-2.6, gpt-image-2.6-flare, minimax-h3-image (2K) or minimax-h3-image-4k",
"image: nano-banana-2.1 (default), gpt-image-2.6, gpt-image-2.6-flare, minimax-h3-image (2K) or minimax-h3-image-4k",
},
bpm: { type: "string", description: "music: tempo, 60–180" },
vocals: {
@@ -182,10 +182,10 @@ export default defineCommand({
};
const voice = await voiceFor(request);
if (voice) request.voice = voice.voice_id;
checkRequest(request);
const price = priceOf(request);
const credits = creditsOf(price);
if (args.plan) {
checkRequest(request);
return {
plan: true,
type,
+14 -16
View File
@@ -161,7 +161,7 @@ describe("generate", () => {
type: "image",
out: join(project, "assets/charged.png"),
prompt: "a charged picture",
model: "gpt-image-2.5",
model: "gpt-image-2.6",
});
expect(r.charged_credits).toBe(41);
expect(readFileSync(join(project, ".media/manifest.jsonl"), "utf8")).toContain(
@@ -182,7 +182,7 @@ describe("generate", () => {
type: "image",
out: join(dir, "assets/limited.png"),
prompt: "a limited picture",
model: "gpt-image-2.5",
model: "gpt-image-2.6",
aspect: "16:9",
} as const;
return generate(request, undefined, creditsOf(priceOf(request)) ?? undefined);
@@ -250,7 +250,7 @@ describe("generate", () => {
type: "image",
out: join(project, "assets/api-charged.png"),
prompt: "an api-charged picture",
model: "gpt-image-2.5",
model: "gpt-image-2.6",
});
expect(r).not.toHaveProperty("charged_credits");
});
@@ -893,7 +893,7 @@ describe("generate", () => {
priceOf({
type: "image",
out: "a.png",
model: "gpt-image-2.5",
model: "gpt-image-2.6",
aspect: "1:1",
references: ["a", "b"],
}).usd,
@@ -905,7 +905,7 @@ describe("generate", () => {
it("prices every reference picture of a GPT Image edit, on each GPT Image model", () => {
const edit = (model: string, references: string[]) =>
creditsOf(priceOf({ type: "image", out: "a.png", model, aspect: "16:9", references }));
for (const model of ["gpt-image-2.5", "gpt-image-2.6", "gpt-image-2.6-flare"]) {
for (const model of ["gpt-image-2.6", "gpt-image-2.6-flare"]) {
expect(edit(model, [])).toBe(66);
expect(edit(model, ["a"])).toBe(87);
expect(
@@ -925,9 +925,9 @@ describe("generate", () => {
it("says a GPT Image price is an estimate charged on the vendor's bill, and a Nano Banana one is not", () => {
expect(
priceOf({ type: "image", out: "a.png", model: "gpt-image-2.5", aspect: "16:9" }).basis,
priceOf({ type: "image", out: "a.png", model: "gpt-image-2.6", aspect: "16:9" }).basis,
).toBe(
"gpt-image-2.5 at 16:9, about 66 credits (charged on the vendor's bill), with about $0.0125 a reference; vendor price x1.5 on an API key, x1.6545 in HyperFrames credits",
"gpt-image-2.6 at 16:9, about 66 credits (charged on the vendor's bill), with about $0.0125 a reference; vendor price x1.5 on an API key, x1.6545 in HyperFrames credits",
);
expect(priceOf({ type: "image", out: "a.png" }).basis).toBe(
"nano-banana-2.1, $0.0336 an image and $0.00168 a reference; vendor price x1.5 on an API key, x1.6545 in HyperFrames credits",
@@ -982,8 +982,7 @@ describe("generate", () => {
const rows: [string, string, number][] = [
["gpt-image-2.6", "1:1", 87.15906],
["gpt-image-2.6-flare", "16:9", 65.5182],
["gpt-image-2.5", "4:3", 59.76054],
["nano-banana-2", "21:9", 110.8515],
["gpt-image-2.6", "4:3", 59.76054],
["nano-banana-2.1", "3:2", 55.5912],
];
for (const [model, aspect, row] of rows)
@@ -994,9 +993,6 @@ describe("generate", () => {
expect(
image("nano-banana-2.1", "1:1", 1).credits! - image("nano-banana-2.1", "1:1").credits!,
).toBeCloseTo(2.77956, 6);
expect(image("nano-banana-2", "1:1", 3).credits).toBe(image("nano-banana-2", "1:1").credits);
expect(image("nano-banana-2", "1:1").list).toBeCloseTo(0.1005, 9);
expect(image("nano-banana-2", "1:1").usd).toBe(0.12);
expect(image("gpt-image-2.6", "16:9").list).toBeCloseTo(0.0594, 9);
expect(image("gpt-image-2.6", "16:9").usd).toBe(0.07);
expect(image("nano-banana-2.1", "16:9", 2).list).toBeCloseTo((0.0336 + 2 * 0.00168) * 1.5, 9);
@@ -1027,7 +1023,9 @@ describe("generate", () => {
}
expect(check("gpt-image-2.6", "21:9")).toThrow("gpt-image-2.6 does not make 21:9");
expect(check("nano-banana-2.1", "21:9")).not.toThrow();
expect(check("nano-banana-2", undefined, 15)).toThrow("at most 14 --reference pictures");
expect(check("nano-banana-2.1", undefined, 15)).toThrow("at most 14 --reference pictures");
expect(check("nano-banana-2")).toThrow("nano-banana-2 is no longer offered here");
expect(check("gpt-image-2.5", "16:9")).toThrow("gpt-image-2.5 is no longer offered here");
expect(check("some-new-model", "7:5")).not.toThrow();
});
@@ -1194,16 +1192,16 @@ describe("generate", () => {
it("keeps 10% headroom under the limit for an image charged on the vendor's bill", () => {
const limited = (request: GenerateRequest, limit: number) => () =>
checkLimit(creditsOf(priceOf(request)), limit, isVendorPriced(request));
const gpt = { type: "image", out: "a.png", model: "gpt-image-2.5", aspect: "16:9" } as const;
const gpt = { type: "image", out: "a.png", model: "gpt-image-2.6", aspect: "16:9" } as const;
expect(creditsOf(priceOf(gpt))).toBe(66);
expect(limited(gpt, 66)).toThrow(
"about 66 credits, 73 with 10% headroom because it is charged on the vendor's bill, over --max-credits 66",
);
expect(limited(gpt, 72)).toThrow("73 with 10% headroom");
expect(limited(gpt, 73)).not.toThrow();
const nano = { type: "image", out: "a.png", model: "nano-banana-2" } as const;
const nano = { type: "image", out: "a.png", model: "nano-banana-2.1" } as const;
expect(isVendorPriced(nano)).toBe(false);
expect(limited(nano, 111)).not.toThrow();
expect(limited(nano, 56)).not.toThrow();
});
});
+6 -3
View File
@@ -169,7 +169,6 @@ const DEFAULTS = {
music: "lyria-3-pro",
} as const;
export const VENDOR_PRICED_IMAGES = new Set([
"gpt-image-2.5",
"gpt-image-2.6",
"gpt-image-2.6-flare",
"minimax-h3-image",
@@ -180,14 +179,16 @@ const GEMINI_ASPECTS = [...GPT_ASPECTS, "3:2", "2:3", "21:9"];
const MINIMAX_ASPECTS = [...GPT_ASPECTS, "21:9"];
/** What /v3/images accepts from each model: its aspect ratios and how many reference pictures. */
const IMAGE_MODELS: Record<string, { aspects: string[]; references: number }> = {
"nano-banana-2": { aspects: GEMINI_ASPECTS, references: 14 },
"nano-banana-2.1": { aspects: GEMINI_ASPECTS, references: 14 },
"gpt-image-2.5": { aspects: GPT_ASPECTS, references: 16 },
"gpt-image-2.6": { aspects: GPT_ASPECTS, references: 16 },
"gpt-image-2.6-flare": { aspects: GPT_ASPECTS, references: 16 },
"minimax-h3-image": { aspects: MINIMAX_ASPECTS, references: 16 },
"minimax-h3-image-4k": { aspects: MINIMAX_ASPECTS, references: 16 },
};
const RETIRED_IMAGE_MODELS: Record<string, string> = {
"nano-banana-2": "nano-banana-2.1",
"gpt-image-2.5": "gpt-image-2.6",
};
export const isVendorPriced = (r: GenerateRequest): boolean =>
r.type === "image" && VENDOR_PRICED_IMAGES.has(r.model ?? "");
const VIDEO_RESOLUTION = "768p";
@@ -203,6 +204,8 @@ const need = <T>(value: T | undefined, flag: string, example: string): T => {
function imageModel(r: GenerateRequest): string {
const model = r.model ?? DEFAULTS.image;
const replacement = RETIRED_IMAGE_MODELS[model];
if (replacement) throw new Fix(`${model} is no longer offered here`, `--model ${replacement}`);
const spec = IMAGE_MODELS[model];
if (!spec) return model;
if (r.aspect && !spec.aspects.includes(r.aspect))
-2
View File
@@ -32,7 +32,6 @@ const GPT_IMAGE: Record<string, number> = {
"3:4": 0.03612,
};
const GPT_REFERENCE = 0.0125;
const NANO_IMAGE = 0.067;
const NANO_2_1_IMAGE = 0.0336;
const NANO_2_1_REFERENCE = 0.00168;
const MINIMAX_IMAGE: Record<string, number> = {
@@ -77,7 +76,6 @@ export function priceOf(r: GenerateRequest): Price {
case "image": {
const refs = r.references?.length ?? 0;
const model = r.model ?? "nano-banana-2.1";
if (model === "nano-banana-2") return image(NANO_IMAGE, "nano-banana-2, $0.067 an image");
if (model === "nano-banana-2.1")
return image(
NANO_2_1_IMAGE + refs * NANO_2_1_REFERENCE,