@openclaw/deepinfra-provider 2026.8.2 → 2026.9.1
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/doctor-contract-api.js +1 -1
- package/dist/image-generation-provider.js +2 -1
- package/dist/{openclaw.plugin-DomWf43f.js → openclaw.plugin-CWb9nYB8.js} +8 -8
- package/dist/pricing-api.js +51 -0
- package/dist/provider-models.js +66 -22
- package/openclaw.plugin.json +13 -8
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as modelCatalog } from "./openclaw.plugin-
|
|
1
|
+
import { t as modelCatalog } from "./openclaw.plugin-CWb9nYB8.js";
|
|
2
2
|
import { asObjectRecord } from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
3
3
|
//#region extensions/deepinfra/doctor-contract-api.ts
|
|
4
4
|
const PROVIDER_PATH = "models.providers.deepinfra";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DEEPINFRA_BASE_URL } from "./provider-models.js";
|
|
2
2
|
import { DEEPINFRA_IMAGE_FALLBACK_MODELS, normalizeDeepInfraBaseUrl, normalizeDeepInfraModelRef } from "./media-models.js";
|
|
3
3
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
+
import { bufferToBlobPart } from "openclaw/plugin-sdk/blob-runtime";
|
|
4
5
|
import { createOpenAiCompatibleImageGenerationProvider, imageSourceUploadFileName } from "openclaw/plugin-sdk/image-generation";
|
|
5
6
|
//#region extensions/deepinfra/image-generation-provider.ts
|
|
6
7
|
const DEEPINFRA_IMAGE_SIZES = [
|
|
@@ -61,7 +62,7 @@ function buildDeepInfraImageGenerationProvider(options) {
|
|
|
61
62
|
form.set("size", normalizeOptionalString(req.size) ?? "1024x1024");
|
|
62
63
|
form.set("response_format", "b64_json");
|
|
63
64
|
const mimeType = normalizeOptionalString(image.mimeType) ?? "image/png";
|
|
64
|
-
form.append("image", new Blob([
|
|
65
|
+
form.append("image", new Blob([bufferToBlobPart(image.buffer)], { type: mimeType }), imageSourceUploadFileName({
|
|
65
66
|
image,
|
|
66
67
|
index: 0
|
|
67
68
|
}));
|
|
@@ -48,9 +48,9 @@ var modelCatalog = {
|
|
|
48
48
|
"contextWindow": 1048576,
|
|
49
49
|
"maxTokens": 1048576,
|
|
50
50
|
"cost": {
|
|
51
|
-
"input": .
|
|
52
|
-
"output":
|
|
53
|
-
"cacheRead": .
|
|
51
|
+
"input": .4875,
|
|
52
|
+
"output": 1.56,
|
|
53
|
+
"cacheRead": .091000001625,
|
|
54
54
|
"cacheWrite": 0
|
|
55
55
|
},
|
|
56
56
|
"compat": {
|
|
@@ -81,9 +81,9 @@ var modelCatalog = {
|
|
|
81
81
|
"contextWindow": 262144,
|
|
82
82
|
"maxTokens": 262144,
|
|
83
83
|
"cost": {
|
|
84
|
-
"input": .
|
|
85
|
-
"output": 3.
|
|
86
|
-
"cacheRead": .
|
|
84
|
+
"input": .68,
|
|
85
|
+
"output": 3.4,
|
|
86
|
+
"cacheRead": .136,
|
|
87
87
|
"cacheWrite": 0
|
|
88
88
|
},
|
|
89
89
|
"compat": { "supportsUsageInStreaming": true }
|
|
@@ -180,9 +180,9 @@ var modelCatalog = {
|
|
|
180
180
|
"contextWindow": 262144,
|
|
181
181
|
"maxTokens": 262144,
|
|
182
182
|
"cost": {
|
|
183
|
-
"input": .
|
|
183
|
+
"input": .09,
|
|
184
184
|
"output": .3,
|
|
185
|
-
"cacheRead": .
|
|
185
|
+
"cacheRead": .0199999998,
|
|
186
186
|
"cacheWrite": 0
|
|
187
187
|
},
|
|
188
188
|
"compat": { "supportsUsageInStreaming": true }
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { asFiniteNumberInRange, asOptionalRecord, asPositiveSafeInteger } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
|
+
import { normalizeModelPricingCatalog } from "openclaw/plugin-sdk/model-catalog-pricing";
|
|
3
|
+
//#region extensions/deepinfra/pricing-api.ts
|
|
4
|
+
function normalizeDeepInfraTokenPricing(value) {
|
|
5
|
+
const row = asOptionalRecord(value);
|
|
6
|
+
if (!row || row.type !== void 0 && row.type !== "tokens") return;
|
|
7
|
+
const discount = asFiniteNumberInRange(row.discount ?? 0, {
|
|
8
|
+
min: 0,
|
|
9
|
+
max: 1
|
|
10
|
+
});
|
|
11
|
+
const inputCents = asFiniteNumberInRange(row.cents_per_input_token, { min: 0 });
|
|
12
|
+
const outputCents = asFiniteNumberInRange(row.cents_per_output_token, { min: 0 });
|
|
13
|
+
const cacheRatio = asFiniteNumberInRange(row.rate_per_input_token_cached ?? 0, { min: 0 });
|
|
14
|
+
const table = row.table == null ? void 0 : asOptionalRecord(row.table);
|
|
15
|
+
const explicitWrites = row.rate_per_explicit_cache_write_token;
|
|
16
|
+
const writeRates = explicitWrites == null ? void 0 : asOptionalRecord(explicitWrites);
|
|
17
|
+
if (discount === void 0 || inputCents === void 0 || outputCents === void 0 || cacheRatio === void 0 || row.full != null && typeof row.full !== "string" || row.table != null && !table || row.discount_ends_at != null && !Number.isSafeInteger(row.discount_ends_at) || [
|
|
18
|
+
"rate_per_input_token_cache_write",
|
|
19
|
+
"rate_per_service_tier_priority",
|
|
20
|
+
"rate_per_service_tier_flex"
|
|
21
|
+
].some((key) => row[key] != null && asFiniteNumberInRange(row[key], { min: 0 }) === void 0) || explicitWrites != null && (!writeRates || Object.values(writeRates).some((rate) => asFiniteNumberInRange(rate, { min: 0 }) === void 0)) || row.explicit_cache_granularity_tokens != null && asPositiveSafeInteger(row.explicit_cache_granularity_tokens) === void 0) return;
|
|
22
|
+
const input = inputCents * 1e4 * (1 - discount);
|
|
23
|
+
const output = outputCents * 1e4 * (1 - discount);
|
|
24
|
+
const cacheRead = input * cacheRatio;
|
|
25
|
+
return [
|
|
26
|
+
input,
|
|
27
|
+
output,
|
|
28
|
+
cacheRead
|
|
29
|
+
].every(Number.isFinite) ? {
|
|
30
|
+
input,
|
|
31
|
+
output,
|
|
32
|
+
cacheRead,
|
|
33
|
+
cacheWrite: 0
|
|
34
|
+
} : void 0;
|
|
35
|
+
}
|
|
36
|
+
/** Pure native price owner shared by hosted publication and chat discovery. */
|
|
37
|
+
function parseDeepInfraPricingCatalog(payload) {
|
|
38
|
+
return normalizeModelPricingCatalog(payload, normalizeDeepInfraTokenPricing, {
|
|
39
|
+
readModelId: (model) => model.model_name,
|
|
40
|
+
readPricing: (model) => {
|
|
41
|
+
const pricing = asOptionalRecord(model.pricing);
|
|
42
|
+
return typeof pricing?.type === "string" && pricing.type !== "tokens" ? void 0 : model.pricing;
|
|
43
|
+
},
|
|
44
|
+
isSupportedPricing: (value) => {
|
|
45
|
+
const row = asOptionalRecord(value);
|
|
46
|
+
return row !== void 0 && !row.full && Object.keys(asOptionalRecord(row.table) ?? {}).length === 0 && row.discount_ends_at == null && row.rate_per_input_token_cache_write == null;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { parseDeepInfraPricingCatalog };
|
package/dist/provider-models.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { t as modelCatalog } from "./openclaw.plugin-
|
|
2
|
-
import {
|
|
1
|
+
import { t as modelCatalog } from "./openclaw.plugin-CWb9nYB8.js";
|
|
2
|
+
import { parseDeepInfraPricingCatalog } from "./pricing-api.js";
|
|
3
|
+
import { buildManifestModelProviderConfig, getCachedLiveCatalogValue } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
3
4
|
import { asPositiveSafeInteger } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
5
|
import { withTrustedEnvProxyGuardedFetchMode } from "openclaw/plugin-sdk/fetch-runtime";
|
|
5
6
|
import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
|
|
6
|
-
import { LiveModelCatalogHttpError, getCachedLiveProviderModelRows } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
|
|
7
|
+
import { LiveModelCatalogHttpError, fetchLiveProviderModelRows, getCachedLiveProviderModelRows } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
|
|
7
8
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
8
9
|
import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input";
|
|
9
10
|
import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
@@ -15,6 +16,7 @@ const DEEPINFRA_MANIFEST_PROVIDER = buildManifestModelProviderConfig({
|
|
|
15
16
|
});
|
|
16
17
|
const DEEPINFRA_BASE_URL = DEEPINFRA_MANIFEST_PROVIDER.baseUrl;
|
|
17
18
|
const DEEPINFRA_MODELS_URL = `${DEEPINFRA_BASE_URL}/models?sort_by=openclaw&filter=with_meta`;
|
|
19
|
+
const DEEPINFRA_PRICING_URL = "https://api.deepinfra.com/models/list";
|
|
18
20
|
const DEEPINFRA_DEFAULT_MODEL_REF = `deepinfra/deepseek-ai/DeepSeek-V4-Flash`;
|
|
19
21
|
const DEEPINFRA_DEFAULT_CONTEXT_WINDOW = 128e3;
|
|
20
22
|
const DEEPINFRA_DEFAULT_MAX_TOKENS = 8192;
|
|
@@ -205,21 +207,15 @@ function chatSurfaceModelToModelDefinition(model) {
|
|
|
205
207
|
const manifestModel = DEEPINFRA_MODEL_CATALOG.find((entry) => entry.id === model.id);
|
|
206
208
|
const input = model.tags.includes("vlm") ? ["text", "image"] : ["text"];
|
|
207
209
|
const reasoning = model.tags.includes("reasoning") || model.tags.includes("reasoning_effort");
|
|
208
|
-
return
|
|
210
|
+
return {
|
|
209
211
|
id: model.id,
|
|
210
212
|
name: model.name,
|
|
211
213
|
reasoning: manifestModel?.reasoning ?? reasoning,
|
|
212
214
|
input,
|
|
213
215
|
...manifestModel?.compat ? { compat: manifestModel.compat } : {},
|
|
214
216
|
contextWindow: model.contextWindow ?? DEEPINFRA_DEFAULT_CONTEXT_WINDOW,
|
|
215
|
-
maxTokens: model.maxTokens ?? DEEPINFRA_DEFAULT_MAX_TOKENS
|
|
216
|
-
|
|
217
|
-
input: model.pricing.input_tokens ?? 0,
|
|
218
|
-
output: model.pricing.output_tokens ?? 0,
|
|
219
|
-
cacheRead: model.pricing.cache_read_tokens ?? 0,
|
|
220
|
-
cacheWrite: 0
|
|
221
|
-
}
|
|
222
|
-
});
|
|
217
|
+
maxTokens: model.maxTokens ?? DEEPINFRA_DEFAULT_MAX_TOKENS
|
|
218
|
+
};
|
|
223
219
|
}
|
|
224
220
|
function hasDeepInfraApiKey(options) {
|
|
225
221
|
const fromEnv = (options?.env ?? process.env).DEEPINFRA_API_KEY;
|
|
@@ -231,13 +227,18 @@ function hasDeepInfraApiKey(options) {
|
|
|
231
227
|
agentDir: options?.agentDir
|
|
232
228
|
});
|
|
233
229
|
}
|
|
234
|
-
|
|
230
|
+
function canDiscoverDeepInfra(options) {
|
|
235
231
|
const env = options?.env ?? process.env;
|
|
236
|
-
if (env.NODE_ENV === "test" || env.VITEST) return
|
|
237
|
-
|
|
232
|
+
if (env.NODE_ENV === "test" || env.VITEST) return false;
|
|
233
|
+
return options?.hasApiKey ?? hasDeepInfraApiKey({
|
|
238
234
|
env,
|
|
239
235
|
agentDir: options?.agentDir
|
|
240
|
-
})
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
async function discoverDeepInfraSurfaces(options) {
|
|
239
|
+
return canDiscoverDeepInfra(options) ? loadDeepInfraSurfaces() : manifestFallbackCatalog();
|
|
240
|
+
}
|
|
241
|
+
async function loadDeepInfraSurfaces() {
|
|
241
242
|
try {
|
|
242
243
|
const data = await getCachedLiveProviderModelRows({
|
|
243
244
|
providerId: "deepinfra",
|
|
@@ -272,19 +273,62 @@ async function discoverDeepInfraSurfaces(options) {
|
|
|
272
273
|
return manifestFallbackCatalog();
|
|
273
274
|
}
|
|
274
275
|
}
|
|
276
|
+
async function discoverDeepInfraPricing() {
|
|
277
|
+
try {
|
|
278
|
+
return await getCachedLiveCatalogValue({
|
|
279
|
+
keyParts: [
|
|
280
|
+
"deepinfra",
|
|
281
|
+
"native-pricing",
|
|
282
|
+
DEEPINFRA_PRICING_URL
|
|
283
|
+
],
|
|
284
|
+
ttlMs: DISCOVERY_CACHE_TTL_MS,
|
|
285
|
+
load: async () => {
|
|
286
|
+
const rows = await fetchLiveProviderModelRows({
|
|
287
|
+
providerId: "deepinfra",
|
|
288
|
+
endpoint: DEEPINFRA_PRICING_URL,
|
|
289
|
+
timeoutMs: DISCOVERY_TIMEOUT_MS,
|
|
290
|
+
buildRequestHeaders: () => ({ Accept: "application/json" }),
|
|
291
|
+
auditContext: "deepinfra-pricing-discovery",
|
|
292
|
+
fetchGuard: (params) => fetchWithSsrFGuard(withTrustedEnvProxyGuardedFetchMode(params)),
|
|
293
|
+
readRows: (body) => {
|
|
294
|
+
if (!Array.isArray(body)) throw new Error("Native DeepInfra pricing response must be an array");
|
|
295
|
+
return body;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
const prices = parseDeepInfraPricingCatalog(rows);
|
|
299
|
+
if (!prices) throw new Error("Native DeepInfra pricing is malformed or has no usable schedules");
|
|
300
|
+
return prices;
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
} catch (error) {
|
|
304
|
+
log.warn(`Native pricing unavailable: ${String(error)}. Keeping model metadata with unknown estimates; retry discovery or configure explicit model costs.`);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
275
308
|
async function discoverDeepInfraModels(options) {
|
|
276
|
-
|
|
277
|
-
|
|
309
|
+
if (!canDiscoverDeepInfra(options)) return DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition);
|
|
310
|
+
const [catalog, prices] = await Promise.all([loadDeepInfraSurfaces(), discoverDeepInfraPricing()]);
|
|
311
|
+
if (!catalog.live && !prices) return DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition);
|
|
278
312
|
const chatModels = catalog.chat.length > 0 ? catalog.chat : [...catalog.chat, ...catalog.vlm];
|
|
279
|
-
|
|
280
|
-
const liveModels = chatModels.map(chatSurfaceModelToModelDefinition);
|
|
313
|
+
const liveModels = catalog.live ? chatModels.map(chatSurfaceModelToModelDefinition) : [];
|
|
281
314
|
const seen = new Set(liveModels.map((model) => model.id));
|
|
282
315
|
const manifestModels = DEEPINFRA_MODEL_CATALOG.filter((model) => {
|
|
283
316
|
const unseen = !seen.has(model.id);
|
|
284
317
|
seen.add(model.id);
|
|
285
318
|
return unseen;
|
|
286
|
-
})
|
|
287
|
-
|
|
319
|
+
});
|
|
320
|
+
const models = [...liveModels, ...manifestModels];
|
|
321
|
+
const unknownPrices = models.filter((model) => !prices?.has(model.id)).length;
|
|
322
|
+
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.`);
|
|
323
|
+
return models.map((model) => buildDeepInfraModelDefinition({
|
|
324
|
+
...model,
|
|
325
|
+
cost: prices?.get(model.id) ?? {
|
|
326
|
+
input: 0,
|
|
327
|
+
output: 0,
|
|
328
|
+
cacheRead: 0,
|
|
329
|
+
cacheWrite: 0
|
|
330
|
+
}
|
|
331
|
+
}));
|
|
288
332
|
}
|
|
289
333
|
//#endregion
|
|
290
334
|
export { DEEPINFRA_BASE_URL, DEEPINFRA_DEFAULT_MODEL_REF, DEEPINFRA_MODEL_CATALOG, buildDeepInfraModelDefinition, discoverDeepInfraModels, discoverDeepInfraSurfaces, getDeepInfraSurfaceFallbackCatalog, hasDeepInfraApiKey };
|
package/openclaw.plugin.json
CHANGED
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
"contextWindow": 1048576,
|
|
82
82
|
"maxTokens": 1048576,
|
|
83
83
|
"cost": {
|
|
84
|
-
"input": 0.
|
|
85
|
-
"output":
|
|
86
|
-
"cacheRead": 0.
|
|
84
|
+
"input": 0.4875,
|
|
85
|
+
"output": 1.56,
|
|
86
|
+
"cacheRead": 0.091000001625,
|
|
87
87
|
"cacheWrite": 0
|
|
88
88
|
},
|
|
89
89
|
"compat": {
|
|
@@ -116,9 +116,9 @@
|
|
|
116
116
|
"contextWindow": 262144,
|
|
117
117
|
"maxTokens": 262144,
|
|
118
118
|
"cost": {
|
|
119
|
-
"input": 0.
|
|
120
|
-
"output": 3.
|
|
121
|
-
"cacheRead": 0.
|
|
119
|
+
"input": 0.68,
|
|
120
|
+
"output": 3.4,
|
|
121
|
+
"cacheRead": 0.136,
|
|
122
122
|
"cacheWrite": 0
|
|
123
123
|
},
|
|
124
124
|
"compat": {
|
|
@@ -225,9 +225,9 @@
|
|
|
225
225
|
"contextWindow": 262144,
|
|
226
226
|
"maxTokens": 262144,
|
|
227
227
|
"cost": {
|
|
228
|
-
"input": 0.
|
|
228
|
+
"input": 0.09,
|
|
229
229
|
"output": 0.3,
|
|
230
|
-
"cacheRead": 0.
|
|
230
|
+
"cacheRead": 0.0199999998,
|
|
231
231
|
"cacheWrite": 0
|
|
232
232
|
},
|
|
233
233
|
"compat": {
|
|
@@ -260,6 +260,11 @@
|
|
|
260
260
|
"deepinfra": "refreshable"
|
|
261
261
|
}
|
|
262
262
|
},
|
|
263
|
+
"modelPricing": {
|
|
264
|
+
"providers": {
|
|
265
|
+
"deepinfra": { "deepinfra": { "provider": "deepinfra" } }
|
|
266
|
+
}
|
|
267
|
+
},
|
|
263
268
|
"providerAuthChoices": [
|
|
264
269
|
{
|
|
265
270
|
"provider": "deepinfra",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/deepinfra-provider",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.9.1",
|
|
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.
|
|
21
|
+
"pluginApi": ">=2026.9.1"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.
|
|
24
|
+
"openclawVersion": "2026.9.1",
|
|
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.
|
|
41
|
+
"openclaw": ">=2026.9.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"openclaw": {
|