feat(providers): add Baseten Model APIs preset - #653
Conversation
📝 WalkthroughWalkthroughThis PR adds bounded, registry-driven provider model discovery, transport-aware registry matching, and the Baseten Model APIs preset. It integrates discovery into catalog loading, API-key validation, routing, management probes, tests, and multilingual documentation. ChangesProvider discovery and registry integration
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs-site/src/content/docs/ru/reference/configuration.md (1)
166-166: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winRussian docs missing the new collision-preservation
baseUrlbehavior that zh-cn received.
docs-site/src/content/docs/zh-cn/reference/configuration.mdwas updated in this same PR (lines 138 and 184-190) to document that newly-added, collision-protected fixed API-key presets (like Baseten) preserve an existing same-named custom provider'sbaseUrl/adapter instead of redirecting it to the new registry host. This Russian page'sbaseUrlrow (line 166) and its "fixed provider endpoints" section (unchanged lines 209-278) were not updated to match, leaving ru readers with an incomplete/outdated description ofbaseUrloverride precedence — directly contradicting the path-instruction requirement that "translated locale pages ... are not left contradicting the English source."As per path instructions,
docs-site/**guidance requires that "translated locale pages (ja, ko, ru, zh-cn) are not left contradicting the English source."📝 Suggested ru addition (adapt zh-cn wording)
-| `baseUrl` | `string` | Базовый URL вышестоящего API. | +| `baseUrl` | `string` | Базовый URL вышестоящего API. Большинство встроенных provider с фиксированными конечными точками игнорируют несовпадающий адрес; новые пресеты с ключевой аутентификацией, включающие защиту от коллизий, сохраняют цель ранее существовавшего custom provider с тем же именем. См. [Фиксированные конечные точки провайдера](`#фиксированные-конечные-точки-провайдера`). |And extend the "fixed endpoint" section (wherever it lives in the unchanged 209-278 range) with a fourth bullet mirroring zh-cn lines 189-190.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs-site/src/content/docs/ru/reference/configuration.md` at line 166, Update the Russian configuration documentation to match the English and zh-cn descriptions of collision-protected fixed API-key presets: clarify in the baseUrl documentation that an existing same-named custom provider preserves its baseUrl and adapter, then add the corresponding fourth bullet to the fixed provider endpoints section. Keep the wording consistent with the existing Russian terminology and zh-cn guidance.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs-site/src/content/docs/guides/providers.md`:
- Around line 222-226: Remove the blank line inside the synchronized Baseten
blockquotes at docs-site/src/content/docs/guides/providers.md lines 222-226,
docs-site/src/content/docs/ja/guides/providers.md lines 156-160, and
docs-site/src/content/docs/ko/guides/providers.md lines 156-160, keeping each
blockquote contiguous.
In `@docs-site/src/content/docs/ru/getting-started/quickstart.md`:
- Around line 16-17: Update the provider-selection sentence to use the correct
Russian numeral agreement, changing “один из 61 встроенного пресета” to “один из
61 встроенных пресетов” while preserving the rest of the quickstart content.
In `@src/providers/model-discovery.ts`:
- Around line 273-280: Add documentation to the predicate union declaration in
the registry module describing the `containsAny` and `containsAll` semantics:
string upstream values use substring matching, while array values use exact
element matching. Keep the existing comparison behavior in the `containsAny` and
`containsAll` branches of model discovery unchanged; only make this contract
clear for registry authors.
---
Outside diff comments:
In `@docs-site/src/content/docs/ru/reference/configuration.md`:
- Line 166: Update the Russian configuration documentation to match the English
and zh-cn descriptions of collision-protected fixed API-key presets: clarify in
the baseUrl documentation that an existing same-named custom provider preserves
its baseUrl and adapter, then add the corresponding fourth bullet to the fixed
provider endpoints section. Keep the wording consistent with the existing
Russian terminology and zh-cn guidance.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6f2e0626-310e-41e7-b32d-b92ab1438d20
📒 Files selected for processing (35)
docs-site/src/content/docs/getting-started/quickstart.mddocs-site/src/content/docs/guides/providers.mddocs-site/src/content/docs/ja/getting-started/quickstart.mddocs-site/src/content/docs/ja/guides/providers.mddocs-site/src/content/docs/ja/reference/configuration.mddocs-site/src/content/docs/ko/getting-started/quickstart.mddocs-site/src/content/docs/ko/guides/providers.mddocs-site/src/content/docs/ko/reference/configuration.mddocs-site/src/content/docs/reference/configuration.mddocs-site/src/content/docs/ru/getting-started/quickstart.mddocs-site/src/content/docs/ru/guides/providers.mddocs-site/src/content/docs/ru/reference/configuration.mddocs-site/src/content/docs/zh-cn/getting-started/quickstart.mddocs-site/src/content/docs/zh-cn/guides/providers.mddocs-site/src/content/docs/zh-cn/reference/configuration.mdsrc/codex/catalog/parsing.tssrc/codex/catalog/provider-fetch.tssrc/oauth/index.tssrc/oauth/key-providers.tssrc/oauth/login-cli.tssrc/providers/derive.tssrc/providers/model-discovery.tssrc/providers/registry.tssrc/router.tssrc/server/auth-cors.tssrc/server/management/provider-routes.tssrc/server/management/shared.tsstructure/01_runtime.mdtests/baseten-provider.test.tstests/codex-catalog.test.tstests/fixtures/baseten-models.jsontests/fixtures/provider-model-discovery.jsontests/provider-model-discovery-contract.test.tstests/provider-registry-parity.test.tstests/umans-provider.test.ts
7faf2e4 to
124f427
Compare
|
Review follow-up for the outside-diff Russian collision-preservation finding: that review was anchored to the old |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/codex/catalog/provider-fetch.ts (1)
219-239: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPrioritize canonical capability flags before truncation.
If
capabilities/featuresalready contributes 32 values, the latersupports_toolsandsupports_reasoningadditions are removed byslice(0, 32). A valid upstream boolean can therefore be omitted from the catalog. Add canonical flags before untrusted labels, or cap generic additions while reserving capacity.Proposed fix
function modelCapabilities(item: ProviderModelsApiItem): string[] | undefined { const metadata = plainRecord(item.metadata); const metadataCapabilities = metadata?.capabilities; const capabilityRecord = plainRecord(metadataCapabilities) ?? plainRecord(item.capabilities); const out = new Set<string>(); + for (const field of ["supports_tools", "supports_tool_calling", "supports_function_calling"] as const) { + if (item[field] === true) out.add("tools"); + } + for (const field of ["supports_reasoning", "reasoning"] as const) { + if (item[field] === true) out.add("reasoning"); + } for (const list of [item.capabilities, item.features, item.supported_features, metadataCapabilities]) { - for (const capability of normalizedStringList(list) ?? []) out.add(capability); + for (const capability of normalizedStringList(list) ?? []) { + if (out.size >= 32) break; + out.add(capability); + } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/codex/catalog/provider-fetch.ts` around lines 219 - 239, Update the capability aggregation flow so canonical boolean-derived values from supports_tools/supports_tool_calling/supports_function_calling and supports_reasoning/reasoning are added before generic capabilities and metadata labels. Preserve the 32-value limit while ensuring these canonical “tools” and “reasoning” values are retained when present, then add untrusted labels only with remaining capacity.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs-site/src/content/docs/ja/guides/providers.md`:
- Around line 156-160: Remove the blank separator between the consecutive
Baseten and Tencent blockquotes in
docs-site/src/content/docs/ja/guides/providers.md lines 156-160 and
docs-site/src/content/docs/ko/guides/providers.md lines 156-160, keeping the
blockquote lines contiguous to satisfy markdownlint MD028.
---
Outside diff comments:
In `@src/codex/catalog/provider-fetch.ts`:
- Around line 219-239: Update the capability aggregation flow so canonical
boolean-derived values from
supports_tools/supports_tool_calling/supports_function_calling and
supports_reasoning/reasoning are added before generic capabilities and metadata
labels. Preserve the 32-value limit while ensuring these canonical “tools” and
“reasoning” values are retained when present, then add untrusted labels only
with remaining capacity.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a890a1e3-1a47-4f3d-a121-0a23983f7ff4
📒 Files selected for processing (24)
docs-site/src/content/docs/getting-started/quickstart.mddocs-site/src/content/docs/guides/providers.mddocs-site/src/content/docs/ja/getting-started/quickstart.mddocs-site/src/content/docs/ja/guides/providers.mddocs-site/src/content/docs/ja/reference/configuration.mddocs-site/src/content/docs/ko/getting-started/quickstart.mddocs-site/src/content/docs/ko/guides/providers.mddocs-site/src/content/docs/ko/reference/configuration.mddocs-site/src/content/docs/reference/configuration.mddocs-site/src/content/docs/ru/getting-started/quickstart.mddocs-site/src/content/docs/ru/guides/providers.mddocs-site/src/content/docs/ru/reference/configuration.mddocs-site/src/content/docs/zh-cn/getting-started/quickstart.mddocs-site/src/content/docs/zh-cn/guides/providers.mdsrc/codex/catalog/provider-fetch.tssrc/oauth/index.tssrc/providers/registry.tssrc/server/management/provider-routes.tsstructure/01_runtime.mdtests/baseten-provider.test.tstests/fixtures/baseten-models.jsontests/provider-connection-test.test.tstests/provider-model-discovery-contract.test.tstests/provider-registry-parity.test.ts
124f427 to
f345775
Compare
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs-site/src/content/docs/ja/guides/providers.md`:
- Around line 156-160: Remove the blank separator between consecutive blockquote
paragraphs in docs-site/src/content/docs/ja/guides/providers.md lines 156-160,
docs-site/src/content/docs/ko/guides/providers.md lines 156-160, and
docs-site/src/content/docs/ru/guides/providers.md lines 167-171, preserving the
separate blockquote paragraphs.
In `@structure/01_runtime.md`:
- Around line 80-81: Update the discovery-limit guidance in
structure/01_runtime.md lines 80-81,
docs-site/src/content/docs/ru/reference/configuration.md lines 330-334, and
docs-site/src/content/docs/zh-cn/reference/configuration.md lines 287-290 to
state the generic 4 MiB response and 2,000 raw-row defaults, plus the Baseten
preset overrides of 1 MiB and 256 models at every site. Keep all translated
pages synchronized with the runtime behavior.
In `@tests/baseten-provider.test.ts`:
- Around line 273-280: Update the adapter-mismatch test around routeModel and
basetenConfig so it supplies a non-canonical custom baseUrl while retaining
adapter: "anthropic". Assert that customAdapter preserves this destination,
ensuring registry retargeting cannot pass the test by leaving the canonical URL
unchanged; keep the existing provider and authMode assertions.
- Around line 217-225: Update the registry assertion’s reasoning configuration
in the toMatchObject block around noReasoningModels or the model-specific
reasoning map to explicitly include moonshotai/Kimi-K2.6. Ensure the existing
Kimi request assertion in the Kimi route test is backed by that registry entry
and continues suppressing reasoning_effort.
In `@tests/provider-model-discovery-contract.test.ts`:
- Around line 34-69: Ensure discovery-cache cleanup is uniform across temporary
registry mutations. In tests/provider-model-discovery-contract.test.ts lines
34-69, update withRegistryDiscovery to call clearModelCache(providerId) in
finally and export the shared helper as needed; in
tests/provider-connection-test.test.ts lines 153-182, replace the inline
together discovery mutate/restore logic with that helper so the temporary state
is restored and cached rows are cleared before subsequent probes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a4308713-4f36-49b7-adae-bd345c8a28b0
📒 Files selected for processing (36)
docs-site/src/content/docs/getting-started/quickstart.mddocs-site/src/content/docs/guides/providers.mddocs-site/src/content/docs/ja/getting-started/quickstart.mddocs-site/src/content/docs/ja/guides/providers.mddocs-site/src/content/docs/ja/reference/configuration.mddocs-site/src/content/docs/ko/getting-started/quickstart.mddocs-site/src/content/docs/ko/guides/providers.mddocs-site/src/content/docs/ko/reference/configuration.mddocs-site/src/content/docs/reference/configuration.mddocs-site/src/content/docs/ru/getting-started/quickstart.mddocs-site/src/content/docs/ru/guides/providers.mddocs-site/src/content/docs/ru/reference/configuration.mddocs-site/src/content/docs/zh-cn/getting-started/quickstart.mddocs-site/src/content/docs/zh-cn/guides/providers.mddocs-site/src/content/docs/zh-cn/reference/configuration.mdsrc/codex/catalog/parsing.tssrc/codex/catalog/provider-fetch.tssrc/oauth/index.tssrc/oauth/key-providers.tssrc/oauth/login-cli.tssrc/providers/derive.tssrc/providers/model-discovery.tssrc/providers/registry.tssrc/router.tssrc/server/auth-cors.tssrc/server/management/provider-routes.tssrc/server/management/shared.tsstructure/01_runtime.mdtests/baseten-provider.test.tstests/codex-catalog.test.tstests/fixtures/baseten-models.jsontests/fixtures/provider-model-discovery.jsontests/provider-connection-test.test.tstests/provider-model-discovery-contract.test.tstests/provider-registry-parity.test.tstests/umans-provider.test.ts
f345775 to
879efb2
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/server/auth-cors.ts (1)
179-182: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse the shared admin-token resolver.
Line 179 accepts only the environment token, while
src/oauth/login-cli.tsLine 13 sends the file-backed fallback fromconfiguredAdminToken(). With noOPENCODEX_ADMIN_AUTH_TOKENbut a configured token file, proxy-update requests send a token the server rejects. Delegate this helper toconfiguredAdminToken()and add a file-only-token regression test.Proposed fix
+import { configuredAdminToken } from "../lib/admin-secrets"; + export function configuredAdminAuthToken(): string | undefined { - const token = process.env.OPENCODEX_ADMIN_AUTH_TOKEN?.trim(); - return token || undefined; + return configuredAdminToken() ?? undefined; }As per path instructions, “A behavior change in src/ should come with a focused regression test near the existing tests for that subsystem.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/server/auth-cors.ts` around lines 179 - 182, Update configuredAdminAuthToken() to delegate to the shared configuredAdminToken() resolver so environment and file-backed tokens use identical precedence. Add a focused regression test near the existing auth/CORS tests covering a configured token file when OPENCODEX_ADMIN_AUTH_TOKEN is absent, and assert that the file token is returned.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs-site/src/content/docs/zh-cn/guides/providers.md`:
- Around line 147-151: Update the Baseten Truss sentence in the Chinese provider
documentation to describe dedicated predict endpoints as using different hosts
and request schemas/formats, not different protocols. Preserve the surrounding
wording and keep the blank separator before the Tencent callout unchanged.
In `@src/providers/model-discovery.ts`:
- Around line 87-93: Update the path validation in the spec.path guard to reject
any path segment equal to "..", including repeated or embedded traversal
segments such as "../../internal/models". Preserve acceptance of ordinary
relative paths like "models" and the existing scheme, protocol-relative, query,
fragment, and length checks.
---
Outside diff comments:
In `@src/server/auth-cors.ts`:
- Around line 179-182: Update configuredAdminAuthToken() to delegate to the
shared configuredAdminToken() resolver so environment and file-backed tokens use
identical precedence. Add a focused regression test near the existing auth/CORS
tests covering a configured token file when OPENCODEX_ADMIN_AUTH_TOKEN is
absent, and assert that the file token is returned.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: bb92fa4f-53dd-4d98-9d51-77b07ecba819
📒 Files selected for processing (36)
docs-site/src/content/docs/getting-started/quickstart.mddocs-site/src/content/docs/guides/providers.mddocs-site/src/content/docs/ja/getting-started/quickstart.mddocs-site/src/content/docs/ja/guides/providers.mddocs-site/src/content/docs/ja/reference/configuration.mddocs-site/src/content/docs/ko/getting-started/quickstart.mddocs-site/src/content/docs/ko/guides/providers.mddocs-site/src/content/docs/ko/reference/configuration.mddocs-site/src/content/docs/reference/configuration.mddocs-site/src/content/docs/ru/getting-started/quickstart.mddocs-site/src/content/docs/ru/guides/providers.mddocs-site/src/content/docs/ru/reference/configuration.mddocs-site/src/content/docs/zh-cn/getting-started/quickstart.mddocs-site/src/content/docs/zh-cn/guides/providers.mddocs-site/src/content/docs/zh-cn/reference/configuration.mdsrc/codex/catalog/parsing.tssrc/codex/catalog/provider-fetch.tssrc/oauth/index.tssrc/oauth/key-providers.tssrc/oauth/login-cli.tssrc/providers/derive.tssrc/providers/model-discovery.tssrc/providers/registry.tssrc/router.tssrc/server/auth-cors.tssrc/server/management/provider-routes.tssrc/server/management/shared.tsstructure/01_runtime.mdtests/baseten-provider.test.tstests/codex-catalog.test.tstests/fixtures/baseten-models.jsontests/fixtures/provider-model-discovery.jsontests/provider-connection-test.test.tstests/provider-model-discovery-contract.test.tstests/provider-registry-parity.test.tstests/umans-provider.test.ts
|
Status after the prerequisite landed: #652 is merged ( I reran the failing Windows job and looked at what it actually reported. The rerun came back cancelled at 12m05s, not failed: That is the Your code checks out locally on my side: So this is waiting on CI capacity, not on a change from you. Two things worth doing when you get a chance:
One note for the remaining batches in #572: the first failure on this PR was a genuine |
The `test` job ran with `timeout-minutes: 12` while a green Windows run takes 11.8 minutes, leaving about 12 seconds of margin. Runner variance, not the code under review, decided the outcome: PR #711's rerun finished at 11.8min and passed, PR #653's was killed at 12.0min with `Test` cancelled and every later step skipped. That flakiness is expensive to review around, because `gh pr checks` renders a cancelled job as `fail`. A red Windows check could mean a real failure, a `cancel-in-progress` concurrency cancel, or this timeout, and telling them apart requires reading `conclusion` from the check-runs API plus per-job timings. Measured on run 30459554635 (same suite, same commit): ubuntu-latest 4.6 min macos-latest 5.6 min windows-latest 11.8 min 20 minutes keeps a green Windows run green with margin. It does not address why Windows needs ~2.5x Linux on an identical suite; the comment says so explicitly, because the ceiling has already been raised once (8 -> 12) for this same reason and chasing it again is not a fix. The `npm-global-smoke` job is untouched at 8 minutes: it completes in 1-2 minutes and was never near its limit. Refs #717
879efb2 to
fe283d6
Compare
fe283d6 to
7e0f779
Compare
|
Review follow-up is complete for the current head (
Local verification for this PR: typecheck, privacy scan, focused tests, docs build, and the full suite all pass (6036 pass / 2 skip / 0 fail). |
|
CI note: the only remaining red check is the Windows matrix job. Its single failure is unrelated to this PR's diff: I attempted both the single-job and failed-jobs rerun APIs, but GitHub requires upstream repository admin rights for this run. A maintainer will need to re-run the failed Windows job: https://github.com/lidge-jun/opencodex/actions/runs/30522540376/job/90805964297 |
Summary
basetenas a first-class API-key preset for the shared Baseten Model APIs endpoint athttps://inference.baseten.co/v1./modelsdiscovery through the contract in feat(providers): add bounded model discovery contract #652, with a 1 MiB response limit, a 256-row limit, and same-named custom-provider destination preservation.This PR is a pilot provider consumer under umbrella issue #572. The umbrella issue must remain open for the remaining provider batches.
Dependency And Review Order
This is stacked on #652 and targets
dev. Until #652 merges, GitHub will show both the contract commit and the Baseten commit in this PR. The Baseten-specific change is the final commit in this stack; after #652 merges, the PR diff will automatically reduce to that provider commit.Scope
predictendpoints, which use different hosts, authentication, and arbitrary schemas.Security
This adds a credential-bearing provider preset. It uses the contract's redirect denial and
preserveCustomDestinationprotection, does not persist discovery trust policy, and introduces no key logging. Explicit maintainer security review is requested before merge.Verification
bun run typecheckbun run privacy:scanbun run lint:guiChecklist
Summary by CodeRabbit
New Features
Bug Fixes
Documentation