Skip to content

Commit 84da6de

Browse files
authored
fix(models): refresh native pricing without pinning defaults (#133695)
* fix(models): refresh native pricing without pinning defaults Use complete native OpenCode and Venice pricing schedules while preserving authored zero, partial, flat and tiered costs across preparation and lookup. Avoid generated price pins during fresh merge-mode Venice onboarding. Follow-up to #133349 (cached long-context accounting) and #129694 (Venice runtime pricing); related to #113549 (broader OpenCode catalog drift). * fix(pricing): preserve native schedules through resolution Merge prepared costs beneath authored display prices, retain validated native free schedules under exact owner policy, and compile OpenRouter overrides with strict thresholds and source-order inheritance for each price key. Preserve zero, partial, flat and tiered user pricing without new settings or storage. Follow-up repairs for #133695.
1 parent f3fed2b commit 84da6de

48 files changed

Lines changed: 3008 additions & 1059 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/concepts/models.md‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,13 @@ build stamp is ignored.
288288

289289
The hosted file is published from the public
290290
[`openclaw/catalog`](https://github.com/openclaw/catalog) GitHub repository.
291-
Its scheduled workflow refreshes from OpenClaw's shipped plugin manifests and
292-
pricing sources; every catalog content change is preserved as a public commit.
291+
Its scheduled workflow checks OpenClaw's default-branch plugin manifests and
292+
public pricing sources every four hours; every catalog content change is
293+
preserved as a public commit. Provider-owned policies select complete price
294+
schedules, including context tiers, without mixing rates from different sources.
295+
Declared native sources read OpenCode's official catalog or Venice's public model
296+
API, so connected installations can receive advertised price changes without a
297+
new OpenClaw release.
293298

294299
Run `openclaw models refresh` for an immediate metadata and pricing check, or
295300
disable every hosted catalog request with `models.catalogRefresh.enabled:

‎docs/plugins/manifest.md‎

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ See [Plugins](/tools/plugin) for the full plugin system guide, and [Capability m
150150
| `providerCatalogEntry` | No | `string` | Lightweight provider-catalog module path, relative to the plugin root, for manifest-scoped provider catalog metadata that can be loaded without activating the full plugin runtime. |
151151
| `modelSupport` | No | `object` | Manifest-owned shorthand model-family metadata used to auto-load the plugin before runtime. |
152152
| `modelCatalog` | No | `object` | Declarative model catalog metadata for providers owned by this plugin. This is the control-plane contract for future read-only listing, onboarding, model pickers, aliases, and suppression without loading plugin runtime. |
153-
| `modelPricing` | No | `object` | Provider-owned hosted-pricing publication policy. Use it to opt local/self-hosted providers out of published pricing or map provider refs to OpenRouter/LiteLLM catalog ids without hardcoding provider ids in core. |
153+
| `modelPricing` | No | `object` | Provider-owned hosted-pricing publication policy. Use it to opt local/self-hosted providers out of published pricing or map provider refs to supported public pricing catalogs without hardcoding provider ids in core. |
154154
| `modelIdNormalization` | No | `object` | Provider-owned model-id alias/prefix cleanup that must run before provider runtime loads. |
155155
| `providerEndpoints` | No | `object[]` | Manifest-owned endpoint host/baseUrl metadata for provider routes that core must classify before provider runtime loads. |
156156
| `providerRequest` | No | `object` | Cheap provider-family and request-compatibility metadata used by generic request policy before provider runtime loads. |
@@ -1295,11 +1295,13 @@ Use `modelPricing` when the hosted catalog publisher needs provider-specific pri
12951295

12961296
Provider fields:
12971297

1298-
| Field | Type | What it means |
1299-
| ------------ | ----------------- | --------------------------------------------------------------------------------------------- |
1300-
| `external` | `boolean` | Set `false` for local/self-hosted providers that should never use published external pricing. |
1301-
| `openRouter` | `false \| object` | OpenRouter publication-key mapping. `false` disables OpenRouter matching for this provider. |
1302-
| `liteLLM` | `false \| object` | LiteLLM publication-key mapping. `false` disables LiteLLM matching for this provider. |
1298+
| Field | Type | What it means |
1299+
| ------------ | ----------------- | ----------------------------------------------------------------------------------------------- |
1300+
| `external` | `boolean` | Set `false` for local/self-hosted providers that should never use published external pricing. |
1301+
| `openCode` | `false \| object` | Explicit mapping to the public `models.opencode.ai/api.json` catalog. Never enabled implicitly. |
1302+
| `openRouter` | `false \| object` | OpenRouter publication-key mapping. `false` disables OpenRouter matching for this provider. |
1303+
| `liteLLM` | `false \| object` | LiteLLM publication-key mapping. `false` disables LiteLLM matching for this provider. |
1304+
| `venice` | `false \| object` | Explicit mapping to the public Venice `/api/v1/models` catalog. Never enabled implicitly. |
13031305

13041306
Source fields:
13051307

@@ -1309,6 +1311,36 @@ Source fields:
13091311
| `passthroughProviderModel` | `boolean` | Treat slash-containing model ids as nested provider/model refs, useful for proxy providers such as OpenRouter. |
13101312
| `modelIdTransforms` | `"version-dots"[]` | Extra external catalog model-id variants. `version-dots` tries dotted version ids like `claude-opus-4.6`. |
13111313

1314+
A declared provider policy enables only its declared source mappings. Without a
1315+
policy, publication tries OpenRouter, then LiteLLM. Each selected price is a
1316+
complete schedule: base rates and context tiers are never combined across sources.
1317+
OpenRouter's native prompt-length overrides are supported; time-based overrides
1318+
are not represented as static context tiers.
1319+
1320+
For authoritative native source mappings, use:
1321+
1322+
```json
1323+
{
1324+
"providers": ["opencode", "venice"],
1325+
"modelPricing": {
1326+
"providers": {
1327+
"opencode": { "openCode": { "provider": "opencode" } },
1328+
"venice": { "venice": { "provider": "venice" } }
1329+
}
1330+
}
1331+
}
1332+
```
1333+
1334+
The publisher fetches the fixed OpenCode or Venice public endpoint without
1335+
credentials only when its source is declared, and publishes native prices only
1336+
in explicitly mapped owner namespaces. Venice's lightweight public
1337+
`pricing-api.ts` keeps its payload parsing in the plugin and shares the complete
1338+
schedule parser with runtime discovery. Fetch failure, malformed response
1339+
bodies, or missing or invalid pricing for a paid bundled model stops
1340+
publication, leaving the previous hosted catalog intact rather than publishing
1341+
stale seed rates with a new timestamp. This authoring metadata does not add an
1342+
operator setting or change the Gateway's existing refresh and restart lifecycle.
1343+
13121344
### OpenClaw Provider Index
13131345

13141346
The OpenClaw Provider Index is OpenClaw-owned preview metadata for providers whose plugins may not be installed yet. It is not part of a plugin manifest. Plugin manifests remain the installed-plugin authority. The Provider Index is the internal fallback contract that future installable-provider and pre-install model picker surfaces will consume when a provider plugin is not installed.

‎docs/plugins/sdk-provider-plugins.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,17 @@ catalog, API-key auth, and dynamic model resolution.
409409
Public metadata never establishes account entitlement or expands the
410410
credential scope of discovery.
411411

412+
The same subpath exposes `normalizeOpenRouterModelPricing(pricing)` for
413+
native OpenRouter pricing objects. It converts per-token rates and static
414+
prompt-length overrides into a complete per-million cost schedule, without
415+
network access or prices from another source. Overrides apply strictly above
416+
`min_prompt_tokens`, counting uncached input, cache reads, and cache writes.
417+
Matching entries apply in source order: later entries win per price key,
418+
including at equal thresholds; omitted keys inherit the native base or an
419+
earlier matching entry. Cache rates absent from the base default to zero.
420+
Invalid effective token rates return `undefined`. Entries with time-based or
421+
unknown conditions are skipped; other known charge dimensions are ignored.
422+
412423
When `ctx.providerIds` is present, it contains the normalized provider
413424
identities selected for that catalog owner. Return `null` before resolving
414425
credentials or making network requests when the hook serves none of them;

‎docs/providers/opencode.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ deprecated models are excluded from active discovery and its offline fallback.
119119
Deprecated explicit refs remain resolvable for existing configurations but are
120120
not shown as current recommendations.
121121

122+
Price estimates also refresh through the [hosted model catalog](/concepts/models#hosted-catalog-updates),
123+
using the same public OpenCode pricing feed as live discovery. Hosted updates
124+
activate after the next Gateway restart; the bundled snapshot remains available
125+
offline. Explicit model prices in your configuration or agent-local `models.json`
126+
keep precedence. These are advertised-price estimates, not verified invoice totals.
127+
122128
### Go
123129

124130
| Property | Value |

‎docs/providers/venice.md‎

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -164,24 +164,46 @@ Venice uses a credit-based system. Anonymized models cost roughly the same as
164164
direct API pricing plus a small Venice fee. See
165165
[venice.ai/pricing](https://venice.ai/pricing) for current rates.
166166

167-
OpenClaw uses the Venice plugin manifest's prices for bundled models, including
168-
when those models appear in live discovery. Newly discovered models outside the
169-
manifest keep zero estimates until pricing is configured; zero does not mean the
170-
model is free.
171-
172-
The bundled prices include extended-context tiers for `grok-4-5` and
173-
`qwen-3-7-plus`. Higher rates apply to the entire request when total prompt
174-
input exceeds 200,000 or 256,000 tokens, respectively. Prompt input includes
175-
uncached tokens, cache reads, and cache writes; output tokens do not select the
176-
tier. A request exactly at the threshold still uses base rates. See Venice's
177-
[model pricing contract](https://docs.venice.ai/api-reference/endpoint/models/list).
178-
179-
Existing explicit model prices take precedence, including zero. Onboarding
180-
preserves existing model entries rather than replacing their prices. If an older
181-
configuration contains obsolete zero rates, back up your configuration and update
182-
only the affected `models.providers.venice.models[].cost` fields to current rates.
183-
Keep intentional custom prices. See [Token use and costs](/reference/token-use)
184-
for pricing units and usage reporting.
167+
OpenClaw reads live prices from Venice's public
168+
[`GET /api/v1/models`](https://docs.venice.ai/api-reference/endpoint/models/list)
169+
response during model discovery. The same plugin parser supplies the hosted
170+
catalog publisher. Known and newly discovered models use the API's complete
171+
schedule in USD per million tokens; the manifest prices are an offline seed.
172+
Missing or invalid live prices retain the complete seed schedule for known
173+
models. Unknown models without valid pricing keep zero estimates; that does not
174+
mean the model is free. Explicit API zero rates are valid.
175+
176+
When the API supplies extended pricing, its rates apply to the entire request
177+
only when total prompt input **exceeds** `context_token_threshold`. Prompt input
178+
includes uncached input, cache reads, and cache writes; output tokens do not
179+
select the tier. A request exactly at the threshold still uses base rates.
180+
Base and extended rates always come from one schedule. An invalid extended
181+
schedule is not combined with seed or other-source prices.
182+
183+
Explicit `models.providers.venice.models[].cost` entries override catalog
184+
estimates, including zero. Omitted `cost` or `{}` inherits the catalog schedule.
185+
Partial flat overrides inherit missing base rates and remove inherited tiers;
186+
explicit `tieredPricing` wins, and `tieredPricing: []` selects flat pricing.
187+
Agent-local root `models.json` prices retain highest priority.
188+
189+
New onboarding in `models.mode: "merge"` leaves generated catalog rows out of the
190+
configuration so they cannot become price pins. Re-onboarding preserves existing
191+
model entries, aliases, and model selection. In `models.mode: "replace"`,
192+
onboarding retains explicit seed rows because that mode disables discovery.
193+
Existing serialized costs are never automatically removed or migrated, even if
194+
they match an old seed. With merge mode enabled, back up your configuration and
195+
remove only unwanted `cost` fields to resume catalog pricing; keep intentional
196+
overrides.
197+
198+
Discovery reuses its existing fetched rows and cache. Usage display makes no
199+
price requests, and a running Gateway does not immediately adopt every upstream
200+
price change. Hosted catalog updates activate at the existing restart boundary;
201+
see [Hosted model catalog](/concepts/models#hosted-catalog-updates).
202+
Make sizing-only edits in your source configuration without copying generated
203+
model rows back into it: replacing an entire model array from a runtime snapshot
204+
can persist inherited costs as explicit overrides. Historical estimated costs
205+
remain subject to the existing repricing policy; provider-billed amounts are
206+
unchanged. See [Token use and costs](/reference/token-use).
185207

186208
## Usage examples
187209

@@ -250,7 +272,6 @@ More help: [Troubleshooting](/help/troubleshooting) and [FAQ](/help/faq).
250272
name: "GLM 4.7",
251273
reasoning: true,
252274
input: ["text"],
253-
cost: { input: 0.55, output: 2.65, cacheRead: 0.11, cacheWrite: 0 },
254275
contextWindow: 198000,
255276
maxTokens: 16384,
256277
},

‎docs/reference/token-use.md‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,16 @@ Explicit flat or all-zero model prices do not inherit a catalog tier schedule.
206206
Omitted flat-rate fields can still inherit catalog defaults. An explicit
207207
`tieredPricing` schedule takes precedence over the catalog schedule.
208208

209-
Pricing updates ship in the hosted model catalog alongside model metadata.
210-
OpenClaw does not fetch OpenRouter or LiteLLM directly. Set
211-
`models.catalogRefresh.enabled: false` to disable hosted catalog traffic on
212-
offline or restricted networks; bundled pricing and explicit
213-
`models.providers.*.models[].cost` entries still drive local cost estimates.
209+
Pricing updates ship in the hosted model catalog alongside model metadata. Its
210+
publisher reads public pricing sources, including OpenCode's official catalog
211+
and Venice's public model API when the provider declares the native source.
212+
Base rates and context tiers come from the same source; usage rendering makes no
213+
network requests. Hosted updates activate after
214+
the next Gateway restart. Set `models.catalogRefresh.enabled: false` to disable
215+
hosted catalog traffic on offline or restricted networks; bundled pricing still
216+
works. Agent-local `models.json` prices take precedence over explicit
217+
`models.providers.*.models[].cost` entries, and both override catalog estimates,
218+
including explicit flat and zero rates.
214219

215220
## Cache TTL and pruning impact
216221

‎extensions/opencode/index.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,17 @@ describe("opencode provider plugin", () => {
161161
throw new Error("expected registered OpenCode Zen static provider");
162162
}
163163
expectSeedModels(result.provider.models);
164+
// Official public-feed snapshot, 2026-08-30; connected pricing refreshes independently.
165+
expect(result.provider.models.find((model) => model.id === "gpt-5.6-sol")?.cost).toEqual({
166+
input: 2,
167+
output: 10,
168+
cacheRead: 0.2,
169+
cacheWrite: 2.5,
170+
tieredPricing: [
171+
{ input: 2, output: 10, cacheRead: 0.2, cacheWrite: 2.5, range: [0, 272_000] },
172+
{ input: 4, output: 15, cacheRead: 0.4, cacheWrite: 5, range: [272_000] },
173+
],
174+
});
164175
expectSeedModels(manifest.modelCatalog.providers.opencode.models);
165176
for (const modelId of OFFLINE_MODEL_IDS) {
166177
expect(provider.resolveDynamicModel?.({ modelId } as never)).toMatchObject({ id: modelId });

‎extensions/opencode/openclaw.plugin.json‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@
4545
"reasoning": true,
4646
"input": ["text", "image"],
4747
"cost": {
48-
"input": 5,
49-
"output": 30,
50-
"cacheRead": 0.5,
51-
"cacheWrite": 6.25,
48+
"input": 2,
49+
"output": 10,
50+
"cacheRead": 0.2,
51+
"cacheWrite": 2.5,
5252
"tieredPricing": [
5353
{
54-
"input": 5,
55-
"output": 30,
56-
"cacheRead": 0.5,
57-
"cacheWrite": 6.25,
54+
"input": 2,
55+
"output": 10,
56+
"cacheRead": 0.2,
57+
"cacheWrite": 2.5,
5858
"range": [0, 272000]
5959
},
6060
{
61-
"input": 10,
62-
"output": 45,
63-
"cacheRead": 1,
64-
"cacheWrite": 12.5,
61+
"input": 4,
62+
"output": 15,
63+
"cacheRead": 0.4,
64+
"cacheWrite": 5,
6565
"range": [272000]
6666
}
6767
]
@@ -178,6 +178,7 @@
178178
},
179179
"discovery": { "opencode": "runtime" }
180180
},
181+
"modelPricing": { "providers": { "opencode": { "openCode": { "provider": "opencode" } } } },
181182
"setup": {
182183
"providers": [
183184
{ "id": "opencode", "envVars": ["OPENCODE_API_KEY", "OPENCODE_ZEN_API_KEY"] }

0 commit comments

Comments
 (0)