@openclaw/deepinfra-provider 2026.9.2 → 2026.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { deepinfraEmbeddingProviderAdapter } from "./embedding-adapter.js";
2
2
  import { buildDeepInfraImageGenerationProvider } from "./image-generation-provider.js";
3
3
  import { deepinfraMediaUnderstandingProvider } from "./media-understanding-provider.js";
4
- import { DEEPINFRA_DEFAULT_MODEL_REF } from "./provider-models.js";
4
+ import { DEEPINFRA_DEFAULT_MODEL_REF, buildStaticDeepInfraProvider } from "./provider-static-catalog.js";
5
5
  import { applyDeepInfraConfig } from "./onboard.js";
6
- import { buildDeepInfraProvider, buildStaticDeepInfraProvider } from "./provider-catalog.js";
6
+ import { buildDeepInfraProvider } from "./provider-catalog.js";
7
7
  import { buildDeepInfraSpeechProvider } from "./speech-provider.js";
8
8
  import { buildDeepInfraVideoGenerationProvider } from "./video-generation-provider.js";
9
9
  export { DEEPINFRA_DEFAULT_MODEL_REF, applyDeepInfraConfig, buildDeepInfraImageGenerationProvider, buildDeepInfraProvider, buildDeepInfraSpeechProvider, buildDeepInfraVideoGenerationProvider, buildStaticDeepInfraProvider, deepinfraEmbeddingProviderAdapter, deepinfraMediaUnderstandingProvider };
@@ -1,9 +1,19 @@
1
- import { applyAnthropicEphemeralCacheControlMarkers, createPayloadPatchStreamWrapper } from "openclaw/plugin-sdk/provider-stream-shared";
1
+ import { applyAnthropicEphemeralCacheControlMarkers, applyCompletionsAnthropicCacheControl, createPayloadPatchStreamWrapper } from "openclaw/plugin-sdk/provider-stream-shared";
2
2
  //#region extensions/deepinfra/cache-wrapper.ts
