@openclaw/deepinfra-provider 0.0.0 → 2026.6.9
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/README.md +11 -2
- package/dist/api.js +9 -0
- package/dist/cache-wrapper.js +13 -0
- package/dist/embedding-provider.js +27 -0
- package/dist/image-generation-provider.js +86 -0
- package/dist/index.js +118 -0
- package/dist/media-models.js +45 -0
- package/dist/media-understanding-provider.js +35 -0
- package/dist/memory-embedding-adapter.js +36 -0
- package/dist/onboard.js +22 -0
- package/dist/provider-catalog.js +30 -0
- package/dist/provider-discovery.js +18 -0
- package/dist/provider-models-BLNlFB8o.js +413 -0
- package/dist/provider-models.js +2 -0
- package/dist/provider-policy-api.js +19 -0
- package/dist/speech-provider.js +40 -0
- package/dist/surface-model-catalogs.js +72 -0
- package/dist/video-generation-provider.js +179 -0
- package/npm-shrinkwrap.json +12 -0
- package/openclaw.plugin.json +224 -0
- package/package.json +44 -8
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
2
|
+
import { asPositiveSafeInteger } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
|
|
4
|
+
import { LiveModelCatalogHttpError, clearLiveCatalogCacheForTests, getCachedLiveProviderModelRows } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
|
|
5
|
+
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
6
|
+
import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input";
|
|
7
|
+
//#region extensions/deepinfra/openclaw.plugin.json
|
|
8
|
+
var modelCatalog = {
|
|
9
|
+
"providers": { "deepinfra": {
|
|
10
|
+
"baseUrl": "https://api.deepinfra.com/v1/openai",
|
|
11
|
+
"api": "openai-completions",
|
|
12
|
+
"models": [
|
|
13
|
+
{
|
|
14
|
+
"id": "deepseek-ai/DeepSeek-V4-Flash",
|
|
15
|
+
"name": "DeepSeek V4 Flash",
|
|
16
|
+
"reasoning": true,
|
|
17
|
+
"input": ["text"],
|
|
18
|
+
"contextWindow": 1048576,
|
|
19
|
+
"maxTokens": 1048576,
|
|
20
|
+
"cost": {
|
|
21
|
+
"input": .1,
|
|
22
|
+
"output": .2,
|
|
23
|
+
"cacheRead": .02,
|
|
24
|
+
"cacheWrite": 0
|
|
25
|
+
},
|
|
26
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "deepseek-ai/DeepSeek-V3.2",
|
|
30
|
+
"name": "DeepSeek V3.2",
|
|
31
|
+
"reasoning": false,
|
|
32
|
+
"input": ["text"],
|
|
33
|
+
"contextWindow": 163840,
|
|
34
|
+
"maxTokens": 163840,
|
|
35
|
+
"cost": {
|
|
36
|
+
"input": .26,
|
|
37
|
+
"output": .38,
|
|
38
|
+
"cacheRead": .13,
|
|
39
|
+
"cacheWrite": 0
|
|
40
|
+
},
|
|
41
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "zai-org/GLM-5.1",
|
|
45
|
+
"name": "GLM-5.1",
|
|
46
|
+
"reasoning": true,
|
|
47
|
+
"input": ["text"],
|
|
48
|
+
"contextWindow": 202752,
|
|
49
|
+
"maxTokens": 202752,
|
|
50
|
+
"cost": {
|
|
51
|
+
"input": 1.05,
|
|
52
|
+
"output": 3.5,
|
|
53
|
+
"cacheRead": .205000005,
|
|
54
|
+
"cacheWrite": 0
|
|
55
|
+
},
|
|
56
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "stepfun-ai/Step-3.5-Flash",
|
|
60
|
+
"name": "Step 3.5 Flash",
|
|
61
|
+
"reasoning": false,
|
|
62
|
+
"input": ["text"],
|
|
63
|
+
"contextWindow": 262144,
|
|
64
|
+
"maxTokens": 262144,
|
|
65
|
+
"cost": {
|
|
66
|
+
"input": .1,
|
|
67
|
+
"output": .3,
|
|
68
|
+
"cacheRead": .02,
|
|
69
|
+
"cacheWrite": 0
|
|
70
|
+
},
|
|
71
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": "MiniMaxAI/MiniMax-M2.5",
|
|
75
|
+
"name": "MiniMax M2.5",
|
|
76
|
+
"reasoning": true,
|
|
77
|
+
"input": ["text"],
|
|
78
|
+
"contextWindow": 196608,
|
|
79
|
+
"maxTokens": 196608,
|
|
80
|
+
"cost": {
|
|
81
|
+
"input": .15,
|
|
82
|
+
"output": 1.15,
|
|
83
|
+
"cacheRead": .03,
|
|
84
|
+
"cacheWrite": 0
|
|
85
|
+
},
|
|
86
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "moonshotai/Kimi-K2.5",
|
|
90
|
+
"name": "Kimi K2.5",
|
|
91
|
+
"reasoning": true,
|
|
92
|
+
"input": ["text", "image"],
|
|
93
|
+
"contextWindow": 262144,
|
|
94
|
+
"maxTokens": 262144,
|
|
95
|
+
"cost": {
|
|
96
|
+
"input": .45,
|
|
97
|
+
"output": 2.25,
|
|
98
|
+
"cacheRead": .070000002,
|
|
99
|
+
"cacheWrite": 0
|
|
100
|
+
},
|
|
101
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"id": "nvidia/NVIDIA-Nemotron-3-Super-120B-A12B",
|
|
105
|
+
"name": "NVIDIA Nemotron 3 Super 120B A12B",
|
|
106
|
+
"reasoning": true,
|
|
107
|
+
"input": ["text"],
|
|
108
|
+
"contextWindow": 262144,
|
|
109
|
+
"maxTokens": 262144,
|
|
110
|
+
"cost": {
|
|
111
|
+
"input": .1,
|
|
112
|
+
"output": .5,
|
|
113
|
+
"cacheRead": 0,
|
|
114
|
+
"cacheWrite": 0
|
|
115
|
+
},
|
|
116
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"id": "meta-llama/Llama-3.3-70B-Instruct-Turbo",
|
|
120
|
+
"name": "Llama 3.3 70B Instruct Turbo",
|
|
121
|
+
"reasoning": false,
|
|
122
|
+
"input": ["text"],
|
|
123
|
+
"contextWindow": 131072,
|
|
124
|
+
"maxTokens": 131072,
|
|
125
|
+
"cost": {
|
|
126
|
+
"input": .1,
|
|
127
|
+
"output": .32,
|
|
128
|
+
"cacheRead": 0,
|
|
129
|
+
"cacheWrite": 0
|
|
130
|
+
},
|
|
131
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
} },
|
|
135
|
+
"discovery": { "deepinfra": "refreshable" }
|
|
136
|
+
};
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region extensions/deepinfra/provider-models.ts
|
|
139
|
+
const log = createSubsystemLogger("deepinfra-models");
|
|
140
|
+
const DEEPINFRA_MANIFEST_PROVIDER = buildManifestModelProviderConfig({
|
|
141
|
+
providerId: "deepinfra",
|
|
142
|
+
catalog: modelCatalog.providers.deepinfra
|
|
143
|
+
});
|
|
144
|
+
const DEEPINFRA_BASE_URL = DEEPINFRA_MANIFEST_PROVIDER.baseUrl;
|
|
145
|
+
const DEEPINFRA_MODELS_URL = `${DEEPINFRA_BASE_URL}/models?sort_by=openclaw&filter=with_meta`;
|
|
146
|
+
const DEEPINFRA_DEFAULT_MODEL_ID = "deepseek-ai/DeepSeek-V4-Flash";
|
|
147
|
+
const DEEPINFRA_DEFAULT_MODEL_REF = `deepinfra/${DEEPINFRA_DEFAULT_MODEL_ID}`;
|
|
148
|
+
const DEEPINFRA_DEFAULT_CONTEXT_WINDOW = 128e3;
|
|
149
|
+
const DEEPINFRA_DEFAULT_MAX_TOKENS = 8192;
|
|
150
|
+
const DEEPINFRA_MODEL_CATALOG = DEEPINFRA_MANIFEST_PROVIDER.models;
|
|
151
|
+
const DISCOVERY_TIMEOUT_MS = 5e3;
|
|
152
|
+
const DISCOVERY_CACHE_TTL_MS = 300 * 1e3;
|
|
153
|
+
function resetDeepInfraModelCacheForTest() {
|
|
154
|
+
clearLiveCatalogCacheForTests();
|
|
155
|
+
}
|
|
156
|
+
const SURFACE_FOR_TAG = {
|
|
157
|
+
chat: "chat",
|
|
158
|
+
vlm: "vlm",
|
|
159
|
+
embed: "embed",
|
|
160
|
+
"image-gen": "image-gen",
|
|
161
|
+
"video-gen": "video-gen",
|
|
162
|
+
tts: "tts",
|
|
163
|
+
stt: "stt"
|
|
164
|
+
};
|
|
165
|
+
function entryToSurfaceModel(entry) {
|
|
166
|
+
const id = typeof entry?.id === "string" ? entry.id.trim() : "";
|
|
167
|
+
if (!id) return null;
|
|
168
|
+
const metadata = entry.metadata;
|
|
169
|
+
if (!metadata) return null;
|
|
170
|
+
const tags = Array.isArray(metadata.tags) ? metadata.tags.filter((t) => typeof t === "string") : [];
|
|
171
|
+
const pricing = metadata.pricing ?? {};
|
|
172
|
+
return {
|
|
173
|
+
id,
|
|
174
|
+
name: id,
|
|
175
|
+
description: metadata.description ?? void 0,
|
|
176
|
+
tags,
|
|
177
|
+
contextWindow: asPositiveSafeInteger(metadata.context_length),
|
|
178
|
+
maxTokens: asPositiveSafeInteger(metadata.max_tokens),
|
|
179
|
+
pricing,
|
|
180
|
+
defaultWidth: asPositiveSafeInteger(metadata.default_width),
|
|
181
|
+
defaultHeight: asPositiveSafeInteger(metadata.default_height),
|
|
182
|
+
defaultIterations: asPositiveSafeInteger(metadata.default_iterations)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function bucketBySurface(models) {
|
|
186
|
+
const catalog = {
|
|
187
|
+
chat: [],
|
|
188
|
+
vlm: [],
|
|
189
|
+
embed: [],
|
|
190
|
+
imageGen: [],
|
|
191
|
+
videoGen: [],
|
|
192
|
+
tts: [],
|
|
193
|
+
stt: [],
|
|
194
|
+
live: true
|
|
195
|
+
};
|
|
196
|
+
const buckets = {
|
|
197
|
+
chat: catalog.chat,
|
|
198
|
+
vlm: catalog.vlm,
|
|
199
|
+
embed: catalog.embed,
|
|
200
|
+
"image-gen": catalog.imageGen,
|
|
201
|
+
"video-gen": catalog.videoGen,
|
|
202
|
+
tts: catalog.tts,
|
|
203
|
+
stt: catalog.stt
|
|
204
|
+
};
|
|
205
|
+
for (const model of models) {
|
|
206
|
+
const seen = /* @__PURE__ */ new Set();
|
|
207
|
+
for (const tag of model.tags) {
|
|
208
|
+
const surface = SURFACE_FOR_TAG[tag];
|
|
209
|
+
if (surface && !seen.has(surface)) {
|
|
210
|
+
seen.add(surface);
|
|
211
|
+
buckets[surface].push(model);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return catalog;
|
|
216
|
+
}
|
|
217
|
+
function hasDeepInfraSurfaceModelRows(rows) {
|
|
218
|
+
return rows.some((entry) => entryToSurfaceModel(entry) !== null);
|
|
219
|
+
}
|
|
220
|
+
function manifestChatEntryToSurfaceModel(entry) {
|
|
221
|
+
const cost = entry.cost ?? {};
|
|
222
|
+
const pricing = {};
|
|
223
|
+
if (typeof cost.input === "number") pricing.input_tokens = cost.input;
|
|
224
|
+
if (typeof cost.output === "number") pricing.output_tokens = cost.output;
|
|
225
|
+
if (typeof cost.cacheRead === "number" && cost.cacheRead > 0) pricing.cache_read_tokens = cost.cacheRead;
|
|
226
|
+
const tags = ["chat"];
|
|
227
|
+
if (entry.input?.includes("image")) tags.push("vlm");
|
|
228
|
+
if (entry.reasoning) tags.push("reasoning");
|
|
229
|
+
return {
|
|
230
|
+
id: entry.id,
|
|
231
|
+
name: entry.name ?? entry.id,
|
|
232
|
+
tags,
|
|
233
|
+
contextWindow: entry.contextWindow,
|
|
234
|
+
maxTokens: entry.maxTokens,
|
|
235
|
+
pricing
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
const STATIC_NON_CHAT_FALLBACK = [
|
|
239
|
+
{
|
|
240
|
+
id: "black-forest-labs/FLUX-1-schnell",
|
|
241
|
+
name: "black-forest-labs/FLUX-1-schnell",
|
|
242
|
+
tags: ["image-gen"],
|
|
243
|
+
pricing: { per_image_unit: .003 },
|
|
244
|
+
defaultWidth: 1024,
|
|
245
|
+
defaultHeight: 1024,
|
|
246
|
+
defaultIterations: 4
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
id: "black-forest-labs/FLUX-1-dev",
|
|
250
|
+
name: "black-forest-labs/FLUX-1-dev",
|
|
251
|
+
tags: ["image-gen"],
|
|
252
|
+
pricing: { per_image_unit: .025 },
|
|
253
|
+
defaultWidth: 1024,
|
|
254
|
+
defaultHeight: 1024,
|
|
255
|
+
defaultIterations: 28
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
id: "Qwen/Qwen-Image-Max",
|
|
259
|
+
name: "Qwen/Qwen-Image-Max",
|
|
260
|
+
tags: ["image-gen"],
|
|
261
|
+
pricing: { per_image_unit: .075 },
|
|
262
|
+
defaultWidth: 1024,
|
|
263
|
+
defaultHeight: 1024,
|
|
264
|
+
defaultIterations: 28
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
id: "stabilityai/sdxl-turbo",
|
|
268
|
+
name: "stabilityai/sdxl-turbo",
|
|
269
|
+
tags: ["image-gen"],
|
|
270
|
+
pricing: { per_image_unit: 2e-4 },
|
|
271
|
+
defaultWidth: 1024,
|
|
272
|
+
defaultHeight: 1024,
|
|
273
|
+
defaultIterations: 4
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
id: "hexgrad/Kokoro-82M",
|
|
277
|
+
name: "hexgrad/Kokoro-82M",
|
|
278
|
+
tags: ["tts"],
|
|
279
|
+
pricing: { input_characters: .65 }
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
id: "Qwen/Qwen3-TTS",
|
|
283
|
+
name: "Qwen/Qwen3-TTS",
|
|
284
|
+
tags: ["tts"],
|
|
285
|
+
pricing: { input_characters: .65 }
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
id: "ResembleAI/chatterbox-turbo",
|
|
289
|
+
name: "ResembleAI/chatterbox-turbo",
|
|
290
|
+
tags: ["tts"],
|
|
291
|
+
pricing: { input_characters: 1 }
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
id: "sesame/csm-1b",
|
|
295
|
+
name: "sesame/csm-1b",
|
|
296
|
+
tags: ["tts"],
|
|
297
|
+
pricing: { input_characters: 7 }
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
id: "openai/whisper-large-v3-turbo",
|
|
301
|
+
name: "openai/whisper-large-v3-turbo",
|
|
302
|
+
tags: ["stt"],
|
|
303
|
+
pricing: { input_seconds: 4e-5 }
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
id: "BAAI/bge-m3",
|
|
307
|
+
name: "BAAI/bge-m3",
|
|
308
|
+
tags: ["embed"],
|
|
309
|
+
pricing: { input_tokens: .01 },
|
|
310
|
+
maxTokens: 8192,
|
|
311
|
+
contextWindow: 8192
|
|
312
|
+
}
|
|
313
|
+
];
|
|
314
|
+
function manifestFallbackCatalog() {
|
|
315
|
+
const catalog = bucketBySurface([...(modelCatalog.providers.deepinfra.models ?? []).map(manifestChatEntryToSurfaceModel), ...STATIC_NON_CHAT_FALLBACK]);
|
|
316
|
+
catalog.live = false;
|
|
317
|
+
return catalog;
|
|
318
|
+
}
|
|
319
|
+
function getDeepInfraSurfaceFallbackCatalog() {
|
|
320
|
+
return manifestFallbackCatalog();
|
|
321
|
+
}
|
|
322
|
+
function buildDeepInfraModelDefinition(model) {
|
|
323
|
+
return {
|
|
324
|
+
...model,
|
|
325
|
+
compat: {
|
|
326
|
+
...model.compat,
|
|
327
|
+
supportsUsageInStreaming: model.compat?.supportsUsageInStreaming ?? true
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function chatSurfaceModelToModelDefinition(model) {
|
|
332
|
+
const input = model.tags.includes("vlm") ? ["text", "image"] : ["text"];
|
|
333
|
+
const reasoning = model.tags.includes("reasoning") || model.tags.includes("reasoning_effort");
|
|
334
|
+
return buildDeepInfraModelDefinition({
|
|
335
|
+
id: model.id,
|
|
336
|
+
name: model.name,
|
|
337
|
+
reasoning,
|
|
338
|
+
input,
|
|
339
|
+
contextWindow: model.contextWindow ?? DEEPINFRA_DEFAULT_CONTEXT_WINDOW,
|
|
340
|
+
maxTokens: model.maxTokens ?? DEEPINFRA_DEFAULT_MAX_TOKENS,
|
|
341
|
+
cost: {
|
|
342
|
+
input: model.pricing.input_tokens ?? 0,
|
|
343
|
+
output: model.pricing.output_tokens ?? 0,
|
|
344
|
+
cacheRead: model.pricing.cache_read_tokens ?? 0,
|
|
345
|
+
cacheWrite: 0
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
function hasDeepInfraApiKey(options) {
|
|
350
|
+
const fromEnv = (options?.env ?? process.env).DEEPINFRA_API_KEY;
|
|
351
|
+
if (typeof fromEnv === "string" && fromEnv.trim() !== "") return true;
|
|
352
|
+
const providers = options?.config?.models?.providers;
|
|
353
|
+
for (const [providerId, provider] of Object.entries(providers ?? {})) if (providerId.trim().toLowerCase() === "deepinfra" && hasConfiguredSecretInput(provider?.apiKey, options?.config?.secrets?.defaults)) return true;
|
|
354
|
+
return isProviderApiKeyConfigured({
|
|
355
|
+
provider: "deepinfra",
|
|
356
|
+
agentDir: options?.agentDir
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
async function discoverDeepInfraSurfaces(options) {
|
|
360
|
+
if (process.env.VITEST) return manifestFallbackCatalog();
|
|
361
|
+
const env = options?.env ?? process.env;
|
|
362
|
+
if (!(options?.hasApiKey ?? hasDeepInfraApiKey({
|
|
363
|
+
env,
|
|
364
|
+
agentDir: options?.agentDir
|
|
365
|
+
}))) return manifestFallbackCatalog();
|
|
366
|
+
try {
|
|
367
|
+
const data = await getCachedLiveProviderModelRows({
|
|
368
|
+
providerId: "deepinfra",
|
|
369
|
+
endpoint: DEEPINFRA_MODELS_URL,
|
|
370
|
+
timeoutMs: DISCOVERY_TIMEOUT_MS,
|
|
371
|
+
ttlMs: DISCOVERY_CACHE_TTL_MS,
|
|
372
|
+
buildRequestHeaders: () => ({ Accept: "application/json" }),
|
|
373
|
+
auditContext: "deepinfra-model-discovery",
|
|
374
|
+
shouldCacheRows: hasDeepInfraSurfaceModelRows
|
|
375
|
+
});
|
|
376
|
+
if (data.length === 0) {
|
|
377
|
+
log.warn("No models found from DeepInfra agent-projection endpoint, using static catalog");
|
|
378
|
+
return manifestFallbackCatalog();
|
|
379
|
+
}
|
|
380
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
381
|
+
const surfaceModels = [];
|
|
382
|
+
for (const entry of data) {
|
|
383
|
+
const model = entryToSurfaceModel(entry);
|
|
384
|
+
if (!model || seenIds.has(model.id)) continue;
|
|
385
|
+
seenIds.add(model.id);
|
|
386
|
+
surfaceModels.push(model);
|
|
387
|
+
}
|
|
388
|
+
if (surfaceModels.length === 0) return manifestFallbackCatalog();
|
|
389
|
+
return bucketBySurface(surfaceModels);
|
|
390
|
+
} catch (error) {
|
|
391
|
+
if (error instanceof LiveModelCatalogHttpError) {
|
|
392
|
+
log.warn(`Failed to discover models: HTTP ${error.status}, using static catalog`);
|
|
393
|
+
return manifestFallbackCatalog();
|
|
394
|
+
}
|
|
395
|
+
log.warn(`Discovery failed: ${String(error)}, using static catalog`);
|
|
396
|
+
return manifestFallbackCatalog();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
async function discoverDeepInfraModels(options) {
|
|
400
|
+
const catalog = await discoverDeepInfraSurfaces(options);
|
|
401
|
+
const chatModels = catalog.chat.length > 0 ? catalog.chat : [...catalog.chat, ...catalog.vlm];
|
|
402
|
+
if (chatModels.length === 0) return DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition);
|
|
403
|
+
const liveModels = chatModels.map(chatSurfaceModelToModelDefinition);
|
|
404
|
+
const seen = new Set(liveModels.map((model) => model.id));
|
|
405
|
+
const manifestModels = DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition).filter((model) => {
|
|
406
|
+
if (seen.has(model.id)) return false;
|
|
407
|
+
seen.add(model.id);
|
|
408
|
+
return true;
|
|
409
|
+
});
|
|
410
|
+
return [...liveModels, ...manifestModels];
|
|
411
|
+
}
|
|
412
|
+
//#endregion
|
|
413
|
+
export { DEEPINFRA_MODEL_CATALOG as a, discoverDeepInfraSurfaces as c, resetDeepInfraModelCacheForTest as d, DEEPINFRA_MODELS_URL as i, getDeepInfraSurfaceFallbackCatalog as l, DEEPINFRA_DEFAULT_MODEL_ID as n, buildDeepInfraModelDefinition as o, DEEPINFRA_DEFAULT_MODEL_REF as r, discoverDeepInfraModels as s, DEEPINFRA_BASE_URL as t, hasDeepInfraApiKey as u };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DEEPINFRA_MODEL_CATALOG, c as discoverDeepInfraSurfaces, d as resetDeepInfraModelCacheForTest, i as DEEPINFRA_MODELS_URL, l as getDeepInfraSurfaceFallbackCatalog, n as DEEPINFRA_DEFAULT_MODEL_ID, o as buildDeepInfraModelDefinition, r as DEEPINFRA_DEFAULT_MODEL_REF, s as discoverDeepInfraModels, t as DEEPINFRA_BASE_URL, u as hasDeepInfraApiKey } from "./provider-models-BLNlFB8o.js";
|
|
2
|
+
export { DEEPINFRA_BASE_URL, DEEPINFRA_DEFAULT_MODEL_ID, DEEPINFRA_DEFAULT_MODEL_REF, DEEPINFRA_MODELS_URL, DEEPINFRA_MODEL_CATALOG, buildDeepInfraModelDefinition, discoverDeepInfraModels, discoverDeepInfraSurfaces, getDeepInfraSurfaceFallbackCatalog, hasDeepInfraApiKey, resetDeepInfraModelCacheForTest };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region extensions/deepinfra/provider-policy-api.ts
|
|
2
|
+
/**
|
|
3
|
+
* Passthrough normalization for DeepInfra provider config.
|
|
4
|
+
*
|
|
5
|
+
* DeepInfra's OpenAI-compatible base URL is `https://api.deepinfra.com/v1/openai`
|
|
6
|
+
* with the `/v1` segment mid-path, not at the end. The generic
|
|
7
|
+
* openai-completions config normalizer strips a trailing `/v1` and re-appends
|
|
8
|
+
* one, which is idempotent for providers like OpenRouter (`.../api/v1`) but
|
|
9
|
+
* doubles to `.../v1/openai/v1` here and breaks inference (404).
|
|
10
|
+
*
|
|
11
|
+
* Shipping this bundled policy surface short-circuits the fallback normalizer
|
|
12
|
+
* chain (see `src/plugins/provider-runtime.ts:normalizeProviderConfigWithPlugin`)
|
|
13
|
+
* and preserves the DeepInfra-declared baseUrl as-is.
|
|
14
|
+
*/
|
|
15
|
+
function normalizeConfig(params) {
|
|
16
|
+
return params.providerConfig;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { normalizeConfig };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { t as DEEPINFRA_BASE_URL } from "./provider-models-BLNlFB8o.js";
|
|
2
|
+
import { DEEPINFRA_TTS_FALLBACK_MODELS, DEFAULT_DEEPINFRA_TTS_VOICE, normalizeDeepInfraModelRef } from "./media-models.js";
|
|
3
|
+
import { asObject, createOpenAiCompatibleSpeechProvider } from "openclaw/plugin-sdk/speech";
|
|
4
|
+
//#region extensions/deepinfra/speech-provider.ts
|
|
5
|
+
const DEEPINFRA_TTS_RESPONSE_FORMATS = [
|
|
6
|
+
"mp3",
|
|
7
|
+
"opus",
|
|
8
|
+
"flac",
|
|
9
|
+
"wav",
|
|
10
|
+
"pcm"
|
|
11
|
+
];
|
|
12
|
+
function buildDeepInfraSpeechProvider(options) {
|
|
13
|
+
const ids = options?.ttsModels && options.ttsModels.length > 0 ? options.ttsModels.map((model) => model.id) : [...DEEPINFRA_TTS_FALLBACK_MODELS];
|
|
14
|
+
const defaultModel = ids[0] ?? DEEPINFRA_TTS_FALLBACK_MODELS[0];
|
|
15
|
+
return createOpenAiCompatibleSpeechProvider({
|
|
16
|
+
id: "deepinfra",
|
|
17
|
+
label: "DeepInfra",
|
|
18
|
+
autoSelectOrder: 45,
|
|
19
|
+
models: ids,
|
|
20
|
+
voices: [DEFAULT_DEEPINFRA_TTS_VOICE],
|
|
21
|
+
defaultModel,
|
|
22
|
+
defaultVoice: DEFAULT_DEEPINFRA_TTS_VOICE,
|
|
23
|
+
defaultBaseUrl: DEEPINFRA_BASE_URL,
|
|
24
|
+
envKey: "DEEPINFRA_API_KEY",
|
|
25
|
+
responseFormats: DEEPINFRA_TTS_RESPONSE_FORMATS,
|
|
26
|
+
defaultResponseFormat: "mp3",
|
|
27
|
+
voiceCompatibleResponseFormats: ["mp3", "opus"],
|
|
28
|
+
baseUrlPolicy: { kind: "trim-trailing-slash" },
|
|
29
|
+
normalizeModel: normalizeDeepInfraModelRef,
|
|
30
|
+
apiErrorLabel: "DeepInfra TTS API error",
|
|
31
|
+
missingApiKeyError: "DeepInfra API key missing",
|
|
32
|
+
readExtraConfig: (raw) => ({ extraBody: asObject(raw?.extraBody) }),
|
|
33
|
+
extraJsonBodyFields: [{
|
|
34
|
+
configKey: "extraBody",
|
|
35
|
+
requestKey: "extra_body"
|
|
36
|
+
}]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { buildDeepInfraSpeechProvider };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { c as discoverDeepInfraSurfaces } from "./provider-models-BLNlFB8o.js";
|
|
2
|
+
import { DEEPINFRA_VIDEO_ASPECT_RATIOS, DEEPINFRA_VIDEO_DURATIONS } from "./media-models.js";
|
|
3
|
+
//#region extensions/deepinfra/surface-model-catalogs.ts
|
|
4
|
+
const PROVIDER_ID = "deepinfra";
|
|
5
|
+
function surfaceModelToImageGenEntry(model) {
|
|
6
|
+
return {
|
|
7
|
+
kind: "image_generation",
|
|
8
|
+
provider: PROVIDER_ID,
|
|
9
|
+
model: model.id,
|
|
10
|
+
source: "live",
|
|
11
|
+
...model.name ? { label: model.name } : {}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function surfaceModelToVideoGenEntry(model) {
|
|
15
|
+
return {
|
|
16
|
+
kind: "video_generation",
|
|
17
|
+
provider: PROVIDER_ID,
|
|
18
|
+
model: model.id,
|
|
19
|
+
source: "live",
|
|
20
|
+
...model.name ? { label: model.name } : {},
|
|
21
|
+
capabilities: buildDeepInfraVideoModelCapabilities()
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function buildDeepInfraVideoModelCapabilities() {
|
|
25
|
+
return {
|
|
26
|
+
providerOptions: {
|
|
27
|
+
seed: "number",
|
|
28
|
+
negative_prompt: "string",
|
|
29
|
+
negativePrompt: "string",
|
|
30
|
+
style: "string",
|
|
31
|
+
guidance_scale: "number",
|
|
32
|
+
guidanceScale: "number"
|
|
33
|
+
},
|
|
34
|
+
generate: {
|
|
35
|
+
maxVideos: 1,
|
|
36
|
+
maxDurationSeconds: 8,
|
|
37
|
+
supportedDurationSeconds: [...DEEPINFRA_VIDEO_DURATIONS],
|
|
38
|
+
supportsAspectRatio: true,
|
|
39
|
+
aspectRatios: [...DEEPINFRA_VIDEO_ASPECT_RATIOS]
|
|
40
|
+
},
|
|
41
|
+
imageToVideo: { enabled: false },
|
|
42
|
+
videoToVideo: { enabled: false }
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async function listDeepInfraImageGenCatalog(ctx) {
|
|
46
|
+
const { discoveryApiKey } = ctx.resolveProviderApiKey(PROVIDER_ID);
|
|
47
|
+
if (!discoveryApiKey) return null;
|
|
48
|
+
const catalog = await discoverDeepInfraSurfaces({
|
|
49
|
+
hasApiKey: true,
|
|
50
|
+
env: ctx.env
|
|
51
|
+
});
|
|
52
|
+
if (!catalog.live || catalog.imageGen.length === 0) return null;
|
|
53
|
+
return catalog.imageGen.map(surfaceModelToImageGenEntry);
|
|
54
|
+
}
|
|
55
|
+
async function listDeepInfraVideoGenCatalog(ctx) {
|
|
56
|
+
const { discoveryApiKey } = ctx.resolveProviderApiKey(PROVIDER_ID);
|
|
57
|
+
if (!discoveryApiKey) return null;
|
|
58
|
+
const catalog = await discoverDeepInfraSurfaces({
|
|
59
|
+
hasApiKey: true,
|
|
60
|
+
env: ctx.env
|
|
61
|
+
});
|
|
62
|
+
if (!catalog.live || catalog.videoGen.length === 0) return null;
|
|
63
|
+
return catalog.videoGen.map(surfaceModelToVideoGenEntry);
|
|
64
|
+
}
|
|
65
|
+
async function resolveDeepInfraVideoModelCapabilities(ctx) {
|
|
66
|
+
const rawId = typeof ctx.model === "string" ? ctx.model : "";
|
|
67
|
+
const normalized = rawId.startsWith(`${PROVIDER_ID}/`) ? rawId.slice(10) : rawId;
|
|
68
|
+
const catalog = await discoverDeepInfraSurfaces({ env: process.env });
|
|
69
|
+
return catalog.videoGen.find((m) => m.id === normalized) ?? catalog.videoGen.find((m) => m.id === rawId) ? buildDeepInfraVideoModelCapabilities() : void 0;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { listDeepInfraImageGenCatalog, listDeepInfraVideoGenCatalog, resolveDeepInfraVideoModelCapabilities };
|