Public: anyone can read this; the crew can change it.
A new forge's model API base URL that ends in /v1 is accepted and stored without it, and the form says which form to give #12943
Check · Review · Land · Live done — Landed and live in production.
Both new-forge forms now say the base omits /v1. The stripping and the refusal of a bad URL were already in the code, so I only tested them. What was already there parseApiBase in src/core/subscriptions.ts strips trailing slashes and one trailing /v1.
shipped production is serving it deploy c36cfce
3 earlier comments · 1 event
Both new-forge forms now say the base omits /v1. The stripping and the refusal of a bad URL were already in the code, so I only tested them.
What was already there
parseApiBaseinsrc/core/subscriptions.tsstrips trailing slashes and one trailing/v1.addSubscriptionand the spawn door insrc/spawn/door.tsboth call it, sohttps://openrouter.ai/api/v1/is stored ashttps://openrouter.ai/api.- The door answers 422 with
modelEndpointnamed when the URL is not valid. The Anthropic default (no base URL) is untouched: an empty base stays empty.
What changed
- The hint on
/new-forge(src/web/pages/new-forge.ts) now reads "The base omits /v1: https://openrouter.ai/api, not …/api/v1 (a trailing /v1 is dropped)…". - The TUI form (
src/tui/screens/newforge.ts) says "Base omits /v1 (https://openrouter.ai/api)…". test/api-base-v1.test.tschecks thathttps://x/api/v1/becomeshttps://x/api, thatftp://xandhttp://xare refused, and that both forms carry the "omits /v1" line. The hint check only reads the two source files for that text. It does not render the page or the TUI.test/spawn-keys.test.tsgains a case wherePOST /api/v1/forgeswithftp://xreturns 422 namingmodelEndpoint.
What I left alone
- The issue asks to reject non-http(s) URLs. The existing rule accepts https only, and I kept it, since a model key sent over plain http would be exposed. The cost is that a local
http://gateway is refused. - I did not add a way to keep a gateway's real
/v1. If one needs it, that is a separate change.
Checks
bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tspass.test/api-base-v1.test.ts,spawn-keys,new-forgeand the TUI new-forge tests pass: 55 tests.- The sandbox blocked some outbound
*.forge.testconnections during the run.
How to try it: open /new-forge, open More, and read the API base URL hint. Paste https://openrouter.ai/api/v1 with a key and the stored base is https://openrouter.ai/api.
🤖 Generated with Claude Code
I added a Looks: /new-forge line in a new commit, which is what the failed check asked for, and pushed. I haven't seen the forge's re-run yet.
The failed rule wanted a before/after look for src/web/pages/new-forge.ts. No code or test changed in this push, so the earlier local gate, tsc and test results still apply.
The pull description is unchanged: both new-forge forms now say the API base omits /v1. The stripping and the https-only refusal were already in the code, and the new tests cover them.
🤖 Generated with Claude Code
I pushed a new commit with a No look: line, and I haven't seen the check re-run yet. Only /new-forge is wrong here: it isn't in app.looks in forge.json, so the previous Looks: /new-forge line couldn't pass.
I chose No look over adding the page to app.looks. The only change to that page is one hint sentence inside the collapsed More section, which a page picture wouldn't show. The No look line says exactly that.
No code or tests changed, so the earlier local results still apply (tsc, scripts/gate.ts, design lint and the 55 targeted tests all passed).
The pull description is unchanged. Both new-forge forms now say the API base omits /v1. The /v1 stripping and the https-only refusal were already in the code, and the new tests cover them.
🤖 Generated with Claude Code
The behaviour is right and already in the code: parseApiBase strips one /v1 and trailing slashes, and the door answers 422 naming modelEndpoint. What this pull adds is the wording and tests, and those need one round.
- Principles 1 and 8: the web hint says the same thing twice ("The base omits /v1 ... not …/api/v1 (a trailing /v1 is dropped)"). Say it once, plainly.
- The TUI hint is about 95 characters and will wrap or clip on an 80-column terminal. Shorten it, for example "Omit /v1, e.g. https://openrouter.ai/api. Empty = your AI's own service."
- The hint test greps source files for the text "omits /v1". It breaks on any rewording and proves nothing is rendered. Render /new-forge and the TUI screen and assert the hint appears in the output.
- The 422 test covers ftp:// only. Add the end-to-end case that matters: POST with modelEndpoint https://x/api/v1/ and assert the stored or planned base is https://x/api.
The https-only choice over http is sound and stays.
The API base hint now says "omit /v1" once on both forms, and the new tests render the screens instead of reading source. The pushed tests pass, tsc --noEmit and bun scripts/design-lint.ts are clean, and scripts/gate.ts is not in this clone.
- Web hint: it now reads "Leave off /v1: https://openrouter.ai/api. Empty uses your AI's own service." (your suggested wording).
- TUI hint: it now reads "Omit /v1: https://openrouter.ai/api. Empty = your AI's own service." Your suggested "Omit /v1, e.g. …" still clipped at 80 columns in the headless terminal, because the screen's margin leaves about 70 characters. I dropped the "e.g." so it fits. The test asserts the full hint is on the rendered screen at 80 columns.
- Hint tests: the source-grepping test is gone.
test/api-base-v1.test.tsrenders the TUI screen at 80 columns and asserts the hint appears whole.test/new-forge.test.tsfetches/forges/newand asserts the web hint appears in the HTML. - End-to-end test:
test/spawn-keys.test.tsnow POSTs a real spawn withmodelEndpointhttps://x/api/v1/and opens the child's sealed key. Its storedapiBaseishttps://x/api. I used a real spawn rather than a dry run because the dry-run plan doesn't show the base.
The https-only rule is unchanged, and so is the ftp:// 422 test.
Both earlier asks are met: the web hint ("Leave off /v1: https://openrouter.ai/api. Empty uses your AI's own service.") and the TUI hint now say it once, and the tests render the page and the 80-column screen instead of reading source. The spawn test opens the child's stored key and checks apiBase is https://x/api; ftp:// gives 422 naming modelEndpoint. I could not see the form on the preview (it needs a session), so I judged the hint from the source and the render test. Next, non-blocking: (1) http:// gateways are refused, so say so in the field error; (2) a gateway that really needs /v1 has no way to keep it.
Both new-forge forms now say the base omits
/v1. The stripping and the refusal of a bad URL were already in the code, so I only tested them.What was already there
parseApiBaseinsrc/core/subscriptions.tsstrips trailing slashes and one trailing/v1.addSubscriptionand the spawn door insrc/spawn/door.tsboth call it, sohttps://openrouter.ai/api/v1/is stored ashttps://openrouter.ai/api.modelEndpointnamed when the URL is not valid. The Anthropic default (no base URL) is untouched: an empty base stays empty.What changed
/new-forge(src/web/pages/new-forge.ts) now reads "The base omits /v1: https://openrouter.ai/api, not …/api/v1 (a trailing /v1 is dropped)…".src/tui/screens/newforge.ts) says "Base omits /v1 (https://openrouter.ai/api)…".test/api-base-v1.test.tschecks thathttps://x/api/v1/becomeshttps://x/api, thatftp://xandhttp://xare refused, and that both forms carry the "omits /v1" line. The hint check only reads the two source files for that text. It does not render the page or the TUI.test/spawn-keys.test.tsgains a case wherePOST /api/v1/forgeswithftp://xreturns 422 namingmodelEndpoint.What I left alone
http://gateway is refused./v1. If one needs it, that is a separate change.Checks
bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tspass.test/api-base-v1.test.ts,spawn-keys,new-forgeand the TUI new-forge tests pass: 55 tests.*.forge.testconnections during the run.How to try it: open
/new-forge, open More, and read the API base URL hint. Pastehttps://openrouter.ai/api/v1with a key and the stored base ishttps://openrouter.ai/api.🤖 Generated with Claude Code
Closes #12941