Files
OmniRoute/tests/unit/chenzk-provider-2437.test.ts
Diego Rodrigues de Sa e Souza ea32dcf863 feat(provider): add Chenzk API OpenAI-compatible gateway (#7246)
* feat(provider): add Chenzk API OpenAI-compatible gateway

Registers Chenzk (chenzk.top) as a new API-key gateway provider — an
OpenAI-compatible aggregator exposing GPT/Claude/DeepSeek/GLM model groups
behind one endpoint. Adapted to OmniRoute's directory-per-provider registry
(open-sse/config/providers/registry/) and metadata catalog
(src/shared/constants/providers/apikey/gateways.ts), following the same
passthrough-models pattern already used for kenari/x5lab/sumopod (live
/v1/models catalog resolves the model list instead of a hardcoded array).

Co-authored-by: Ahmad Putra Cahyo <CahyokPutraDev99@users.noreply.github.com>
Inspired-by: https://github.com/decolua/9router/pull/2437

* chore(changelog): fragment for #7246

* test(provider): regen golden snapshot + bump family-count for Chenzk gateway

The Chenzk provider added in a616b88c9 registered a new APIKEY_PROVIDERS
entry (gateways.ts) but did not update the two characterization tests
that assert exact provider counts: the translate-path golden snapshot
(missing the chenzk entry) and the 167-entry family-merge count in
providers-constants-split.test.ts (now 168, verified as a strict
partition sum across the 6 family files, no loss/dup).

Co-authored-by: Ahmad Putra Cahyo <CahyokPutraDev99@users.noreply.github.com>

---------

Co-authored-by: Ahmad Putra Cahyo <CahyokPutraDev99@users.noreply.github.com>
2026-07-17 10:40:49 -03:00

50 lines
2.3 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
const { APIKEY_PROVIDERS } = await import("../../src/shared/constants/providers.ts");
const { PROVIDER_ENDPOINTS } = await import("../../src/shared/constants/config.ts");
const { REGISTRY: providerRegistry } = await import("../../open-sse/config/providerRegistry.ts");
const CHENZK_CHAT_URL = "https://chenzk.top/v1/chat/completions";
const CHENZK_MODELS_URL = "https://chenzk.top/v1/models";
// Port of decolua/9router#2437 ("feat: add Chenzk API provider"), adapted to
// OmniRoute's directory-per-provider registry (`open-sse/config/providers/registry/`)
// and the `src/shared/constants/providers/apikey/*` metadata catalog, instead of
// upstream's flat `open-sse/providers/registry/*.js` + hardcoded model array. Chenzk
// exposes a "New API"-style OpenAI-compatible gateway with a live /v1/models catalog,
// so — matching the sibling kenari/x5lab/sumopod gateways already in this catalog —
// models are resolved via passthrough rather than a speculative hardcoded list.
test("Chenzk is registered as an OpenAI-compatible API-key gateway", () => {
const entry = APIKEY_PROVIDERS.chenzk;
assert.ok(entry, "APIKEY_PROVIDERS.chenzk must be defined");
assert.equal(entry.id, "chenzk");
assert.equal(entry.alias, "chenzk");
assert.equal(entry.name, "Chenzk API");
assert.equal(entry.website, "https://chenzk.top");
assert.equal(entry.passthroughModels, true);
});
test("Chenzk exposes the OpenAI-compatible chat completions endpoint", () => {
assert.equal(PROVIDER_ENDPOINTS.chenzk, CHENZK_CHAT_URL);
});
test("Chenzk registry entry uses OpenAI format with bearer API-key auth and passthrough models", () => {
const entry = providerRegistry.chenzk;
assert.ok(entry, "providerRegistry.chenzk must be defined");
assert.equal(entry.id, "chenzk");
assert.equal(entry.alias, "chenzk");
assert.equal(entry.format, "openai");
assert.equal(entry.executor, "default");
assert.equal(entry.authType, "apikey");
assert.equal(entry.authHeader, "bearer");
assert.equal(entry.baseUrl, CHENZK_CHAT_URL);
assert.equal(entry.modelsUrl, CHENZK_MODELS_URL);
assert.equal(entry.passthroughModels, true);
assert.deepEqual(
entry.models,
[],
"Chenzk ships no speculative seeded models — live catalog via passthrough only"
);
});