GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(ai): describe text models by api, baseURL and auth by rekram1-node · Pull Request #61501 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Fourth PR in the @opencode/ai model redesign. Stacked on #61499 (one Model).

Problem

After #61499 there is one Model, but a text model still only knows a route: an opaque value that bundles the wire API with the deployment (base URL, auth). To point a model somewhere else you had to rebuild its route:

LanguageModel.update(model, { route: model.route.with({ endpoint: { baseURL } }) })   // core's per-request baseURL hook
LanguageModel.update(model, { route: model.route.with({ auth: Auth.none }) })          // core's keyless providers
model.route.endpoint.baseURL                                                            // reading where it goes

and there was no way to describe a model by hand without learning Route.

Change

A model now says which API it speaks and where it goes:

import { Model } from "@opencode/ai"
import { apis } from "@opencode/ai/apis"

const local = Model.make({
  type: "chat",
  id: "qwen3-coder",
  provider: "lmstudio",
  api: apis.openaiChat,              // anthropicMessages, bedrockConverse, cohereChat, gemini, googleInteractions, mistralChat, openaiChat, openaiResponses
  baseURL: "http://localhost:1234/v1",
  auth: Auth.none,
  capabilities: { tools: { strict: false } },
  options: { temperature: 0.7 },
  compatibility: { maxTokensField: "max_tokens" },
})

