Skip to content

Commit 55cf952

Browse files
feat: discover models from live provider catalogs (#112412)
* feat: discover models from live provider catalogs * fix(provider-catalog): satisfy current catalog contracts * fix(deps): update fast-uri past new advisory * fix(deps): refresh fast-uri shrinkwraps * fix(openrouter): satisfy provider catalog lint * fix(agents): preserve refreshable catalog metadata * test(agents): keep catalog fallback proof within lint budget * fix(provider-catalog): honor live model contracts * fix(minimax): type discovery headers explicitly * docs(plugin-sdk): define live model discovery contract
1 parent 0f066ee commit 55cf952

88 files changed

Lines changed: 2031 additions & 144 deletions

File tree

Some content is hidden

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

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

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,61 @@ catalog, API-key auth, and dynamic model resolution.
208208

209209
### Live model discovery
210210

211-
If your provider exposes a `/models`-style API, keep the provider-specific
212-
endpoint and row projection in your plugin and use
211+
If your provider exposes an OpenAI-compatible `/models` API, opt the
212+
single-provider helper into shared discovery:
213+
214+
```typescript
215+
catalog: {
216+
buildProvider: () => ({
217+
api: "openai-completions",
218+
baseUrl: "https://api.acme-ai.com/v1",
219+
models: [...STATIC_MODELS],
220+
}),
221+
buildStaticProvider: () => ({
222+
api: "openai-completions",
223+
baseUrl: "https://api.acme-ai.com/v1",
224+
models: [...STATIC_MODELS],
225+
}),
226+
liveModelDiscovery: true,
227+
},
228+
```
229+
230+
`liveModelDiscovery: true` is a public Plugin SDK contract with these
231+
behaviors:
232+
233+
| Area | Contract |
234+
| --- | --- |
235+
| Credentials | Discovery uses the catalog's resolved provider credential, preferring `discoveryApiKey` when auth supplies one. Secret-reference markers are never sent as tokens. The default request uses `Authorization: Bearer <token>`; use `buildRequestHeaders` for another vendor auth scheme. |
236+
| Endpoint | The default URL is `models` relative to the effective provider `baseUrl`, including an operator override when `allowExplicitBaseUrl` is enabled. Use `endpointPath` for another relative path. Use `endpointUrl: { url, requireBaseUrl }` only for a fixed vendor URL; discovery is skipped unless the effective base URL still equals `requireBaseUrl`, so a custom proxy credential is not sent to the vendor. |
237+
| Network limits | Fetches use OpenClaw's SSRF guard, one 5-second timeout budget across pagination, a 4 MiB response limit per page, and a 50-page limit. Cross-origin pagination links are rejected; credentials are removed after a cross-origin redirect. |
238+
| Cache | Successful, non-empty catalogs are cached for 60 seconds by provider, endpoint, and resolved credential. Empty or unusable results are not cached. |
239+
| Filtering | Exact live IDs keep their trusted static metadata. New rows are projected conservatively as text/chat models. Disabled, archived, deprecated, explicitly non-chat, embedding, reranking, moderation, speech, image-only, and video-only rows are excluded. Use `readRows` only to select rows from a nonstandard response envelope; provider-specific model semantics still belong in a custom catalog. |
240+
| Failure | Live discovery is advisory. Auth, network, timeout, pagination, parsing, empty-catalog, and filtering failures return the provider-owned static seed instead of removing the provider. |
241+
242+
For a non-Bearer or nonstandard list endpoint, pass options instead of
243+
`true`:
244+
245+
```typescript
246+
liveModelDiscovery: {
247+
endpointPath: "model-catalog",
248+
buildRequestHeaders: ({ apiKey, discoveryApiKey }) => ({
249+
"vendor-version": "2026-01-01",
250+
"x-api-key": discoveryApiKey ?? apiKey ?? "",
251+
}),
252+
readRows: (body) =>
253+
body && typeof body === "object" &&
254+
Array.isArray((body as { models?: unknown }).models)
255+
? (body as { models: unknown[] }).models
256+
: [],
257+
},
258+
```
259+
260+
Do not use `endpointUrl` as an unconditional alternate host. Its
261+
`requireBaseUrl` check is the credential-isolation boundary for providers
262+
whose model-list host differs from their inference host.
263+
264+
If the provider needs custom model semantics rather than the conservative
265+
OpenAI-compatible projection, keep that projection in the plugin and use
213266
`openclaw/plugin-sdk/provider-catalog-live-runtime` for the shared fetch
214267
lifecycle. The helper gives you guarded HTTP fetches, provider-auth headers,
215268
structured HTTP errors, TTL caching, and static fallback behavior without

‎docs/providers/google.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ Choose your preferred auth method and follow the setup steps.
6161
`GEMINI_API_KEY` and `GOOGLE_API_KEY` are both accepted. Use whichever you already have configured.
6262
</Tip>
6363

64+
With a configured API key, OpenClaw refreshes Google AI Studio's text-model
65+
catalog from the Gemini `models.list` API. Newly released Gemini 3 Pro, Flash,
66+
and Flash-Lite variants therefore appear in
67+
`openclaw models list --provider google` without waiting for an OpenClaw
68+
release. If discovery is unavailable, OpenClaw keeps the bundled fallback
69+
catalog.
70+
6471
</Tab>
6572

6673
<Tab title="Gemini CLI (OAuth)">

‎extensions/amazon-bedrock-mantle/openclaw.plugin.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,10 @@
3232
"help": "When false, OpenClaw keeps the Amazon Bedrock Mantle plugin available but skips implicit startup discovery. Leave unset for default auto-detect behavior."
3333
}
3434
},
35-
"providers": ["amazon-bedrock-mantle"]
35+
"providers": ["amazon-bedrock-mantle"],
36+
"modelCatalog": {
37+
"discovery": {
38+
"amazon-bedrock-mantle": "refreshable"
39+
}
40+
}
3641
}