3
- function createDeepInfraAnthropicCacheWrapper(baseStreamFn) {
4
- return createPayloadPatchStreamWrapper(baseStreamFn, ({ payload }) => {
5
- applyAnthropicEphemeralCacheControlMarkers(payload);
6
- }, { shouldPatch: ({ model }) => model.id.toLowerCase().startsWith("anthropic/") });
3
+ function createDeepInfraAnthropicCacheWrapper(baseStreamFn, extraParams) {
4
+ return (model, context, options) => {
5
+ if (!model.id.toLowerCase().startsWith("anthropic/")) return baseStreamFn(model, context, options);
6
+ const isCompletions = model.api === "openai-completions";
7
+ const configured = options?.cacheRetention ?? extraParams?.cacheRetention;
8
+ const cacheRetention = configured === "none" || configured === "long" ? configured : "short";
9
+ return createPayloadPatchStreamWrapper(baseStreamFn, ({ payload }) => {
10
+ if (isCompletions) applyCompletionsAnthropicCacheControl(payload, cacheRetention === "none" ? null : { type: "ephemeral" });
11
+ else applyAnthropicEphemeralCacheControlMarkers(payload);
12
+ })(model, context, isCompletions ? {
13
+ ...options,
14
+ cacheRetention
15
+ } : options);
16
+ };
7
17
  }
8
18
  //#endregion
9
19
  export { createDeepInfraAnthropicCacheWrapper };
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@ import { createDeepInfraAnthropicCacheWrapper } from "./cache-wrapper.js";
2
2
  import { buildDeepInfraEmbeddingAdapter } from "./embedding-adapter.js";
3
3
  import { buildDeepInfraImageGenerationProvider } from "./image-generation-provider.js";
4
4
  import { buildDeepInfraMediaUnderstandingProvider } from "./media-understanding-provider.js";
5
- import { DEEPINFRA_DEFAULT_MODEL_REF, discoverDeepInfraModels, getDeepInfraSurfaceFallbackCatalog, hasDeepInfraApiKey } from "./provider-models.js";
5
+ import { DEEPINFRA_DEFAULT_MODEL_REF, buildStaticDeepInfraProvider } from "./provider-static-catalog.js";
6
6
  import { applyDeepInfraConfig } from "./onboard.js";
7
- import { buildDeepInfraApiKeyCatalog, buildStaticDeepInfraProvider } from "./provider-catalog.js";
7
+ import { getDeepInfraSurfaceFallbackCatalog } from "./provider-models.js";
8
+ import { buildDeepInfraApiKeyCatalog } from "./provider-catalog.js";
8
9
  import { buildDeepInfraSpeechProvider } from "./speech-provider.js";
9
10
  import { listDeepInfraImageGenCatalog, listDeepInfraVideoGenCatalog } from "./surface-model-catalogs.js";
10
11
  import { buildDeepInfraVideoGenerationProvider } from "./video-generation-provider.js";
11
- import { readConfiguredProviderCatalogEntries } from "openclaw/plugin-sdk/provider-catalog-shared";
12
12
  import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
13
13
  import { buildProviderReplayFamilyHooks } from "openclaw/plugin-sdk/provider-model-shared";
14
14
  import { createOpenRouterWrapper, isProxyReasoningUnsupported } from "openclaw/plugin-sdk/provider-stream";
@@ -47,38 +47,6 @@ var deepinfra_default = defineSingleProviderPluginEntry({
47
47
  run: (ctx) => buildDeepInfraApiKeyCatalog(ctx),
48
48
  staticRun: async () => ({ provider: buildStaticDeepInfraProvider() })
49
49
  },
50
- augmentModelCatalog: async ({ config, env, agentDir }) => {
51
- const configured = readConfiguredProviderCatalogEntries({
52
- config,
53
- providerId: PROVIDER_ID
54
- });
55
- const hasApiKey = hasDeepInfraApiKey({
56
- env,
57
- agentDir,
58
- config
59
- });
60
- const seen = new Set(configured.map((entry) => entry.id));
61
- const discovered = await discoverDeepInfraModels({
62
- hasApiKey,
63
- env,
64
- agentDir
65
- });
66
- const merged = [...configured];
67
- for (const model of discovered) {
68
- if (seen.has(model.id)) continue;
69
- seen.add(model.id);
70
- const input = model.input;
71
- merged.push({
72
- provider: PROVIDER_ID,
73
- id: model.id,
74
- name: model.name ?? model.id,
75
- ...typeof model.contextWindow === "number" && model.contextWindow > 0 ? { contextWindow: model.contextWindow } : {},
76
- ...typeof model.reasoning === "boolean" ? { reasoning: model.reasoning } : {},
77
- ...input && input.length > 0 ? { input } : {}
78
- });
79
- }
80
- return merged;
81
- },
82
50
  normalizeConfig: ({ providerConfig }) => providerConfig,
83
51
  normalizeTransport: ({ api, baseUrl }) => baseUrl === "https://api.deepinfra.com/v1/openai" ? {
84
52
  api,
@@ -87,7 +55,7 @@ var deepinfra_default = defineSingleProviderPluginEntry({
87
55
  ...buildProviderReplayFamilyHooks({ family: "passthrough-gemini" }),
88
56
  wrapStreamFn: (ctx) => {
89
57
  const thinkingLevel = isProxyReasoningUnsupported(ctx.modelId) ? void 0 : ctx.thinkingLevel;
90
- return createDeepInfraAnthropicCacheWrapper(createOpenRouterWrapper(ctx.streamFn, thinkingLevel));
58
+ return createDeepInfraAnthropicCacheWrapper(createOpenRouterWrapper(ctx.streamFn, thinkingLevel), ctx.extraParams);
91
59
  },
92
60
  isModernModelRef: () => true,
93
61
  isCacheTtlEligible: (ctx) => ctx.modelId.toLowerCase().startsWith("anthropic/")
package/dist/onboard.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEEPINFRA_DEFAULT_MODEL_REF } from "./provider-models.js";
1
+ import { DEEPINFRA_DEFAULT_MODEL_REF } from "./provider-static-catalog.js";
2
2
  import { createAliasOnlyPresetAppliers } from "openclaw/plugin-sdk/provider-onboard";
3
3
  //#region extensions/deepinfra/onboard.ts
4
4
  function applyDeepInfraConfig(cfg, modelRef = DEEPINFRA_DEFAULT_MODEL_REF) {
@@ -1,16 +1,13 @@
1
1
  import { DEEPINFRA_BASE_URL } from "./media-models.js";
2
- import { DEEPINFRA_MODEL_CATALOG, buildDeepInfraModelDefinition, discoverDeepInfraModels } from "./provider-models.js";
2
+ import { discoverDeepInfraModels } from "./provider-models.js";
3
+ import { runLiveProviderCatalog } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
3
4
  import { buildSingleProviderApiKeyCatalog } from "openclaw/plugin-sdk/provider-catalog-shared";
4
5
  //#region extensions/deepinfra/provider-catalog.ts
5
- function buildStaticDeepInfraProvider() {
6
- return {
7
- baseUrl: DEEPINFRA_BASE_URL,
8
- api: "openai-completions",
9
- models: DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition)
10
- };
11
- }
12
6
  async function buildDeepInfraProvider(options) {
13
- const models = await discoverDeepInfraModels(options);
7
+ const models = await discoverDeepInfraModels({
8
+ ...options,
9
+ discoveryMode: options?.discoveryMode ?? "advisory"
10
+ });
14
11
  return {
15
12
  baseUrl: DEEPINFRA_BASE_URL,
16
13
  api: "openai-completions",
@@ -18,15 +15,19 @@ async function buildDeepInfraProvider(options) {
18
15
  };
19
16
  }
20
17
  function buildDeepInfraApiKeyCatalog(ctx) {
21
- return buildSingleProviderApiKeyCatalog({
22
- ctx,
18
+ return runLiveProviderCatalog({
23
19
  providerId: "deepinfra",
24
- buildProvider: () => buildDeepInfraProvider({
25
- hasApiKey: true,
26
- env: ctx.env,
27
- agentDir: ctx.agentDir
20
+ run: () => buildSingleProviderApiKeyCatalog({
21
+ ctx,
22
+ providerId: "deepinfra",
23
+ buildProvider: () => buildDeepInfraProvider({
24
+ hasApiKey: true,
25
+ discoveryMode: "strict",
26
+ env: ctx.env,
27
+ agentDir: ctx.agentDir
28
+ })
28
29
  })
29
30
  });
30
31
  }
31
32
  //#endregion
32
- export { buildDeepInfraApiKeyCatalog, buildDeepInfraProvider, buildStaticDeepInfraProvider };
33
+ export { buildDeepInfraApiKeyCatalog, buildDeepInfraProvider };
@@ -1,4 +1,4 @@
1
- import { buildDeepInfraApiKeyCatalog, buildStaticDeepInfraProvider } from "./provider-catalog.js";
1
+ import { buildStaticDeepInfraProvider } from "./provider-static-catalog.js";
2
2
  //#region extensions/deepinfra/provider-discovery.ts
3
3
  const deepinfraProviderDiscovery = {
4
4
  id: "deepinfra",
@@ -7,7 +7,10 @@ const deepinfraProviderDiscovery = {
7
7
  auth: [],
8
8
  catalog: {
9
9
  order: "simple",
10
- run: (ctx) => buildDeepInfraApiKeyCatalog(ctx)
10
+ run: async (ctx) => {
11
+ const { buildDeepInfraApiKeyCatalog } = await import("./provider-catalog.js");
12
+ return await buildDeepInfraApiKeyCatalog(ctx);
13
+ }
11
14
  },
12
15
  staticCatalog: {
13
16
  order: "simple",
@@ -1,26 +1,20 @@
1
1
  import { t as modelCatalog } from "./openclaw.plugin-BRaVociw.js";
2
2
  import { DEEPINFRA_BASE_URL, DEEPINFRA_TTS_FALLBACK_CATALOG } from "./media-models.js";
3
+ import { DEEPINFRA_MODEL_CATALOG, buildDeepInfraModelDefinition } from "./provider-static-catalog.js";
3
4
  import { parseDeepInfraPricingCatalog } from "./pricing-api.js";
4
- import { buildManifestModelProviderConfig, getCachedLiveCatalogValue } from "openclaw/plugin-sdk/provider-catalog-shared";
5
- import { asPositiveSafeInteger } from "openclaw/plugin-sdk/string-coerce-runtime";
5
+ import { asPositiveSafeInteger, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
6
+ import { fetchLiveProviderModelRows } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
7
+ import { getCachedLiveCatalogValue } from "openclaw/plugin-sdk/provider-catalog-shared";
6
8
  import { withTrustedEnvProxyGuardedFetchMode } from "openclaw/plugin-sdk/fetch-runtime";
7
9
  import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
8
- import { LiveModelCatalogHttpError, fetchLiveProviderModelRows, getCachedLiveProviderModelRows } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
9
10
  import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
10
- import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input";
11
11
  import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
12
12
  //#region extensions/deepinfra/provider-models.ts
13
13
  const log = createSubsystemLogger("deepinfra-models");
14
- const DEEPINFRA_MANIFEST_PROVIDER = buildManifestModelProviderConfig({
15
- providerId: "deepinfra",
16
- catalog: modelCatalog.providers.deepinfra
17
- });
18
14
  const DEEPINFRA_MODELS_URL = `${DEEPINFRA_BASE_URL}/models?sort_by=openclaw&filter=with_meta`;
19
15
  const DEEPINFRA_PRICING_URL = "https://api.deepinfra.com/models/list";
20
- const DEEPINFRA_DEFAULT_MODEL_REF = `deepinfra/deepseek-ai/DeepSeek-V4-Flash`;
21
16
  const DEEPINFRA_DEFAULT_CONTEXT_WINDOW = 128e3;
22
17
  const DEEPINFRA_DEFAULT_MAX_TOKENS = 8192;
23
- const DEEPINFRA_MODEL_CATALOG = DEEPINFRA_MANIFEST_PROVIDER.models;
24
18
  const DISCOVERY_TIMEOUT_MS = 5e3;
25
19
  const DISCOVERY_CACHE_TTL_MS = 3e5;
26
20
  const SURFACE_FOR_TAG = {
@@ -36,14 +30,14 @@ function entryToSurfaceModel(entry) {
36
30
  const id = typeof entry?.id === "string" ? entry.id.trim() : "";
37
31
  if (!id) return null;
38
32
  const metadata = entry.metadata;
39
- if (!metadata) return null;
40
- const tags = Array.isArray(metadata.tags) ? metadata.tags.filter((t) => typeof t === "string") : [];
33
+ if (metadata === null) return null;
34
+ if (!isRecord(metadata) || !Array.isArray(metadata.tags) || metadata.tags.some((tag) => typeof tag !== "string")) throw new Error("DeepInfra model metadata discovery unavailable.");
41
35
  const pricing = metadata.pricing ?? {};
42
36
  return {
43
37
  id,
44
38
  name: id,
45
- description: metadata.description ?? void 0,
46
- tags,
39
+ description: typeof metadata.description === "string" ? metadata.description : void 0,
40
+ tags: metadata.tags,
47
41
  contextWindow: asPositiveSafeInteger(metadata.context_length),
48
42
  maxTokens: asPositiveSafeInteger(metadata.max_tokens),
49
43
  pricing,
@@ -84,9 +78,6 @@ function bucketBySurface(models) {
84
78
  }
85
79
  return catalog;
86
80
  }
87
- function hasDeepInfraSurfaceModelRows(rows) {
88
- return rows.some((entry) => entryToSurfaceModel(entry) !== null);
89
- }
90
81
  function manifestChatEntryToSurfaceModel(entry) {
91
82
  const cost = entry.cost ?? {};
92
83
  const pricing = {};
@@ -166,20 +157,6 @@ function manifestFallbackCatalog() {
166
157
  function getDeepInfraSurfaceFallbackCatalog() {
167
158
  return manifestFallbackCatalog();
168
159
  }
169
- function resolveDeepInfraThinkingFormat(modelId) {
170
- return (modelId ?? "").toLowerCase().split("/")[0] === "deepseek-ai" ? "deepseek" : void 0;
171
- }
172
- function buildDeepInfraModelDefinition(model) {
173
- const thinkingFormat = model.compat?.thinkingFormat ?? resolveDeepInfraThinkingFormat(model.id);
174
- return {
175
- ...model,
176
- compat: {
177
- ...model.compat,
178
- supportsUsageInStreaming: model.compat?.supportsUsageInStreaming ?? true,
179
- ...thinkingFormat ? { thinkingFormat } : {}
180
- }
181
- };
182
- }
183
160
  function chatSurfaceModelToModelDefinition(model) {
184
161
  const manifestModel = DEEPINFRA_MODEL_CATALOG.find((entry) => entry.id === model.id);
185
162
  const input = model.tags.includes("vlm") ? ["text", "image"] : ["text"];
@@ -194,109 +171,99 @@ function chatSurfaceModelToModelDefinition(model) {
194
171
  maxTokens: model.maxTokens ?? DEEPINFRA_DEFAULT_MAX_TOKENS
195
172
  };
196
173
  }
197
- function hasDeepInfraApiKey(options) {
174
+ function canDiscoverDeepInfra(options) {
175
+ if (options?.hasApiKey !== void 0) return options.hasApiKey;
198
176
  const fromEnv = (options?.env ?? process.env).DEEPINFRA_API_KEY;
199
- if (typeof fromEnv === "string" && fromEnv.trim() !== "") return true;
200
- const providers = options?.config?.models?.providers;
201
- for (const [providerId, provider] of Object.entries(providers ?? {})) if (providerId.trim().toLowerCase() === "deepinfra" && hasConfiguredSecretInput(provider?.apiKey, options?.config?.secrets?.defaults)) return true;
202
- return isProviderApiKeyConfigured({
177
+ return typeof fromEnv === "string" && fromEnv.trim() !== "" || isProviderApiKeyConfigured({
203
178
  provider: "deepinfra",
204
179
  agentDir: options?.agentDir
205
180
  });
206
181
  }
207
- function canDiscoverDeepInfra(options) {
208
- const env = options?.env ?? process.env;
209
- if (env.NODE_ENV === "test" || env.VITEST) return false;
210
- return options?.hasApiKey ?? hasDeepInfraApiKey({
211
- env,
212
- agentDir: options?.agentDir
213
- });
214
- }
215
182
  async function discoverDeepInfraSurfaces(options) {
216
- return canDiscoverDeepInfra(options) ? loadDeepInfraSurfaces() : manifestFallbackCatalog();
183
+ if (canDiscoverDeepInfra(options)) try {
184
+ return await loadDeepInfraSurfaces();
185
+ } catch (error) {
186
+ log.warn(`Model metadata discovery unavailable: ${String(error)}`);
187
+ }
188
+ return manifestFallbackCatalog();
217
189
  }
218
190
  async function loadDeepInfraSurfaces() {
219
- try {
220
- const data = await getCachedLiveProviderModelRows({
221
- providerId: "deepinfra",
222
- endpoint: DEEPINFRA_MODELS_URL,
223
- timeoutMs: DISCOVERY_TIMEOUT_MS,
224
- ttlMs: DISCOVERY_CACHE_TTL_MS,
225
- buildRequestHeaders: () => ({ Accept: "application/json" }),
226
- auditContext: "deepinfra-model-discovery",
227
- shouldCacheRows: hasDeepInfraSurfaceModelRows,
228
- fetchGuard: (params) => fetchWithSsrFGuard(withTrustedEnvProxyGuardedFetchMode(params))
229
- });
230
- if (data.length === 0) {
231
- log.warn("No models found from DeepInfra agent-projection endpoint, using static catalog");
232
- return manifestFallbackCatalog();
233
- }
234
- const seenIds = /* @__PURE__ */ new Set();
235
- const surfaceModels = [];
236
- for (const entry of data) {
237
- const model = entryToSurfaceModel(entry);
238
- if (!model || seenIds.has(model.id)) continue;
239
- seenIds.add(model.id);
240
- surfaceModels.push(model);
241
- }
242
- if (surfaceModels.length === 0) return manifestFallbackCatalog();
243
- return bucketBySurface(surfaceModels);
244
- } catch (error) {
245
- if (error instanceof LiveModelCatalogHttpError) {
246
- log.warn(`Failed to discover models: HTTP ${error.status}, using static catalog`);
247
- return manifestFallbackCatalog();
191
+ return getCachedLiveCatalogValue({
192
+ keyParts: [
193
+ "deepinfra",
194
+ "surfaces",
195
+ DEEPINFRA_MODELS_URL
196
+ ],
197
+ ttlMs: DISCOVERY_CACHE_TTL_MS,
198
+ load: async () => {
199
+ const data = await fetchLiveProviderModelRows({
200
+ providerId: "deepinfra",
201
+ endpoint: DEEPINFRA_MODELS_URL,
202
+ timeoutMs: DISCOVERY_TIMEOUT_MS,
203
+ buildRequestHeaders: () => ({ Accept: "application/json" }),
204
+ auditContext: "deepinfra-model-discovery",
205
+ fetchGuard: (params) => fetchWithSsrFGuard(withTrustedEnvProxyGuardedFetchMode(params))
206
+ });
207
+ const seenIds = /* @__PURE__ */ new Set();
208
+ const surfaceModels = [];
209
+ for (const entry of data) {
210
+ const model = entryToSurfaceModel(entry);
211
+ if (!model || seenIds.has(model.id)) continue;
212
+ seenIds.add(model.id);
213
+ surfaceModels.push(model);
214
+ }
215
+ if (data.length > 0 && surfaceModels.length === 0) throw new Error("DeepInfra model metadata discovery unavailable.");
216
+ return bucketBySurface(surfaceModels);
248
217
  }
249
- log.warn(`Discovery failed: ${String(error)}, using static catalog`);
250
- return manifestFallbackCatalog();
251
- }
218
+ });
252
219
  }
253
220
  async function discoverDeepInfraPricing() {
254
- try {
255
- return await getCachedLiveCatalogValue({
256
- keyParts: [
257
- "deepinfra",
258
- "native-pricing",
259
- DEEPINFRA_PRICING_URL
260
- ],
261
- ttlMs: DISCOVERY_CACHE_TTL_MS,
262
- load: async () => {
263
- const rows = await fetchLiveProviderModelRows({
264
- providerId: "deepinfra",
265
- endpoint: DEEPINFRA_PRICING_URL,
266
- timeoutMs: DISCOVERY_TIMEOUT_MS,
267
- buildRequestHeaders: () => ({ Accept: "application/json" }),
268
- auditContext: "deepinfra-pricing-discovery",
269
- fetchGuard: (params) => fetchWithSsrFGuard(withTrustedEnvProxyGuardedFetchMode(params)),
270
- readRows: (body) => {
271
- if (!Array.isArray(body)) throw new Error("Native DeepInfra pricing response must be an array");
272
- return body;
273
- }
274
- });
275
- const prices = parseDeepInfraPricingCatalog(rows);
276
- if (!prices) throw new Error("Native DeepInfra pricing is malformed or has no usable schedules");
277
- return prices;
278
- }
279
- });
280
- } catch (error) {
281
- log.warn(`Native pricing unavailable: ${String(error)}. Keeping model metadata with unknown estimates; retry discovery or configure explicit model costs.`);
282
- return;
283
- }
221
+ return await getCachedLiveCatalogValue({
222
+ keyParts: [
223
+ "deepinfra",
224
+ "native-pricing",
225
+ DEEPINFRA_PRICING_URL
226
+ ],
227
+ ttlMs: DISCOVERY_CACHE_TTL_MS,
228
+ load: async () => {
229
+ const rows = await fetchLiveProviderModelRows({
230
+ providerId: "deepinfra",
231
+ endpoint: DEEPINFRA_PRICING_URL,
232
+ timeoutMs: DISCOVERY_TIMEOUT_MS,
233
+ buildRequestHeaders: () => ({ Accept: "application/json" }),
234
+ auditContext: "deepinfra-pricing-discovery",
235
+ fetchGuard: (params) => fetchWithSsrFGuard(withTrustedEnvProxyGuardedFetchMode(params)),
236
+ readRows: (body) => {
237
+ if (!Array.isArray(body)) throw new Error("Native DeepInfra pricing response must be an array");
238
+ return body;
239
+ }
240
+ });
241
+ const prices = parseDeepInfraPricingCatalog(rows);
242
+ if (!prices) throw new Error("Native DeepInfra pricing is malformed or has no usable schedules");
243
+ return prices;
244
+ }
245
+ });
284
246
  }
285
247
  async function discoverDeepInfraModels(options) {
286
248
  if (!canDiscoverDeepInfra(options)) return DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition);
287
- const [catalog, prices] = await Promise.all([loadDeepInfraSurfaces(), discoverDeepInfraPricing()]);
288
- if (!catalog.live && !prices) return DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition);
289
- const chatModels = catalog.chat.length > 0 ? catalog.chat : [...catalog.chat, ...catalog.vlm];
290
- const liveModels = catalog.live ? chatModels.map(chatSurfaceModelToModelDefinition) : [];
291
- const seen = new Set(liveModels.map((model) => model.id));
292
- const manifestModels = DEEPINFRA_MODEL_CATALOG.filter((model) => {
293
- const unseen = !seen.has(model.id);
294
- seen.add(model.id);
295
- return unseen;
296
- });
297
- const models = [...liveModels, ...manifestModels];
249
+ const strict = options?.discoveryMode !== "advisory";
250
+ const [metadata, pricing] = await Promise.allSettled([loadDeepInfraSurfaces(), discoverDeepInfraPricing()]);
251
+ if (metadata.status === "rejected") {
252
+ if (strict) throw metadata.reason;
253
+ if (pricing.status === "rejected") return DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition);
254
+ }
255
+ const catalog = metadata.status === "fulfilled" ? metadata.value : void 0;
256
+ const chatModels = catalog ? catalog.chat.length > 0 ? catalog.chat : catalog.vlm : [];
257
+ if (strict && chatModels.length === 0) return [];
258
+ if (strict && pricing.status === "rejected") throw pricing.reason;
259
+ const prices = pricing.status === "fulfilled" ? pricing.value : void 0;
260
+ const models = chatModels.map(chatSurfaceModelToModelDefinition);
261
+ if (!strict) {
262
+ const discovered = new Set(models.map((model) => model.id));
263
+ models.push(...DEEPINFRA_MODEL_CATALOG.filter((model) => !discovered.has(model.id)));
264
+ }
298
265
  const unknownPrices = models.filter((model) => !prices?.has(model.id)).length;
299
- if (prices && unknownPrices > 0) log.warn(`Native pricing unavailable or qualified for ${unknownPrices} models; keeping metadata with unknown estimates. Configure explicit model costs if needed.`);
266
+ if (unknownPrices > 0) log.warn(`Native pricing unavailable or qualified for ${unknownPrices} models; keeping metadata with unknown estimates. Configure explicit model costs if needed.`);
300
267
  return models.map((model) => buildDeepInfraModelDefinition({
301
268
  ...model,
302
269
  cost: prices?.get(model.id) ?? {
@@ -308,4 +275,4 @@ async function discoverDeepInfraModels(options) {
308
275
  }));
309
276
  }
310
277
  //#endregion
311
- export { DEEPINFRA_DEFAULT_MODEL_REF, DEEPINFRA_MODEL_CATALOG, buildDeepInfraModelDefinition, discoverDeepInfraModels, discoverDeepInfraSurfaces, getDeepInfraSurfaceFallbackCatalog, hasDeepInfraApiKey };
278
+ export { discoverDeepInfraModels, discoverDeepInfraSurfaces, getDeepInfraSurfaceFallbackCatalog };
@@ -0,0 +1,33 @@
1
+ import { t as modelCatalog } from "./openclaw.plugin-BRaVociw.js";
2
+ import { DEEPINFRA_BASE_URL } from "./media-models.js";
3
+ import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-model-metadata";
4
+ //#region extensions/deepinfra/provider-static-catalog.ts
5
+ const DEEPINFRA_MANIFEST_PROVIDER = buildManifestModelProviderConfig({
6
+ providerId: "deepinfra",
7
+ catalog: modelCatalog.providers.deepinfra
8
+ });
9
+ const DEEPINFRA_DEFAULT_MODEL_REF = `deepinfra/deepseek-ai/DeepSeek-V4-Flash`;
10
+ const DEEPINFRA_MODEL_CATALOG = DEEPINFRA_MANIFEST_PROVIDER.models;
11
+ function resolveDeepInfraThinkingFormat(modelId) {
12
+ return (modelId ?? "").toLowerCase().split("/")[0] === "deepseek-ai" ? "deepseek" : void 0;
13
+ }
14
+ function buildDeepInfraModelDefinition(model) {
15
+ const thinkingFormat = model.compat?.thinkingFormat ?? resolveDeepInfraThinkingFormat(model.id);
16
+ return {
17
+ ...model,
18
+ compat: {
19
+ ...model.compat,
20
+ supportsUsageInStreaming: model.compat?.supportsUsageInStreaming ?? true,
21
+ ...thinkingFormat ? { thinkingFormat } : {}
22
+ }
23
+ };
24
+ }
25
+ function buildStaticDeepInfraProvider() {
26
+ return {
27
+ baseUrl: DEEPINFRA_BASE_URL,
28
+ api: "openai-completions",
29
+ models: DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition)
30
+ };
31
+ }
32
+ //#endregion
33
+ export { DEEPINFRA_DEFAULT_MODEL_REF, DEEPINFRA_MODEL_CATALOG, buildDeepInfraModelDefinition, buildStaticDeepInfraProvider };
@@ -1,5 +1,10 @@
1
1
  {
2
2
  "id": "deepinfra",
3
+ "categories": [
4
+ "models",
5
+ "memory",
6
+ "voice"
7
+ ],
3
8
  "capabilityCatalogEntry": "./dist/capability-catalog.js",
4
9
  "doctorContract": {
5
10
  "configRepair": true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/deepinfra-provider",
3
- "version": "2026.9.2",
3
+ "version": "2026.9.4",
4
4
  "description": "OpenClaw DeepInfra provider plugin.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,10 +18,10 @@
18
18
  "minHostVersion": ">=2026.6.8"
19
19
  },
20
20
  "compat": {
21
- "pluginApi": ">=2026.9.2"
21
+ "pluginApi": ">=2026.9.4"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.9.2",
24
+ "openclawVersion": "2026.9.4",
25
25
  "bundledDist": false
26
26
  },
27
27
  "release": {
@@ -38,7 +38,7 @@
38
38
  "README.md"
39
39
  ],
40
40
  "peerDependencies": {
41
- "openclaw": ">=2026.9.2"
41
+ "openclaw": ">=2026.9.4"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "openclaw": {