Model.with(local, { baseURL: "http://gpu-box:1234/v1" })   // same API and auth, new host
local.baseURL                                               // plain field
  • Model.Input takes api (was route) for every type. For text models baseURL, path (models.dev v2 path, only when the host departs from the API's usual one) and auth override the API's own defaults; provider-built models fill them from their configured route, so nothing changes for them.
  • model.route is now derived (api deployed at baseURL with auth) and marked internal; the clients keep running it.
  • Model.with(model, { api }) brings the new API's own baseURL and auth, as LanguageModel.update(model, { route }) did.
  • New @opencode/ai/apis export with the eight shared text APIs.

Media and decision models take api too but still carry their deployment inside it; splitting those out is the next PR.

Core

Syntax-only call-site updates, no behavior change:

File Before After
session/model-request.ts base.model.route.endpoint.baseURL; AIModel.with(base.model, { route: base.model.route.with({ endpoint: { baseURL } }) }) base.model.baseURL; AIModel.with(base.model, { baseURL })
model-resolver.ts resolved.route.endpoint.baseURL; AIModel.with(model, { route: model.route.with({ auth: Auth.none }) }) resolved.baseURL; AIModel.with(model, { auth: Auth.none })
aisdk.ts, perf/snapshot.ts Model.make({ ..., route }) Model.make({ ..., api: route })

Model.with({ baseURL }) deploys the original API with the model's current auth, which is the same route the old route.with(...) chain produced (the Auth.none override from the resolver is kept). No plugin, SDK, server or config surface changes.

Wire check

Checked locally: 36 sample models byte-identical (method, URL, headers, body vs a snapshot taken before the redesign); full catalog 8544 models, 0 requests differ (7732 send a request; the rest are AI SDK packages or need real cloud config). Both checks resolve models through ModelResolver and capture the request the AI package sends; they stay out of the repo.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" font-family="ui-monospace,monospace" font-size="9">
  <rect width="240" height="72" rx="8" fill="#111"/>
  <text x="12" y="20" fill="#9cdcfe">Model.make({</text>
  <text x="22" y="34" fill="#ce9178">api: apis.openaiChat,</text>
  <text x="22" y="48" fill="#ce9178">baseURL:
    <tspan fill="#b5cea8">"localhost:1234"<animate attributeName="opacity" values="1;1;0;0;1" dur="4s" repeatCount="indefinite"/></tspan>
  </text>
  <text x="70" y="48" fill="#b5cea8" opacity="0">"gpu-box:1234"<animate attributeName="opacity" values="0;0;1;1;0" dur="4s" repeatCount="indefinite"/></text>
  <text x="12" y="62" fill="#9cdcfe">})</text>
  <circle cx="214" cy="36" r="6" fill="#4ec9b0"><animate attributeName="r" values="4;7;4" dur="2s" repeatCount="indefinite"/></circle>
</svg>

Out of scope / open questions

  • Media and decision deployment fields (baseURL, auth split out of their api), and deleting Route.model / MediaRoute.deployment with providers becoming presets over Model.make. That is the remaining step of the plan, together with the callable provider surface from refactor(ai): callable providers #60966.
  • Model is not JSON-serializable (the api is a value with functions). api.id is enough for core today, so no toJSON yet.
  • api stays a value, not the v2 protocol name string ("chat-completions", "responses", ...). Several package APIs share one v2 name with different dialects (OpenAI, Z.ai, Alibaba and Venice Chat; Bedrock Mantle's own metadata key and compaction), and provider presets attach transports and compaction to them, so a string would need a registry plus per-dialect compatibility first.
  • baseURL stays optional: media and decision models carry theirs inside api until the next step. There is no top-level headers: deployment headers are options.headers, the same key a request uses.

Size

src +90 / -36 (the apis entry point and the baseURL/path/auth fields), tests +127 / -69 (mostly route: → api: in hand-built test models, plus test/model.test.ts).

Verification

  • bun typecheck and bun run typecheck:tsc in packages/ai, core, server, sdk, plugin: pass
  • bun test in packages/ai: 2048 pass, 0 fail
  • packages/core: model-resolver, session-runner, config/provider, session-runner-recorded, plugin/: 900 pass, 0 fail
  • bun run check: pass

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the contributor label Nov 3, 2026
@rekram1-node
rekram1-node force-pushed the model-type branch from f40b4ac to ae8b95c Compare November 4, 2026 00:02
@rekram1-node
rekram1-node force-pushed the model-api branch from daea909 to 3b98718 Compare November 4, 2026 00:02
@github-actions github-actions Bot mentioned this pull request Nov 4, 2026
📊 AI CLI 工具社区动态日报 2026-11-04 litang9/big_model_radar#650
Open
@rekram1-node
rekram1-node force-pushed the model-type branch from ae8b95c to f0c28ab Compare November 4, 2026 17:21
@rekram1-node
rekram1-node force-pushed the model-api branch from 3b98718 to d93d8f8 Compare November 4, 2026 17:21
@rekram1-node rekram1-node mentioned this pull request Nov 4, 2026
feat(ai): price usage from the model's catalog cost #61717
Open
@rekram1-node
rekram1-node force-pushed the model-type branch from f0c28ab to 40ed33d Compare November 4, 2026 22:43
@rekram1-node
rekram1-node force-pushed the model-api branch from d93d8f8 to 1aac3bd Compare November 4, 2026 22:43
@rekram1-node
rekram1-node force-pushed the model-type branch from 40ed33d to 7f29f54 Compare November 4, 2026 23:37
@rekram1-node
rekram1-node force-pushed the model-api branch from 1aac3bd to 56caa75 Compare November 4, 2026 23:37
@rekram1-node
rekram1-node force-pushed the model-type branch from 7f29f54 to 260b913 Compare November 5, 2026 15:27
@rekram1-node
rekram1-node force-pushed the model-api branch from 56caa75 to ccb3965 Compare November 5, 2026 15:28
rekram1-node added 2 commits November 5, 2026 09:50
@rekram1-node
refactor(ai): replace the seven model classes with one Model
9dbebb5
@rekram1-node
feat(ai): describe text models by api, baseURL and auth
4ae08ae
@rekram1-node
rekram1-node force-pushed the model-type branch from 260b913 to 9dbebb5 Compare November 5, 2026 15:52
@rekram1-node
rekram1-node force-pushed the model-api branch from ccb3965 to 4ae08ae Compare November 5, 2026 15:58
@rekram1-node
rekram1-node force-pushed the model-type branch from 9dbebb5 to a1798d3 Compare November 5, 2026 16:58
@rekram1-node rekram1-node mentioned this pull request Nov 5, 2026
refactor(ai): make Model one plain object for every model type #61499
Open
@rekram1-node

rekram1-node commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Folded into #61499: the model is now a plain object, and baseURL/path/auth only work as plain fields if the client reads them per request, which is part of that change. #61717 now stacks on it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node rekram1-node closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@rekram1-node
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.