‎extensions/amazon-bedrock/openclaw.plugin.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
},
88
"enabledByDefault": true,
99
"providers": ["amazon-bedrock"],
10+
"modelCatalog": {
11+
"discovery": {
12+
"amazon-bedrock": "refreshable"
13+
}
14+
},
1015
"contracts": {
1116
"memoryEmbeddingProviders": ["bedrock"]
1217
},

‎extensions/anthropic/openclaw.plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@
213213
},
214214
"discovery": {
215215
"claude-cli": "static",
216-
"anthropic": "static"
216+
"anthropic": "refreshable"
217217
}
218218
},
219219
"modelSupport": {

‎extensions/anthropic/openclaw.plugin.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe("Anthropic plugin manifest", () => {
7979
});
8080

8181
it("resolves both official Claude Haiku 4.5 API identifiers from the static catalog", () => {
82-
expect(manifest.modelCatalog?.discovery?.anthropic).toBe("static");
82+
expect(manifest.modelCatalog?.discovery?.anthropic).toBe("refreshable");
8383

8484
const models = manifest.modelCatalog?.providers?.anthropic?.models ?? [];
8585
for (const id of ["claude-haiku-4-5", "claude-haiku-4-5-20251001"]) {

‎extensions/anthropic/register.runtime.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import {
2525
upsertAuthProfileWithLock,
2626
validateAnthropicSetupToken,
2727
} from "openclaw/plugin-sdk/provider-auth";
28+
import { buildOpenAICompatibleProviderCatalog } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
29+
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
2830
import {
2931
buildProviderReplayFamilyHooks,
3032
cloneFirstTemplateModel,
@@ -55,6 +57,7 @@ import {
5557
normalizeAnthropicProviderConfigForProvider,
5658
} from "./config-defaults.js";
5759
import { anthropicMediaUnderstandingProvider } from "./media-understanding-provider.js";
60+
import manifest from "./openclaw.plugin.json" with { type: "json" };
5861
import { resolveClaudeCliSyntheticAuth } from "./provider-discovery.js";
5962
import { createClaudeSessionNodeInvokePolicies } from "./session-catalog-node-commands.js";
6063
import { registerClaudeSessionDiscovery } from "./session-catalog-registration.js";
@@ -115,6 +118,13 @@ const ANTHROPIC_SETUP_TOKEN_NOTE_LINES = [
115118
`If you want a direct API billing path instead, use ${formatCliCommand("openclaw models auth login --provider anthropic --method api-key --set-default")} or ${formatCliCommand("openclaw models auth login --provider anthropic --method cli --set-default")}.`,
116119
] as const;
117120

121+
function buildAnthropicCatalogProvider() {
122+
return buildManifestModelProviderConfig({
123+
providerId: PROVIDER_ID,
124+
catalog: manifest.modelCatalog.providers.anthropic,
125+
});
126+
}
127+
118128
function resolveAnthropicSonnet5Cost(nowMs: number = Date.now()) {
119129
return nowMs >= ANTHROPIC_SONNET_5_STANDARD_PRICING_START_MS
120130
? ANTHROPIC_SONNET_5_STANDARD_COST
@@ -892,6 +902,29 @@ export function buildAnthropicProvider(): ProviderPlugin {
892902
},
893903
}),
894904
],
905+
catalog: {
906+
order: "simple",
907+
run: (ctx) =>
908+
buildOpenAICompatibleProviderCatalog({
909+
ctx,
910+
providerId,
911+
buildProvider: buildAnthropicCatalogProvider,
912+
modelDiscovery: {
913+
endpointPath: "v1/models",
914+
buildRequestHeaders: ({ apiKey, discoveryApiKey }) => {
915+
const key = discoveryApiKey ?? apiKey;
916+
return {
917+
"anthropic-version": "2023-06-01",
918+
...(key ? { "x-api-key": key } : {}),
919+
};
920+
},
921+
},
922+
}),
923+
},
924+
staticCatalog: {
925+
order: "simple",
926+
run: async () => ({ provider: buildAnthropicCatalogProvider() }),
927+
},
895928
normalizeConfig: ({ provider, providerConfig }) =>
896929
normalizeAnthropicProviderConfigForProvider({ provider, providerConfig }),
897930
applyConfigDefaults: ({ config, env }) => applyAnthropicConfigDefaults({ config, env }),

‎extensions/arcee/index.ts‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
66
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
7+
import { buildOpenAICompatibleLiveModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
78
import {
89
readConfiguredProviderCatalogEntries,
910
type ProviderCatalogContext,
@@ -74,9 +75,16 @@ function buildArceeAuthMethods() {
7475
}
7576

7677
async function resolveArceeCatalog(ctx: ProviderCatalogContext) {
77-
const directKey = ctx.resolveProviderApiKey(PROVIDER_ID).apiKey;
78-
if (directKey) {
79-
return { provider: { ...buildArceeProvider(), apiKey: directKey } };
78+
const directAuth = ctx.resolveProviderApiKey(PROVIDER_ID);
79+
if (directAuth.apiKey) {
80+
return {
81+
provider: await buildOpenAICompatibleLiveModelProviderConfig({
82+
providerId: PROVIDER_ID,
83+
providerConfig: buildArceeProvider(),
84+
apiKey: directAuth.apiKey,
85+
discoveryApiKey: directAuth.discoveryApiKey,
86+
}),
87+
};
8088
}
8189

8290
const openRouterKey = ctx.resolveProviderApiKey("openrouter").apiKey;
@@ -120,6 +128,9 @@ export default definePluginEntry({
120128
catalog: {
121129
run: resolveArceeCatalog,
122130
},
131+
staticCatalog: {
132+
run: async () => ({ provider: buildArceeProvider() }),
133+
},
123134
augmentModelCatalog: ({ config }) =>
124135
readConfiguredProviderCatalogEntries({
125136
config,

‎extensions/arcee/openclaw.plugin.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
},
66
"enabledByDefault": true,
77
"providers": ["arcee"],
8+
"modelCatalog": {
9+
"discovery": {
10+
"arcee": "runtime"
11+
}
12+
},
813
"setup": {
914
"providers": [
1015
{

‎extensions/byteplus/index.ts‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
55
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
6+
import { buildOpenAICompatibleLiveModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
67
import { ensureModelAllowlistEntry } from "openclaw/plugin-sdk/provider-onboard";
78
import { BYTEPLUS_PROVIDER_CATALOG_ENTRIES } from "./provider-catalog.js";
89
import { buildBytePlusVideoGenerationProvider } from "./video-generation-provider.js";
@@ -49,20 +50,39 @@ export default definePluginEntry({
4950
catalog: {
5051
order: "paired",
5152
run: async (ctx) => {
52-
const apiKey = ctx.resolveProviderApiKey(PROVIDER_ID).apiKey;
53+
const auth = ctx.resolveProviderApiKey(PROVIDER_ID);
54+
const apiKey = auth.apiKey;
5355
if (!apiKey) {
5456
return null;
5557
}
5658
return {
5759
providers: Object.fromEntries(
58-
BYTEPLUS_PROVIDER_CATALOG_ENTRIES.map(({ id, buildProvider }) => [
59-
id,
60-
{ ...buildProvider(), apiKey },
61-
]),
60+
await Promise.all(
61+
BYTEPLUS_PROVIDER_CATALOG_ENTRIES.map(
62+
async ({ id, buildProvider }) =>
63+
[
64+
id,
65+
await buildOpenAICompatibleLiveModelProviderConfig({
66+
providerId: id,
67+
providerConfig: buildProvider(),
68+
apiKey,
69+
discoveryApiKey: auth.discoveryApiKey,
70+
}),
71+
] as const,
72+
),
73+
),
6274
),
6375
};
6476
},
6577
},
78+
staticCatalog: {
79+
order: "paired",
80+
run: async () => ({
81+
providers: Object.fromEntries(
82+
BYTEPLUS_PROVIDER_CATALOG_ENTRIES.map(({ id, buildProvider }) => [id, buildProvider()]),
83+
),
84+
}),
85+
},
6686
augmentModelCatalog: () =>
6787
BYTEPLUS_PROVIDER_CATALOG_ENTRIES.flatMap(({ id: provider, models }) =>
6888
models.map((entry) => ({

0 commit comments

Comments
 (0)