# OpenCode free-model discovery

The pure parser in `packages/orchestrator/src/opencode-free-models.ts` adapts OpenCode's catalog discovery. The shared keyless registry and production fallback backend consume it to register the anonymous route; the parser itself makes no inference requests. Onboarding uses the same discovery and request adapter.

Source revision: [`anomalyco/opencode@15b24ae12ddb8b7ae3e923b286b4032761bee510`](https://github.com/anomalyco/opencode/tree/15b24ae12ddb8b7ae3e923b286b4032761bee510), reviewed 2026-10-12.

- [`packages/core/src/models-dev.ts`](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/packages/core/src/models-dev.ts) reads `https://models.opencode.ai/api.json`, normalizes provider/model transport, capabilities, costs and token limits, and uses a bundled snapshot with a five-minute refresh.
- [`packages/core/src/plugin/models-dev.ts`](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/packages/core/src/plugin/models-dev.ts) excludes deprecated models and models without text support.
- [`packages/core/src/plugin/provider/opencode.ts`](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/packages/core/src/plugin/provider/opencode.ts) enables anonymous access using the public sentinel `public` and disables models with positive input costs when no real key is configured.

Omnius requires explicit zero input and output costs, including any advertised context tiers and cache prices. It pins the provider and endpoint, accepts the OpenAI-compatible chat transport and the per-model `@ai-sdk/openai` Responses transport, excludes foreign endpoints and unsupported protocols, and preserves documented tool, schema and token-limit metadata. Missing schema support remains unknown. The returned `admission: "catalog_only"` records that metadata alone establishes no route availability. Responses models use the dedicated adapter at the same pinned `/inference/v1/responses` endpoint.

The catalog lists paid models too. The inference `/v1/models` response supplies IDs without cost or capability metadata and cannot establish free eligibility. Free suffixes are insufficient: Big Pickle has zero costs without that suffix, and old free rows can remain deprecated or unavailable.

Listing hints from `https://opencode.ai/inference/v1/models` establish positive listing evidence, not exhaustive exclusions. A genuine installed-client request returned a valid Nemotron Ultra reply on 2026-10-14 while that alias remained omitted; canonical active zero-cost metadata therefore determines eligibility. This unauthenticated endpoint returned 83 IDs on 2026-10-12; `exo-free`, `ling-3.0-flash-fin-free` and `nemotron-3-ultra-free` were absent. These observations are not hardcoded exclusions. Empty, partial, missing, malformed or oversized availability discovery preserves canonical zero-cost eligibility; an explicitly empty valid canonical catalog still excludes all models. ID-only rows can never add a model or supply price, tools, schema or context metadata.

The [complete free-model follow-up](work-orders/WO-opencode-all-free-models-20261012.md)
removes the previous 16-model cascade cutoff: all eligible OpenCode models within
the shared 512-row catalog bound are queued. The subsequent
[benchmark-informed priority](inference-fallback-priority.md) exhausts eligible
OpenCode models before Hermes and other providers. The current audit found seven live free chat models plus
`muse-spark-1.3-contributor-free`, whose `@ai-sdk/openai` declaration selects
Responses. The ordinary chat adapter must never substitute for that transport.

On 2026-10-12, synthetic tool-less Nemotron requests returned HTTP 403 `FreeTierError`, including probes using the public sentinel, current upstream headers and legacy `/zen/v1/chat/completions` endpoint. Within the user's explicitly authorized partner compatibility scope, a subsequent source-derived native-shaped request succeeded at `https://opencode.ai/inference/v1/chat/completions`: HTTP 200 SSE, visible answer `OK`, normal `stop` and `[DONE]`, in 1.044 seconds. It used `opencode/latest/2.0.27/cli`, client `cli`, transparent `x-omnius-client: omnius/1.0.847`, fresh source-format session/message IDs, the current system prefix, genuine read/shell definitions, automatic tool selection and streaming. No tool executed. This demonstrates native-agent availability for that request; it does not identify which shape differences the server requires or establish all models and modes.

Two further synthetic streamed probes also returned HTTP 200 with normal terminal receipts. The same compatibility definitions with `tool_choice: "none"` and a strict JSON schema produced exactly `{"value":"ok"}` without tool calls in 4.120 seconds. A forced custom `omnius_probe` tool alongside those definitions returned that custom call with the expected arguments in 0.946 seconds. These establish those request shapes for Nemotron, without executing any tool or sending private context. They do not imply every catalog model supports them.

Current [App metadata](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/packages/core/src/app.ts) and [model request construction](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/packages/core/src/session/model-request.ts) supply the header format. The public [inference proxy](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/packages/console/app/src/lib/inference-proxy.ts) delegates free-tier admission to the inference service; its server-side guard was not found in this public source tree. No TLS fingerprint or hidden-signature requirement has been established. See the provider's [access discussion](https://github.com/anomalyco/opencode/issues/49580).

The module exports fixed header, system-prefix and core-tool metadata from that pinned source, plus an OpenAI-style catalog normalizer. Its request-header factory generates a source-format session identifier and uses a stable SHA-1 of the public namespace `omnius` as its project marker. It can retain a caller-owned session ID for affinity. The obsolete `x-opencode-request` header is omitted: single-header live controls found it caused 403 while the unchanged body succeeded without it. It reads no user credentials, private project paths or existing conversation/session data and supplies no Authorization header or execution implementation. A truthful `omnius/unknown` attribution is allowed when no application version is available.

Callers must keep host authorization, original tool schemas, history and tool-choice bindings, invert any existing tool-name aliases, and reject calls to compatibility definitions that have no host execution authority. The parser's catalog-only receipt remains separate from live route admission. Identifier generation follows upstream [Identifier](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/packages/schema/src/identifier.ts) and [SessionID](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/packages/schema/src/session-id.ts); core metadata follows the [read](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/packages/core/src/tool/plugin/read.ts) and [shell](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/packages/core/src/tool/plugin/shell.ts) definitions.

Current source comparisons, genuine-client controls and Telegram acceptance are recorded in the [2026-10-14 work order](work-orders/WO-genuine-opencode-access-20261014.md). Unknown native grammar support uses prompt-only formatting on validated built-in routes, preserving full host schemas and callbacks.

The adapted discovery is covered by OpenCode's [MIT license](https://github.com/anomalyco/opencode/blob/15b24ae12ddb8b7ae3e923b286b4032761bee510/LICENSE):

```text
MIT License

Copyright (c) 2025 opencode

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
