Skip to content

refactor(models): read model metadata from the live catalog - #20

Open
Dankosik wants to merge 1 commit into
mainfrom
feat/add-deepseek-v4-flash-0731
Open

refactor(models): read model metadata from the live catalog#20
Dankosik wants to merge 1 commit into
mainfrom
feat/add-deepseek-v4-flash-0731

Conversation

@Dankosik

@Dankosik Dankosik commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

What changed

This PR originally hardcoded a new model into the CLI. That approach is replaced: the CLI now reads
model metadata from the live catalog instead of carrying a copy of it.

Hardcoded before

  • src/commands/init.ts: export const DEFAULT_MODEL_ID = 'deepseek-ai/deepseek-v4-flash-0731',
    plus a doc comment asserting its 400K context window.
  • The generated .env template wrote # GONKAGATE_MODEL=deepseek-ai/deepseek-v4-flash-0731.
  • README.md named the same id twice as the suggested default, once with "400K context".

Every one of those is gone. Nothing in src/ or README.md names a model id or a context window
any more.

Read live now

GET /v1/models is the only source of truth for the catalog.

  • gonkagate models renders the live context window in a new context column, and prints each
    model's display name and description under --verbose when the gateway provides them. --json
    already carried contextLength/name/description; that is unchanged.
  • Default model = models[0], the first entry in response order. It is printed as
    Default model: <id> (first entry returned by /v1/models) and exposed as a new top-level
    defaultModel field in --json. There is no client-side sort, ranking or preference heuristic,
    and no hardcoded default id.
  • gonkagate init runs before an API key exists, so it genuinely cannot fetch the catalog. Rather
    than guess, the template now leaves GONKAGATE_MODEL commented and unset and points the user
    at gonkagate models. This is the one place metadata could not be read live, and the honest
    answer there is to name nothing.

Behaviour against a gateway that has NOT shipped gonka-proxy#70

The fallback path is the default path, not an afterthought. Against today's gateway, which returns
only id/object/created/owned_by:

field absent or null behaviour
context_length / contextLength either column prints n/a; key omitted from --json. Never 0, never null.
name either model stays listed by its id; no name: line in --verbose.
description either omitted entirely.

context_length and contextLength are both accepted (pre-existing tolerance, kept). Only id is
required; a model without one is skipped, and an empty list is still the existing MODELS_ERROR.
defaultModel needs nothing beyond id, so it works on today's gateway too.

Four new tests/models.integration.test.ts cases prove both sides: an ids-only response, an enriched
response, an explicit all-null response, and response-order-defines-the-default (asserted in both
directions so a hidden sort would fail).

Kept from the original approach

The cwd option on init and its integration test, and the removal of the dead llama-3.1-70b
placeholder from the .env template.

Validation

Run locally on Node 20+, all from a clean npm ci:

command result
npm ci --no-audit --no-fund pass - 183 packages
npm run format:check pass - all matched files use Prettier code style
npm run lint pass - no findings
npm run typecheck pass - no errors
npm test pass - 9 files, 54 tests (was 47 on main)
npm run build pass - dist/cli.js 58.24 KB
npm run ci pass - the full chain above

Also verified by hand against a local stub gateway, in both shapes:

Default model: deepseek-ai/deepseek-v4-flash-0731 (first entry returned by /v1/models)

model                                  context  network/1M    fee/1M        total/1M
deepseek-ai/deepseek-v4-flash-0731      400000  $0.012300     $0.001230     $0.013530
  name: DeepSeek V4 Flash 0731
moonshotai/kimi-k2.6                    240000  $0.012300     $0.001230     $0.013530
minimaxai/minimax-m2.7                     n/a  $0.012300     $0.001230     $0.013530

and with the enriched fields stripped (today's gateway), where every row reads n/a and the command
still exits 0.

Notes

  • The branch was squashed and force-pushed. The old feat(models): add DeepSeek V4 Flash 0731 as the default GonkaGate model commit was removed on purpose: this repo merges with merge commits
    enabled and release-please builds CHANGELOG.md from commit subjects, so leaving it would have
    published a release note for a change that no longer exists.
  • Stale qwen/qwen3-235b-a22b-instruct-2507-fp8 and llama-3.1-* references in docs/ and in
    unrelated test fixtures are untouched; they are sample data, not a catalog the CLI reads.

🤖 Generated with Claude Code

@Dankosik
Dankosik requested a review from a team as a code owner August 18, 2026 12:12
Drop the hardcoded default model id and read ids, display names,
descriptions and context windows from GET /v1/models instead. `init` runs
before an API key exists, so it names no model and points at `gonkagate
models`, which now prints the live context window and the first catalog
entry as the default. Absent or null enrichment fields degrade to `n/a`
or are omitted, so gateways that do not publish them yet keep working.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Dankosik
Dankosik force-pushed the feat/add-deepseek-v4-flash-0731 branch from e97a6fe to 8ba7371 Compare August 18, 2026 12:56
@Dankosik Dankosik changed the title feat(models): add DeepSeek V4 Flash 0731 as the default GonkaGate model refactor(models): read model metadata from the live catalog Aug 18, 2026
@Dankosik

Copy link
Copy Markdown
Contributor Author

Reworked: the hardcoding approach in this PR has been replaced with live model metadata.

Why. The earlier revision added the model by writing
DEFAULT_MODEL_ID = 'deepseek-ai/deepseek-v4-flash-0731' into src/commands/init.ts, baking that id
into the generated .env, and repeating it (plus "400K context") twice in the README. That makes the
CLI a second, stale copy of a catalog the gateway already publishes: every catalog change would need
a release here, and in between the CLI would confidently suggest a model that may no longer exist.
GET /v1/models is the source of truth, so the CLI should read it.

What replaced it. gonkagate models now renders the live context window in a context column
and the live display name and description under --verbose, and it reports the default as
models[0] - the first entry in response order, exposed as defaultModel in --json. No hardcoded
default id, no client-side sort or preference heuristic. src/ and README.md no longer contain any
model id or context window.

init is the honest exception. It runs before an API key exists, so it cannot call the catalog.
Instead of guessing, the template now leaves GONKAGATE_MODEL commented and unset and points at
gonkagate models. A test asserts the template names no model.

Compatibility. gonka-proxy#70 is merged but not deployed, so this had to work against today's
gateway first. name, description and context_length are all treated as possibly absent or
null: the context window falls back to n/a in the table and is omitted from --json (never 0,
never null), a missing name leaves the model listed by its id, and a missing description is
dropped. Both context_length and contextLength are still accepted. Four new integration tests
cover the ids-only gateway, the enriched gateway, an all-null response, and response-order-defines-
the-default in both directions.

npm run ci passes end to end (format, lint, typecheck, 54 tests, build); details in the PR body.

The branch was squashed and force-pushed so the superseded feat(models): add DeepSeek V4 Flash 0731
commit does not reach main and generate a false release-please changelog entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant