Files
OmniRoute/tests/unit/cheaperinference-image-models.test.ts
Diego Rodrigues de Sa e Souza 371c10ea5f feat(sse): Cheaper Inference provider — chat + native Responses + images, sponsor rail 2nd (#9043)
Registers Cheaper Inference (api.cheaperinference.com) as an OSS-sponsor gateway provider.

- Canonical provider `cheaperinference` (alias `cinf`) + routing registry with 39 measured text models
- Dedicated executor: forces `store:false` on the native /v1/responses endpoint (the shared strip in
  chatCore.ts deletes `store` for every provider != openai, so without this every Responses request
  400'd) and resolves chat-vs-responses URL from the per-model targetFormat
- 3 image models (grok-imagine, nano-banana-pro, nano-banana-2), prefix-only: the two nano-banana ids
  already belong to adobe-firefly, which keeps the bare-id routing
- Resale pricing measured from GET /v1/models (30% off list); sponsor rail Kimi 1st / Cheaper
  Inference 2nd via an explicit rank map; supporter badge in 43 locales; README row

No quota card: the gateway exposes no balance API (/v1/wallet and /v1/balance both 404).

Validated live end-to-end through OmniRoute: chat, native Responses, streaming and image generation
all 200 with real content; the Firefly collision guard verified at runtime.
2026-07-31 07:53:41 -03:00

54 lines
2.5 KiB
TypeScript

// Cheaper Inference image models + the Adobe Firefly collision guard.
//
// nano-banana-pro / nano-banana-2 exist in BOTH providers. parseImageModel resolves a
// bare id by first-match over IMAGE_PROVIDERS iteration order, so the bare ids must
// keep going to adobe-firefly (pre-existing behaviour) and Cheaper Inference must be
// reachable only via its prefix. Operator decision 2026-07-31.
import { test } from "node:test";
import assert from "node:assert/strict";
import { IMAGE_PROVIDERS, parseImageModel } from "@omniroute/open-sse/config/imageRegistry.ts";
test("cheaperinference is registered as an image provider with the 3 measured models", () => {
const provider = IMAGE_PROVIDERS.cheaperinference;
assert.ok(provider, "cheaperinference missing from IMAGE_PROVIDERS");
assert.equal(provider.baseUrl, "https://api.cheaperinference.com/v1/images/generations");
assert.equal(provider.authType, "apikey");
assert.equal(provider.authHeader, "bearer");
assert.equal(provider.format, "openai");
assert.equal(provider.alias, "cinf");
const ids = provider.models.map((m) => m.id).sort();
assert.deepEqual(ids, ["grok-imagine", "nano-banana-2", "nano-banana-pro"]);
});
test("prefixed ids resolve to cheaperinference", () => {
assert.deepEqual(parseImageModel("cheaperinference/nano-banana-2"), {
provider: "cheaperinference",
model: "nano-banana-2",
});
assert.deepEqual(parseImageModel("cinf/grok-imagine"), {
provider: "cheaperinference",
model: "grok-imagine",
});
});
test("REGRESSION GUARD: bare nano-banana ids still route to adobe-firefly", () => {
// If this flips to cheaperinference, someone added an IMAGE_MODEL_ALIASES entry
// (forbidden) or declared cheaperinference before adobe-firefly in IMAGE_PROVIDERS.
assert.equal(parseImageModel("nano-banana-2").provider, "adobe-firefly");
assert.equal(parseImageModel("nano-banana-pro").provider, "adobe-firefly");
});
test("cheaperinference image models are NOT in the chat registry", async () => {
const { REGISTRY } = await import("@omniroute/open-sse/config/providers/index.ts");
const chatIds = new Set(
(REGISTRY.cheaperinference as unknown as { models: Array<{ id: string }> }).models.map(
(m) => m.id
)
);
// Upstream returns HTTP 400 for these on /v1/chat/completions:
// "…is an image-generation model. Use POST /v1/images/generations."
for (const id of ["grok-imagine", "nano-banana-2", "nano-banana-pro"]) {
assert.ok(!chatIds.has(id), `${id} must not be routable as a chat model`);
}
});