@openclaw/deepinfra-provider 2026.7.2-beta.2 → 2026.7.2-beta.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 +1 -1
- package/dist/doctor-contract-api.js +84 -0
- package/dist/embedding-provider.js +1 -1
- package/dist/image-generation-provider.js +1 -1
- package/dist/index.js +1 -1
- package/dist/media-models.js +2 -4
- package/dist/media-understanding-provider.js +1 -1
- package/dist/onboard.js +1 -1
- package/dist/openclaw.plugin-C1yZ4_ko.js +132 -0
- package/dist/provider-catalog.js +1 -1
- package/dist/provider-models.js +286 -1
- package/dist/speech-provider.js +1 -1
- package/dist/surface-model-catalogs.js +2 -4
- package/dist/video-generation-provider.js +66 -50
- package/npm-shrinkwrap.json +2 -2
- package/openclaw.plugin.json +0 -3
- package/package.json +4 -4
- package/dist/provider-models-CXaqRQOl.js +0 -409
package/dist/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEEPINFRA_DEFAULT_MODEL_REF } from "./provider-models.js";
|
|
2
2
|
import { buildDeepInfraImageGenerationProvider } from "./image-generation-provider.js";
|
|
3
3
|
import { deepinfraMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
|
4
4
|
import { deepinfraMemoryEmbeddingProviderAdapter } from "./memory-embedding-adapter.js";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { t as modelCatalog } from "./openclaw.plugin-C1yZ4_ko.js";
|
|
2
|
+
import { asObjectRecord } from "openclaw/plugin-sdk/runtime-doctor";
|
|
3
|
+
//#region extensions/deepinfra/doctor-contract-api.ts
|
|
4
|
+
const PROVIDER_PATH = "models.providers.deepinfra";
|
|
5
|
+
const NATIVE_INFERENCE_PATH = "/v1/inference";
|
|
6
|
+
const OPENAI_COMPAT_PATH = "/v1/openai";
|
|
7
|
+
const CANONICAL_BASE_URL = modelCatalog.providers.deepinfra.baseUrl;
|
|
8
|
+
const FIX_HINT = `Run "openclaw doctor --fix" (api.deepinfra.com endpoints migrate automatically; custom hosts must set ${PROVIDER_PATH}.baseUrl to an OpenAI-compatible videos endpoint manually).`;
|
|
9
|
+
const legacyConfigRules = [{
|
|
10
|
+
path: [
|
|
11
|
+
"models",
|
|
12
|
+
"providers",
|
|
13
|
+
"deepinfra",
|
|
14
|
+
"nativeBaseUrl"
|
|
15
|
+
],
|
|
16
|
+
message: `${PROVIDER_PATH}.nativeBaseUrl is legacy; video generation uses the OpenAI-compatible ${PROVIDER_PATH}.baseUrl. ${FIX_HINT}`
|
|
17
|
+
}, {
|
|
18
|
+
path: [
|
|
19
|
+
"models",
|
|
20
|
+
"providers",
|
|
21
|
+
"deepinfra",
|
|
22
|
+
"baseUrl"
|
|
23
|
+
],
|
|
24
|
+
message: `${PROVIDER_PATH}.baseUrl targets the retired native ${NATIVE_INFERENCE_PATH} surface; use an ${OPENAI_COMPAT_PATH} base. ${FIX_HINT}`,
|
|
25
|
+
match: (value) => typeof value === "string" && value.includes(NATIVE_INFERENCE_PATH)
|
|
26
|
+
}];
|
|
27
|
+
function isDeepInfraApiHost(value) {
|
|
28
|
+
try {
|
|
29
|
+
return new URL(value).host === "api.deepinfra.com";
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function normalizeBaseUrlValue(value) {
|
|
35
|
+
if (typeof value !== "string") return;
|
|
36
|
+
const trimmed = value.trim().replace(/\/+$/u, "");
|
|
37
|
+
return trimmed ? trimmed : void 0;
|
|
38
|
+
}
|
|
39
|
+
function normalizeCompatibilityConfig({ cfg }) {
|
|
40
|
+
const models = asObjectRecord(cfg.models);
|
|
41
|
+
const providers = asObjectRecord(models?.providers);
|
|
42
|
+
const provider = asObjectRecord(providers?.deepinfra);
|
|
43
|
+
if (!provider) return {
|
|
44
|
+
config: cfg,
|
|
45
|
+
changes: []
|
|
46
|
+
};
|
|
47
|
+
const changes = [];
|
|
48
|
+
const next = { ...provider };
|
|
49
|
+
if (Object.hasOwn(next, "nativeBaseUrl")) {
|
|
50
|
+
const legacyNative = normalizeBaseUrlValue(next.nativeBaseUrl);
|
|
51
|
+
delete next.nativeBaseUrl;
|
|
52
|
+
if (normalizeBaseUrlValue(next.baseUrl)) changes.push(`${PROVIDER_PATH}.nativeBaseUrl: removed (baseUrl is already configured)`);
|
|
53
|
+
else if (legacyNative && !isDeepInfraApiHost(legacyNative)) {
|
|
54
|
+
next.baseUrl = CANONICAL_BASE_URL;
|
|
55
|
+
changes.push(`${PROVIDER_PATH}.nativeBaseUrl: removed retired custom native endpoint; using ${CANONICAL_BASE_URL} - set ${PROVIDER_PATH}.baseUrl manually if your host serves an OpenAI-compatible videos API`);
|
|
56
|
+
} else {
|
|
57
|
+
next.baseUrl = legacyNative?.includes(NATIVE_INFERENCE_PATH) ? legacyNative.replace(NATIVE_INFERENCE_PATH, OPENAI_COMPAT_PATH) : CANONICAL_BASE_URL;
|
|
58
|
+
changes.push(`${PROVIDER_PATH}.nativeBaseUrl -> ${PROVIDER_PATH}.baseUrl (OpenAI-compatible ${OPENAI_COMPAT_PATH} endpoint)`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (typeof next.baseUrl === "string" && next.baseUrl.includes(NATIVE_INFERENCE_PATH) && isDeepInfraApiHost(next.baseUrl)) {
|
|
62
|
+
next.baseUrl = next.baseUrl.replace(NATIVE_INFERENCE_PATH, OPENAI_COMPAT_PATH);
|
|
63
|
+
changes.push(`${PROVIDER_PATH}.baseUrl: ${NATIVE_INFERENCE_PATH} -> ${OPENAI_COMPAT_PATH}`);
|
|
64
|
+
}
|
|
65
|
+
if (changes.length === 0) return {
|
|
66
|
+
config: cfg,
|
|
67
|
+
changes: []
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
config: {
|
|
71
|
+
...cfg,
|
|
72
|
+
models: {
|
|
73
|
+
...models,
|
|
74
|
+
providers: {
|
|
75
|
+
...providers,
|
|
76
|
+
deepinfra: next
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
changes
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { legacyConfigRules, normalizeCompatibilityConfig };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEEPINFRA_BASE_URL } from "./provider-models.js";
|
|
2
2
|
import { DEEPINFRA_EMBED_FALLBACK_MODELS, normalizeDeepInfraModelRef } from "./media-models.js";
|
|
3
3
|
import { createRemoteEmbeddingProvider, resolveRemoteEmbeddingClient } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
4
4
|
//#region extensions/deepinfra/embedding-provider.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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 { createOpenAiCompatibleImageGenerationProvider, imageSourceUploadFileName } from "openclaw/plugin-sdk/image-generation";
|
|
4
4
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDeepInfraAnthropicCacheWrapper } from "./cache-wrapper.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DEEPINFRA_DEFAULT_MODEL_REF, discoverDeepInfraModels, getDeepInfraSurfaceFallbackCatalog, hasDeepInfraApiKey } from "./provider-models.js";
|
|
3
3
|
import { buildDeepInfraImageGenerationProvider } from "./image-generation-provider.js";
|
|
4
4
|
import { buildDeepInfraMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
|
5
5
|
import { buildDeepInfraMemoryEmbeddingAdapter } from "./memory-embedding-adapter.js";
|
package/dist/media-models.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEEPINFRA_BASE_URL } from "./provider-models.js";
|
|
2
2
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
//#region extensions/deepinfra/media-models.ts
|
|
4
|
-
const DEEPINFRA_NATIVE_BASE_URL = "https://api.deepinfra.com/v1/inference";
|
|
5
4
|
const DEFAULT_DEEPINFRA_IMAGE_SIZE = "1024x1024";
|
|
6
5
|
const DEFAULT_DEEPINFRA_TTS_VOICE = "af_bella";
|
|
7
6
|
const DEEPINFRA_VIDEO_ASPECT_RATIOS = [
|
|
@@ -14,7 +13,6 @@ const DEEPINFRA_VIDEO_ASPECT_RATIOS = [
|
|
|
14
13
|
const DEEPINFRA_VIDEO_DURATIONS = [5, 8];
|
|
15
14
|
const DEEPINFRA_IMAGE_FALLBACK_MODELS = [
|
|
16
15
|
"black-forest-labs/FLUX-1-schnell",
|
|
17
|
-
"run-diffusion/Juggernaut-Lightning-Flux",
|
|
18
16
|
"black-forest-labs/FLUX-1-dev",
|
|
19
17
|
"Qwen/Qwen-Image-Max",
|
|
20
18
|
"stabilityai/sdxl-turbo"
|
|
@@ -42,4 +40,4 @@ function normalizeDeepInfraBaseUrl(value, fallback = DEEPINFRA_BASE_URL) {
|
|
|
42
40
|
return (normalizeOptionalString(value) ?? fallback).replace(/\/+$/u, "");
|
|
43
41
|
}
|
|
44
42
|
//#endregion
|
|
45
|
-
export { DEEPINFRA_BASE_URL, DEEPINFRA_EMBED_FALLBACK_MODELS, DEEPINFRA_IMAGE_FALLBACK_MODELS,
|
|
43
|
+
export { DEEPINFRA_BASE_URL, DEEPINFRA_EMBED_FALLBACK_MODELS, DEEPINFRA_IMAGE_FALLBACK_MODELS, DEEPINFRA_STT_FALLBACK_MODELS, DEEPINFRA_TTS_FALLBACK_MODELS, DEEPINFRA_VIDEO_ASPECT_RATIOS, DEEPINFRA_VIDEO_DURATIONS, DEEPINFRA_VIDEO_FALLBACK_MODELS, DEEPINFRA_VLM_FALLBACK_MODELS, DEFAULT_DEEPINFRA_IMAGE_SIZE, DEFAULT_DEEPINFRA_TTS_VOICE, normalizeDeepInfraBaseUrl, normalizeDeepInfraModelRef };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEEPINFRA_BASE_URL } from "./provider-models.js";
|
|
2
2
|
import { DEEPINFRA_STT_FALLBACK_MODELS, DEEPINFRA_VLM_FALLBACK_MODELS } from "./media-models.js";
|
|
3
3
|
import { describeImageWithModel, describeImagesWithModel, transcribeOpenAiCompatibleAudio } from "openclaw/plugin-sdk/media-understanding";
|
|
4
4
|
//#region extensions/deepinfra/media-understanding-provider.ts
|
package/dist/onboard.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEEPINFRA_DEFAULT_MODEL_REF } from "./provider-models.js";
|
|
2
2
|
import { applyAgentDefaultModelPrimary } from "openclaw/plugin-sdk/provider-onboard";
|
|
3
3
|
//#region extensions/deepinfra/onboard.ts
|
|
4
4
|
function applyDeepInfraConfig(cfg, modelRef = DEEPINFRA_DEFAULT_MODEL_REF) {
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
//#region extensions/deepinfra/openclaw.plugin.json
|
|
2
|
+
var modelCatalog = {
|
|
3
|
+
"providers": { "deepinfra": {
|
|
4
|
+
"baseUrl": "https://api.deepinfra.com/v1/openai",
|
|
5
|
+
"api": "openai-completions",
|
|
6
|
+
"models": [
|
|
7
|
+
{
|
|
8
|
+
"id": "deepseek-ai/DeepSeek-V4-Flash",
|
|
9
|
+
"name": "DeepSeek V4 Flash",
|
|
10
|
+
"reasoning": true,
|
|
11
|
+
"input": ["text"],
|
|
12
|
+
"contextWindow": 1048576,
|
|
13
|
+
"maxTokens": 1048576,
|
|
14
|
+
"cost": {
|
|
15
|
+
"input": .1,
|
|
16
|
+
"output": .2,
|
|
17
|
+
"cacheRead": .02,
|
|
18
|
+
"cacheWrite": 0
|
|
19
|
+
},
|
|
20
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "deepseek-ai/DeepSeek-V3.2",
|
|
24
|
+
"name": "DeepSeek V3.2",
|
|
25
|
+
"reasoning": false,
|
|
26
|
+
"input": ["text"],
|
|
27
|
+
"contextWindow": 163840,
|
|
28
|
+
"maxTokens": 163840,
|
|
29
|
+
"cost": {
|
|
30
|
+
"input": .26,
|
|
31
|
+
"output": .38,
|
|
32
|
+
"cacheRead": .13,
|
|
33
|
+
"cacheWrite": 0
|
|
34
|
+
},
|
|
35
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "zai-org/GLM-5.1",
|
|
39
|
+
"name": "GLM-5.1",
|
|
40
|
+
"reasoning": true,
|
|
41
|
+
"input": ["text"],
|
|
42
|
+
"contextWindow": 202752,
|
|
43
|
+
"maxTokens": 202752,
|
|
44
|
+
"cost": {
|
|
45
|
+
"input": 1.05,
|
|
46
|
+
"output": 3.5,
|
|
47
|
+
"cacheRead": .205000005,
|
|
48
|
+
"cacheWrite": 0
|
|
49
|
+
},
|
|
50
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"id": "stepfun-ai/Step-3.5-Flash",
|
|
54
|
+
"name": "Step 3.5 Flash",
|
|
55
|
+
"reasoning": false,
|
|
56
|
+
"input": ["text"],
|
|
57
|
+
"contextWindow": 262144,
|
|
58
|
+
"maxTokens": 262144,
|
|
59
|
+
"cost": {
|
|
60
|
+
"input": .1,
|
|
61
|
+
"output": .3,
|
|
62
|
+
"cacheRead": .02,
|
|
63
|
+
"cacheWrite": 0
|
|
64
|
+
},
|
|
65
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "MiniMaxAI/MiniMax-M2.5",
|
|
69
|
+
"name": "MiniMax M2.5",
|
|
70
|
+
"reasoning": true,
|
|
71
|
+
"input": ["text"],
|
|
72
|
+
"contextWindow": 196608,
|
|
73
|
+
"maxTokens": 196608,
|
|
74
|
+
"cost": {
|
|
75
|
+
"input": .15,
|
|
76
|
+
"output": 1.15,
|
|
77
|
+
"cacheRead": .03,
|
|
78
|
+
"cacheWrite": 0
|
|
79
|
+
},
|
|
80
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "moonshotai/Kimi-K2.5",
|
|
84
|
+
"name": "Kimi K2.5",
|
|
85
|
+
"reasoning": true,
|
|
86
|
+
"input": ["text", "image"],
|
|
87
|
+
"contextWindow": 262144,
|
|
88
|
+
"maxTokens": 262144,
|
|
89
|
+
"cost": {
|
|
90
|
+
"input": .45,
|
|
91
|
+
"output": 2.25,
|
|
92
|
+
"cacheRead": .070000002,
|
|
93
|
+
"cacheWrite": 0
|
|
94
|
+
},
|
|
95
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"id": "nvidia/NVIDIA-Nemotron-3-Super-120B-A12B",
|
|
99
|
+
"name": "NVIDIA Nemotron 3 Super 120B A12B",
|
|
100
|
+
"reasoning": true,
|
|
101
|
+
"input": ["text"],
|
|
102
|
+
"contextWindow": 262144,
|
|
103
|
+
"maxTokens": 262144,
|
|
104
|
+
"cost": {
|
|
105
|
+
"input": .1,
|
|
106
|
+
"output": .5,
|
|
107
|
+
"cacheRead": 0,
|
|
108
|
+
"cacheWrite": 0
|
|
109
|
+
},
|
|
110
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"id": "meta-llama/Llama-3.3-70B-Instruct-Turbo",
|
|
114
|
+
"name": "Llama 3.3 70B Instruct Turbo",
|
|
115
|
+
"reasoning": false,
|
|
116
|
+
"input": ["text"],
|
|
117
|
+
"contextWindow": 131072,
|
|
118
|
+
"maxTokens": 131072,
|
|
119
|
+
"cost": {
|
|
120
|
+
"input": .1,
|
|
121
|
+
"output": .32,
|
|
122
|
+
"cacheRead": 0,
|
|
123
|
+
"cacheWrite": 0
|
|
124
|
+
},
|
|
125
|
+
"compat": { "supportsUsageInStreaming": true }
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
} },
|
|
129
|
+
"discovery": { "deepinfra": "refreshable" }
|
|
130
|
+
};
|
|
131
|
+
//#endregion
|
|
132
|
+
export { modelCatalog as t };
|
package/dist/provider-catalog.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEEPINFRA_BASE_URL, DEEPINFRA_MODEL_CATALOG, buildDeepInfraModelDefinition, discoverDeepInfraModels } from "./provider-models.js";
|
|
2
2
|
import { buildSingleProviderApiKeyCatalog } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
3
3
|
//#region extensions/deepinfra/provider-catalog.ts
|
|
4
4
|
function buildStaticDeepInfraProvider() {
|
package/dist/provider-models.js
CHANGED
|
@@ -1,2 +1,287 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as modelCatalog } from "./openclaw.plugin-C1yZ4_ko.js";
|
|
2
|
+
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
3
|
+
import { asPositiveSafeInteger } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
+
import { withTrustedEnvProxyGuardedFetchMode } from "openclaw/plugin-sdk/fetch-runtime";
|
|
5
|
+
import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
|
|
6
|
+
import { LiveModelCatalogHttpError, getCachedLiveProviderModelRows } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
|
|
7
|
+
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
8
|
+
import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/secret-input";
|
|
9
|
+
import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
10
|
+
//#region extensions/deepinfra/provider-models.ts
|
|
11
|
+
const log = createSubsystemLogger("deepinfra-models");
|
|
12
|
+
const DEEPINFRA_MANIFEST_PROVIDER = buildManifestModelProviderConfig({
|
|
13
|
+
providerId: "deepinfra",
|
|
14
|
+
catalog: modelCatalog.providers.deepinfra
|
|
15
|
+
});
|
|
16
|
+
const DEEPINFRA_BASE_URL = DEEPINFRA_MANIFEST_PROVIDER.baseUrl;
|
|
17
|
+
const DEEPINFRA_MODELS_URL = `${DEEPINFRA_BASE_URL}/models?sort_by=openclaw&filter=with_meta`;
|
|
18
|
+
const DEEPINFRA_DEFAULT_MODEL_REF = `deepinfra/deepseek-ai/DeepSeek-V4-Flash`;
|
|
19
|
+
const DEEPINFRA_DEFAULT_CONTEXT_WINDOW = 128e3;
|
|
20
|
+
const DEEPINFRA_DEFAULT_MAX_TOKENS = 8192;
|
|
21
|
+
const DEEPINFRA_MODEL_CATALOG = DEEPINFRA_MANIFEST_PROVIDER.models;
|
|
22
|
+
const DISCOVERY_TIMEOUT_MS = 5e3;
|
|
23
|
+
const DISCOVERY_CACHE_TTL_MS = 300 * 1e3;
|
|
24
|
+
const SURFACE_FOR_TAG = {
|
|
25
|
+
chat: "chat",
|
|
26
|
+
vlm: "vlm",
|
|
27
|
+
embed: "embed",
|
|
28
|
+
"image-gen": "image-gen",
|
|
29
|
+
"video-gen": "video-gen",
|
|
30
|
+
tts: "tts",
|
|
31
|
+
stt: "stt"
|
|
32
|
+
};
|
|
33
|
+
function entryToSurfaceModel(entry) {
|
|
34
|
+
const id = typeof entry?.id === "string" ? entry.id.trim() : "";
|
|
35
|
+
if (!id) return null;
|
|
36
|
+
const metadata = entry.metadata;
|
|
37
|
+
if (!metadata) return null;
|
|
38
|
+
const tags = Array.isArray(metadata.tags) ? metadata.tags.filter((t) => typeof t === "string") : [];
|
|
39
|
+
const pricing = metadata.pricing ?? {};
|
|
40
|
+
return {
|
|
41
|
+
id,
|
|
42
|
+
name: id,
|
|
43
|
+
description: metadata.description ?? void 0,
|
|
44
|
+
tags,
|
|
45
|
+
contextWindow: asPositiveSafeInteger(metadata.context_length),
|
|
46
|
+
maxTokens: asPositiveSafeInteger(metadata.max_tokens),
|
|
47
|
+
pricing,
|
|
48
|
+
defaultWidth: asPositiveSafeInteger(metadata.default_width),
|
|
49
|
+
defaultHeight: asPositiveSafeInteger(metadata.default_height),
|
|
50
|
+
defaultIterations: asPositiveSafeInteger(metadata.default_iterations)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function bucketBySurface(models) {
|
|
54
|
+
const catalog = {
|
|
55
|
+
chat: [],
|
|
56
|
+
vlm: [],
|
|
57
|
+
embed: [],
|
|
58
|
+
imageGen: [],
|
|
59
|
+
videoGen: [],
|
|
60
|
+
tts: [],
|
|
61
|
+
stt: [],
|
|
62
|
+
live: true
|
|
63
|
+
};
|
|
64
|
+
const buckets = {
|
|
65
|
+
chat: catalog.chat,
|
|
66
|
+
vlm: catalog.vlm,
|
|
67
|
+
embed: catalog.embed,
|
|
68
|
+
"image-gen": catalog.imageGen,
|
|
69
|
+
"video-gen": catalog.videoGen,
|
|
70
|
+
tts: catalog.tts,
|
|
71
|
+
stt: catalog.stt
|
|
72
|
+
};
|
|
73
|
+
for (const model of models) {
|
|
74
|
+
const seen = /* @__PURE__ */ new Set();
|
|
75
|
+
for (const tag of model.tags) {
|
|
76
|
+
const surface = SURFACE_FOR_TAG[tag];
|
|
77
|
+
if (surface && !seen.has(surface)) {
|
|
78
|
+
seen.add(surface);
|
|
79
|
+
buckets[surface].push(model);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return catalog;
|
|
84
|
+
}
|
|
85
|
+
function hasDeepInfraSurfaceModelRows(rows) {
|
|
86
|
+
return rows.some((entry) => entryToSurfaceModel(entry) !== null);
|
|
87
|
+
}
|
|
88
|
+
function manifestChatEntryToSurfaceModel(entry) {
|
|
89
|
+
const cost = entry.cost ?? {};
|
|
90
|
+
const pricing = {};
|
|
91
|
+
if (typeof cost.input === "number") pricing.input_tokens = cost.input;
|
|
92
|
+
if (typeof cost.output === "number") pricing.output_tokens = cost.output;
|
|
93
|
+
if (typeof cost.cacheRead === "number" && cost.cacheRead > 0) pricing.cache_read_tokens = cost.cacheRead;
|
|
94
|
+
const tags = ["chat"];
|
|
95
|
+
if (entry.input?.includes("image")) tags.push("vlm");
|
|
96
|
+
if (entry.reasoning) tags.push("reasoning");
|
|
97
|
+
return {
|
|
98
|
+
id: entry.id,
|
|
99
|
+
name: entry.name ?? entry.id,
|
|
100
|
+
tags,
|
|
101
|
+
contextWindow: entry.contextWindow,
|
|
102
|
+
maxTokens: entry.maxTokens,
|
|
103
|
+
pricing
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const STATIC_NON_CHAT_FALLBACK = [
|
|
107
|
+
{
|
|
108
|
+
id: "black-forest-labs/FLUX-1-schnell",
|
|
109
|
+
name: "black-forest-labs/FLUX-1-schnell",
|
|
110
|
+
tags: ["image-gen"],
|
|
111
|
+
pricing: { per_image_unit: .003 },
|
|
112
|
+
defaultWidth: 1024,
|
|
113
|
+
defaultHeight: 1024,
|
|
114
|
+
defaultIterations: 4
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: "black-forest-labs/FLUX-1-dev",
|
|
118
|
+
name: "black-forest-labs/FLUX-1-dev",
|
|
119
|
+
tags: ["image-gen"],
|
|
120
|
+
pricing: { per_image_unit: .025 },
|
|
121
|
+
defaultWidth: 1024,
|
|
122
|
+
defaultHeight: 1024,
|
|
123
|
+
defaultIterations: 28
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "Qwen/Qwen-Image-Max",
|
|
127
|
+
name: "Qwen/Qwen-Image-Max",
|
|
128
|
+
tags: ["image-gen"],
|
|
129
|
+
pricing: { per_image_unit: .075 },
|
|
130
|
+
defaultWidth: 1024,
|
|
131
|
+
defaultHeight: 1024,
|
|
132
|
+
defaultIterations: 28
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: "stabilityai/sdxl-turbo",
|
|
136
|
+
name: "stabilityai/sdxl-turbo",
|
|
137
|
+
tags: ["image-gen"],
|
|
138
|
+
pricing: { per_image_unit: 2e-4 },
|
|
139
|
+
defaultWidth: 1024,
|
|
140
|
+
defaultHeight: 1024,
|
|
141
|
+
defaultIterations: 4
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "hexgrad/Kokoro-82M",
|
|
145
|
+
name: "hexgrad/Kokoro-82M",
|
|
146
|
+
tags: ["tts"],
|
|
147
|
+
pricing: { input_characters: .65 }
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: "Qwen/Qwen3-TTS",
|
|
151
|
+
name: "Qwen/Qwen3-TTS",
|
|
152
|
+
tags: ["tts"],
|
|
153
|
+
pricing: { input_characters: .65 }
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: "ResembleAI/chatterbox-turbo",
|
|
157
|
+
name: "ResembleAI/chatterbox-turbo",
|
|
158
|
+
tags: ["tts"],
|
|
159
|
+
pricing: { input_characters: 1 }
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: "sesame/csm-1b",
|
|
163
|
+
name: "sesame/csm-1b",
|
|
164
|
+
tags: ["tts"],
|
|
165
|
+
pricing: { input_characters: 7 }
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: "openai/whisper-large-v3-turbo",
|
|
169
|
+
name: "openai/whisper-large-v3-turbo",
|
|
170
|
+
tags: ["stt"],
|
|
171
|
+
pricing: { input_seconds: 4e-5 }
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
id: "BAAI/bge-m3",
|
|
175
|
+
name: "BAAI/bge-m3",
|
|
176
|
+
tags: ["embed"],
|
|
177
|
+
pricing: { input_tokens: .01 },
|
|
178
|
+
maxTokens: 8192,
|
|
179
|
+
contextWindow: 8192
|
|
180
|
+
}
|
|
181
|
+
];
|
|
182
|
+
function manifestFallbackCatalog() {
|
|
183
|
+
const catalog = bucketBySurface([...(modelCatalog.providers.deepinfra.models ?? []).map(manifestChatEntryToSurfaceModel), ...STATIC_NON_CHAT_FALLBACK]);
|
|
184
|
+
catalog.live = false;
|
|
185
|
+
return catalog;
|
|
186
|
+
}
|
|
187
|
+
function getDeepInfraSurfaceFallbackCatalog() {
|
|
188
|
+
return manifestFallbackCatalog();
|
|
189
|
+
}
|
|
190
|
+
function resolveDeepInfraThinkingFormat(modelId) {
|
|
191
|
+
return (modelId ?? "").toLowerCase().split("/")[0] === "deepseek-ai" ? "deepseek" : void 0;
|
|
192
|
+
}
|
|
193
|
+
function buildDeepInfraModelDefinition(model) {
|
|
194
|
+
const thinkingFormat = model.compat?.thinkingFormat ?? resolveDeepInfraThinkingFormat(model.id);
|
|
195
|
+
return {
|
|
196
|
+
...model,
|
|
197
|
+
compat: {
|
|
198
|
+
...model.compat,
|
|
199
|
+
supportsUsageInStreaming: model.compat?.supportsUsageInStreaming ?? true,
|
|
200
|
+
...thinkingFormat ? { thinkingFormat } : {}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function chatSurfaceModelToModelDefinition(model) {
|
|
205
|
+
const input = model.tags.includes("vlm") ? ["text", "image"] : ["text"];
|
|
206
|
+
const reasoning = model.tags.includes("reasoning") || model.tags.includes("reasoning_effort");
|
|
207
|
+
return buildDeepInfraModelDefinition({
|
|
208
|
+
id: model.id,
|
|
209
|
+
name: model.name,
|
|
210
|
+
reasoning,
|
|
211
|
+
input,
|
|
212
|
+
contextWindow: model.contextWindow ?? DEEPINFRA_DEFAULT_CONTEXT_WINDOW,
|
|
213
|
+
maxTokens: model.maxTokens ?? DEEPINFRA_DEFAULT_MAX_TOKENS,
|
|
214
|
+
cost: {
|
|
215
|
+
input: model.pricing.input_tokens ?? 0,
|
|
216
|
+
output: model.pricing.output_tokens ?? 0,
|
|
217
|
+
cacheRead: model.pricing.cache_read_tokens ?? 0,
|
|
218
|
+
cacheWrite: 0
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function hasDeepInfraApiKey(options) {
|
|
223
|
+
const fromEnv = (options?.env ?? process.env).DEEPINFRA_API_KEY;
|
|
224
|
+
if (typeof fromEnv === "string" && fromEnv.trim() !== "") return true;
|
|
225
|
+
const providers = options?.config?.models?.providers;
|
|
226
|
+
for (const [providerId, provider] of Object.entries(providers ?? {})) if (providerId.trim().toLowerCase() === "deepinfra" && hasConfiguredSecretInput(provider?.apiKey, options?.config?.secrets?.defaults)) return true;
|
|
227
|
+
return isProviderApiKeyConfigured({
|
|
228
|
+
provider: "deepinfra",
|
|
229
|
+
agentDir: options?.agentDir
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
async function discoverDeepInfraSurfaces(options) {
|
|
233
|
+
if (process.env.VITEST) return manifestFallbackCatalog();
|
|
234
|
+
const env = options?.env ?? process.env;
|
|
235
|
+
if (!(options?.hasApiKey ?? hasDeepInfraApiKey({
|
|
236
|
+
env,
|
|
237
|
+
agentDir: options?.agentDir
|
|
238
|
+
}))) return manifestFallbackCatalog();
|
|
239
|
+
try {
|
|
240
|
+
const data = await getCachedLiveProviderModelRows({
|
|
241
|
+
providerId: "deepinfra",
|
|
242
|
+
endpoint: DEEPINFRA_MODELS_URL,
|
|
243
|
+
timeoutMs: DISCOVERY_TIMEOUT_MS,
|
|
244
|
+
ttlMs: DISCOVERY_CACHE_TTL_MS,
|
|
245
|
+
buildRequestHeaders: () => ({ Accept: "application/json" }),
|
|
246
|
+
auditContext: "deepinfra-model-discovery",
|
|
247
|
+
shouldCacheRows: hasDeepInfraSurfaceModelRows,
|
|
248
|
+
fetchGuard: (params) => fetchWithSsrFGuard(withTrustedEnvProxyGuardedFetchMode(params))
|
|
249
|
+
});
|
|
250
|
+
if (data.length === 0) {
|
|
251
|
+
log.warn("No models found from DeepInfra agent-projection endpoint, using static catalog");
|
|
252
|
+
return manifestFallbackCatalog();
|
|
253
|
+
}
|
|
254
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
255
|
+
const surfaceModels = [];
|
|
256
|
+
for (const entry of data) {
|
|
257
|
+
const model = entryToSurfaceModel(entry);
|
|
258
|
+
if (!model || seenIds.has(model.id)) continue;
|
|
259
|
+
seenIds.add(model.id);
|
|
260
|
+
surfaceModels.push(model);
|
|
261
|
+
}
|
|
262
|
+
if (surfaceModels.length === 0) return manifestFallbackCatalog();
|
|
263
|
+
return bucketBySurface(surfaceModels);
|
|
264
|
+
} catch (error) {
|
|
265
|
+
if (error instanceof LiveModelCatalogHttpError) {
|
|
266
|
+
log.warn(`Failed to discover models: HTTP ${error.status}, using static catalog`);
|
|
267
|
+
return manifestFallbackCatalog();
|
|
268
|
+
}
|
|
269
|
+
log.warn(`Discovery failed: ${String(error)}, using static catalog`);
|
|
270
|
+
return manifestFallbackCatalog();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async function discoverDeepInfraModels(options) {
|
|
274
|
+
const catalog = await discoverDeepInfraSurfaces(options);
|
|
275
|
+
const chatModels = catalog.chat.length > 0 ? catalog.chat : [...catalog.chat, ...catalog.vlm];
|
|
276
|
+
if (chatModels.length === 0) return DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition);
|
|
277
|
+
const liveModels = chatModels.map(chatSurfaceModelToModelDefinition);
|
|
278
|
+
const seen = new Set(liveModels.map((model) => model.id));
|
|
279
|
+
const manifestModels = DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition).filter((model) => {
|
|
280
|
+
if (seen.has(model.id)) return false;
|
|
281
|
+
seen.add(model.id);
|
|
282
|
+
return true;
|
|
283
|
+
});
|
|
284
|
+
return [...liveModels, ...manifestModels];
|
|
285
|
+
}
|
|
286
|
+
//#endregion
|
|
2
287
|
export { DEEPINFRA_BASE_URL, DEEPINFRA_DEFAULT_MODEL_REF, DEEPINFRA_MODEL_CATALOG, buildDeepInfraModelDefinition, discoverDeepInfraModels, discoverDeepInfraSurfaces, getDeepInfraSurfaceFallbackCatalog, hasDeepInfraApiKey };
|
package/dist/speech-provider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEEPINFRA_BASE_URL } from "./provider-models.js";
|
|
2
2
|
import { DEEPINFRA_TTS_FALLBACK_MODELS, DEFAULT_DEEPINFRA_TTS_VOICE, normalizeDeepInfraModelRef } from "./media-models.js";
|
|
3
3
|
import { asObject, createOpenAiCompatibleSpeechProvider } from "openclaw/plugin-sdk/speech";
|
|
4
4
|
//#region extensions/deepinfra/speech-provider.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { discoverDeepInfraSurfaces } from "./provider-models.js";
|
|
2
2
|
import { DEEPINFRA_VIDEO_ASPECT_RATIOS, DEEPINFRA_VIDEO_DURATIONS } from "./media-models.js";
|
|
3
3
|
//#region extensions/deepinfra/surface-model-catalogs.ts
|
|
4
4
|
const PROVIDER_ID = "deepinfra";
|
|
@@ -27,9 +27,7 @@ function buildDeepInfraVideoModelCapabilities() {
|
|
|
27
27
|
seed: "number",
|
|
28
28
|
negative_prompt: "string",
|
|
29
29
|
negativePrompt: "string",
|
|
30
|
-
style: "string"
|
|
31
|
-
guidance_scale: "number",
|
|
32
|
-
guidanceScale: "number"
|
|
30
|
+
style: "string"
|
|
33
31
|
},
|
|
34
32
|
generate: {
|
|
35
33
|
maxVideos: 1,
|
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEEPINFRA_BASE_URL } from "./provider-models.js";
|
|
2
|
+
import { DEEPINFRA_VIDEO_ASPECT_RATIOS, DEEPINFRA_VIDEO_DURATIONS, DEEPINFRA_VIDEO_FALLBACK_MODELS, normalizeDeepInfraBaseUrl, normalizeDeepInfraModelRef } from "./media-models.js";
|
|
2
3
|
import { resolveDeepInfraVideoModelCapabilities } from "./surface-model-catalogs.js";
|
|
3
|
-
import {
|
|
4
|
+
import { asSafeIntegerInRange, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
5
|
import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
|
|
5
6
|
import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
|
|
6
7
|
import { canonicalizeBase64 } from "openclaw/plugin-sdk/media-runtime";
|
|
7
8
|
import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
|
|
8
|
-
import { assertOkOrThrowHttpError, postJsonRequest, readProviderJsonResponse, resolveProviderHttpRequestConfig } from "openclaw/plugin-sdk/provider-http";
|
|
9
|
+
import { assertOkOrThrowHttpError, createProviderOperationDeadline, pollProviderOperationJson, postJsonRequest, readProviderJsonResponse, resolveProviderHttpRequestConfig, resolveProviderOperationTimeoutMs } from "openclaw/plugin-sdk/provider-http";
|
|
9
10
|
//#region extensions/deepinfra/video-generation-provider.ts
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
const providerConfig = req.cfg?.models?.providers?.deepinfra;
|
|
15
|
-
const nativeBaseUrl = normalizeOptionalString(providerConfig?.nativeBaseUrl);
|
|
16
|
-
if (nativeBaseUrl) return normalizeDeepInfraBaseUrl(nativeBaseUrl, DEEPINFRA_NATIVE_BASE_URL);
|
|
17
|
-
const configuredBaseUrl = normalizeOptionalString(providerConfig?.baseUrl);
|
|
18
|
-
if (configuredBaseUrl?.includes("/v1/inference")) return normalizeDeepInfraBaseUrl(configuredBaseUrl, DEEPINFRA_NATIVE_BASE_URL);
|
|
19
|
-
return DEEPINFRA_NATIVE_BASE_URL;
|
|
20
|
-
}
|
|
21
|
-
function normalizeDeepInfraVideoUrl(url) {
|
|
11
|
+
const DEFAULT_HTTP_TIMEOUT_MS = 6e4;
|
|
12
|
+
const POLL_INTERVAL_MS = 5e3;
|
|
13
|
+
const MAX_POLL_ATTEMPTS = 120;
|
|
14
|
+
function normalizeDeepInfraVideoUrl(url, baseUrl) {
|
|
22
15
|
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("data:")) return url;
|
|
23
|
-
return new URL(url,
|
|
16
|
+
return new URL(url, baseUrl).href;
|
|
24
17
|
}
|
|
25
18
|
function parseVideoDataUrl(url) {
|
|
26
19
|
const match = /^data:([^;,]+);base64,(.+)$/u.exec(url);
|
|
@@ -47,33 +40,32 @@ function resolveSeed(value) {
|
|
|
47
40
|
}
|
|
48
41
|
function buildDeepInfraVideoBody(req, model) {
|
|
49
42
|
const options = req.providerOptions ?? {};
|
|
50
|
-
const body = {
|
|
43
|
+
const body = {
|
|
44
|
+
model,
|
|
45
|
+
prompt: req.prompt
|
|
46
|
+
};
|
|
51
47
|
const aspectRatio = normalizeOptionalString(req.aspectRatio);
|
|
52
48
|
if (aspectRatio) body.aspect_ratio = aspectRatio;
|
|
53
49
|
const duration = resolveDurationSeconds(req.durationSeconds);
|
|
54
|
-
if (duration) body.
|
|
50
|
+
if (duration) body.seconds = duration;
|
|
55
51
|
const seed = resolveSeed(options.seed);
|
|
56
52
|
if (seed != null) body.seed = seed;
|
|
57
53
|
const negativePrompt = normalizeOptionalString(options.negative_prompt) ?? normalizeOptionalString(options.negativePrompt);
|
|
58
54
|
if (negativePrompt) body.negative_prompt = negativePrompt;
|
|
59
55
|
const style = normalizeOptionalString(options.style);
|
|
60
56
|
if (style) body.style = style;
|
|
61
|
-
const guidanceScale = asFiniteNumber(options.guidance_scale) ?? asFiniteNumber(options.guidanceScale);
|
|
62
|
-
if (guidanceScale != null && model.startsWith("Wan-AI/")) body.guidance_scale = guidanceScale;
|
|
63
57
|
return body;
|
|
64
58
|
}
|
|
65
|
-
function firstDeepInfraVideoUrl(
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
for (const entry of payload.videos ?? []) {
|
|
69
|
-
const videoUrl = typeof entry === "string" ? normalizeOptionalString(entry) : normalizeOptionalString(entry.url) ?? normalizeOptionalString(entry.video_url);
|
|
59
|
+
function firstDeepInfraVideoUrl(job) {
|
|
60
|
+
for (const entry of job.data ?? []) {
|
|
61
|
+
const videoUrl = entry ? normalizeOptionalString(entry.url) : void 0;
|
|
70
62
|
if (videoUrl) return videoUrl;
|
|
71
63
|
}
|
|
72
64
|
}
|
|
73
|
-
function extractDeepInfraVideoAsset(
|
|
74
|
-
const videoUrl = firstDeepInfraVideoUrl(
|
|
65
|
+
function extractDeepInfraVideoAsset(job, baseUrl) {
|
|
66
|
+
const videoUrl = firstDeepInfraVideoUrl(job);
|
|
75
67
|
if (!videoUrl) throw new Error("DeepInfra video response missing video URL");
|
|
76
|
-
const normalizedUrl = normalizeDeepInfraVideoUrl(videoUrl);
|
|
68
|
+
const normalizedUrl = normalizeDeepInfraVideoUrl(videoUrl, baseUrl);
|
|
77
69
|
const dataAsset = parseVideoDataUrl(normalizedUrl);
|
|
78
70
|
if (dataAsset) return dataAsset;
|
|
79
71
|
return {
|
|
@@ -82,9 +74,11 @@ function extractDeepInfraVideoAsset(payload) {
|
|
|
82
74
|
fileName: "video-1.mp4"
|
|
83
75
|
};
|
|
84
76
|
}
|
|
85
|
-
function
|
|
86
|
-
const
|
|
87
|
-
|
|
77
|
+
function resolveDeepInfraVideoBaseUrl(req) {
|
|
78
|
+
const providerConfig = req.cfg?.models?.providers?.deepinfra;
|
|
79
|
+
const baseUrl = normalizeDeepInfraBaseUrl(providerConfig?.baseUrl, DEEPINFRA_BASE_URL);
|
|
80
|
+
if (baseUrl.includes("/v1/inference")) throw new Error("DeepInfra video generation requires an OpenAI-compatible endpoint, but models.providers.deepinfra.baseUrl targets the retired native /v1/inference surface. Run \"openclaw doctor --fix\" (api.deepinfra.com migrates automatically; custom hosts must set baseUrl to an OpenAI-compatible videos endpoint).");
|
|
81
|
+
return baseUrl;
|
|
88
82
|
}
|
|
89
83
|
function buildDeepInfraVideoGenerationProvider(options) {
|
|
90
84
|
const ids = options?.videoGenModels && options.videoGenModels.length > 0 ? options.videoGenModels.map((model) => model.id) : [...DEEPINFRA_VIDEO_FALLBACK_MODELS];
|
|
@@ -110,9 +104,7 @@ function buildDeepInfraVideoGenerationProvider(options) {
|
|
|
110
104
|
seed: "number",
|
|
111
105
|
negative_prompt: "string",
|
|
112
106
|
negativePrompt: "string",
|
|
113
|
-
style: "string"
|
|
114
|
-
guidance_scale: "number",
|
|
115
|
-
guidanceScale: "number"
|
|
107
|
+
style: "string"
|
|
116
108
|
}
|
|
117
109
|
},
|
|
118
110
|
imageToVideo: { enabled: false },
|
|
@@ -129,9 +121,13 @@ function buildDeepInfraVideoGenerationProvider(options) {
|
|
|
129
121
|
});
|
|
130
122
|
if (!auth.apiKey) throw new Error("DeepInfra API key missing");
|
|
131
123
|
const model = normalizeDeepInfraModelRef(req.model, defaultModel);
|
|
124
|
+
const deadline = createProviderOperationDeadline({
|
|
125
|
+
timeoutMs: req.timeoutMs,
|
|
126
|
+
label: "DeepInfra video generation"
|
|
127
|
+
});
|
|
132
128
|
const { baseUrl, allowPrivateNetwork, headers, dispatcherPolicy } = resolveProviderHttpRequestConfig({
|
|
133
|
-
baseUrl:
|
|
134
|
-
defaultBaseUrl:
|
|
129
|
+
baseUrl: resolveDeepInfraVideoBaseUrl(req),
|
|
130
|
+
defaultBaseUrl: DEEPINFRA_BASE_URL,
|
|
135
131
|
allowPrivateNetwork: false,
|
|
136
132
|
defaultHeaders: {
|
|
137
133
|
Authorization: `Bearer ${auth.apiKey}`,
|
|
@@ -142,31 +138,51 @@ function buildDeepInfraVideoGenerationProvider(options) {
|
|
|
142
138
|
transport: "http"
|
|
143
139
|
});
|
|
144
140
|
const { response, release } = await postJsonRequest({
|
|
145
|
-
url: `${baseUrl}
|
|
141
|
+
url: `${baseUrl}/videos`,
|
|
146
142
|
headers,
|
|
147
143
|
body: buildDeepInfraVideoBody(req, model),
|
|
148
|
-
timeoutMs:
|
|
144
|
+
timeoutMs: resolveProviderOperationTimeoutMs({
|
|
145
|
+
deadline,
|
|
146
|
+
defaultTimeoutMs: DEFAULT_HTTP_TIMEOUT_MS
|
|
147
|
+
}),
|
|
149
148
|
fetchFn: fetch,
|
|
150
149
|
allowPrivateNetwork,
|
|
151
150
|
dispatcherPolicy
|
|
152
151
|
});
|
|
152
|
+
let submitted;
|
|
153
153
|
try {
|
|
154
154
|
await assertOkOrThrowHttpError(response, "DeepInfra video generation failed");
|
|
155
|
-
|
|
156
|
-
const failed = failureMessage(payload);
|
|
157
|
-
if (failed) throw new Error(failed);
|
|
158
|
-
return {
|
|
159
|
-
videos: [extractDeepInfraVideoAsset(payload)],
|
|
160
|
-
model,
|
|
161
|
-
metadata: {
|
|
162
|
-
requestId: normalizeOptionalString(payload.request_id),
|
|
163
|
-
seed: resolveSeed(payload.seed),
|
|
164
|
-
status: payload.inference_status?.status ?? payload.status
|
|
165
|
-
}
|
|
166
|
-
};
|
|
155
|
+
submitted = await readProviderJsonResponse(response, "DeepInfra video generation failed");
|
|
167
156
|
} finally {
|
|
168
157
|
await release();
|
|
169
158
|
}
|
|
159
|
+
const jobId = normalizeOptionalString(submitted.id);
|
|
160
|
+
if (!jobId) throw new Error("DeepInfra video generation response missing job id");
|
|
161
|
+
if (submitted.status === "failed") throw new Error(normalizeOptionalString(submitted.error) ?? "DeepInfra video generation failed");
|
|
162
|
+
const completed = submitted.status === "succeeded" ? submitted : await pollProviderOperationJson({
|
|
163
|
+
url: `${baseUrl}/videos/${encodeURIComponent(jobId)}`,
|
|
164
|
+
headers,
|
|
165
|
+
deadline,
|
|
166
|
+
defaultTimeoutMs: DEFAULT_HTTP_TIMEOUT_MS,
|
|
167
|
+
fetchFn: fetch,
|
|
168
|
+
maxAttempts: MAX_POLL_ATTEMPTS,
|
|
169
|
+
pollIntervalMs: POLL_INTERVAL_MS,
|
|
170
|
+
requestFailedMessage: "DeepInfra video status request failed",
|
|
171
|
+
timeoutMessage: `DeepInfra video generation job ${jobId} did not finish in time`,
|
|
172
|
+
allowPrivateNetwork,
|
|
173
|
+
dispatcherPolicy,
|
|
174
|
+
auditContext: "deepinfra-video-status",
|
|
175
|
+
isComplete: (payload) => payload.status === "succeeded",
|
|
176
|
+
getFailureMessage: (payload) => payload.status === "failed" ? normalizeOptionalString(payload.error) ?? "DeepInfra video generation failed" : void 0
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
videos: [extractDeepInfraVideoAsset(completed, baseUrl)],
|
|
180
|
+
model: normalizeOptionalString(completed.model) ?? model,
|
|
181
|
+
metadata: {
|
|
182
|
+
jobId,
|
|
183
|
+
status: completed.status
|
|
184
|
+
}
|
|
185
|
+
};
|
|
170
186
|
}
|
|
171
187
|
};
|
|
172
188
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/deepinfra-provider",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/deepinfra-provider",
|
|
9
|
-
"version": "2026.7.2-beta.
|
|
9
|
+
"version": "2026.7.2-beta.4"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
}
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/deepinfra-provider",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.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.7.2-beta.
|
|
21
|
+
"pluginApi": ">=2026.7.2-beta.4"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.7.2-beta.
|
|
24
|
+
"openclawVersion": "2026.7.2-beta.4",
|
|
25
25
|
"bundledDist": false
|
|
26
26
|
},
|
|
27
27
|
"release": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"README.md"
|
|
40
40
|
],
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"openclaw": ">=2026.7.2-beta.
|
|
42
|
+
"openclaw": ">=2026.7.2-beta.4"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"openclaw": {
|
|
@@ -1,409 +0,0 @@
|
|
|
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, 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_REF = `deepinfra/deepseek-ai/DeepSeek-V4-Flash`;
|
|
147
|
-
const DEEPINFRA_DEFAULT_CONTEXT_WINDOW = 128e3;
|
|
148
|
-
const DEEPINFRA_DEFAULT_MAX_TOKENS = 8192;
|
|
149
|
-
const DEEPINFRA_MODEL_CATALOG = DEEPINFRA_MANIFEST_PROVIDER.models;
|
|
150
|
-
const DISCOVERY_TIMEOUT_MS = 5e3;
|
|
151
|
-
const DISCOVERY_CACHE_TTL_MS = 300 * 1e3;
|
|
152
|
-
const SURFACE_FOR_TAG = {
|
|
153
|
-
chat: "chat",
|
|
154
|
-
vlm: "vlm",
|
|
155
|
-
embed: "embed",
|
|
156
|
-
"image-gen": "image-gen",
|
|
157
|
-
"video-gen": "video-gen",
|
|
158
|
-
tts: "tts",
|
|
159
|
-
stt: "stt"
|
|
160
|
-
};
|
|
161
|
-
function entryToSurfaceModel(entry) {
|
|
162
|
-
const id = typeof entry?.id === "string" ? entry.id.trim() : "";
|
|
163
|
-
if (!id) return null;
|
|
164
|
-
const metadata = entry.metadata;
|
|
165
|
-
if (!metadata) return null;
|
|
166
|
-
const tags = Array.isArray(metadata.tags) ? metadata.tags.filter((t) => typeof t === "string") : [];
|
|
167
|
-
const pricing = metadata.pricing ?? {};
|
|
168
|
-
return {
|
|
169
|
-
id,
|
|
170
|
-
name: id,
|
|
171
|
-
description: metadata.description ?? void 0,
|
|
172
|
-
tags,
|
|
173
|
-
contextWindow: asPositiveSafeInteger(metadata.context_length),
|
|
174
|
-
maxTokens: asPositiveSafeInteger(metadata.max_tokens),
|
|
175
|
-
pricing,
|
|
176
|
-
defaultWidth: asPositiveSafeInteger(metadata.default_width),
|
|
177
|
-
defaultHeight: asPositiveSafeInteger(metadata.default_height),
|
|
178
|
-
defaultIterations: asPositiveSafeInteger(metadata.default_iterations)
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
function bucketBySurface(models) {
|
|
182
|
-
const catalog = {
|
|
183
|
-
chat: [],
|
|
184
|
-
vlm: [],
|
|
185
|
-
embed: [],
|
|
186
|
-
imageGen: [],
|
|
187
|
-
videoGen: [],
|
|
188
|
-
tts: [],
|
|
189
|
-
stt: [],
|
|
190
|
-
live: true
|
|
191
|
-
};
|
|
192
|
-
const buckets = {
|
|
193
|
-
chat: catalog.chat,
|
|
194
|
-
vlm: catalog.vlm,
|
|
195
|
-
embed: catalog.embed,
|
|
196
|
-
"image-gen": catalog.imageGen,
|
|
197
|
-
"video-gen": catalog.videoGen,
|
|
198
|
-
tts: catalog.tts,
|
|
199
|
-
stt: catalog.stt
|
|
200
|
-
};
|
|
201
|
-
for (const model of models) {
|
|
202
|
-
const seen = /* @__PURE__ */ new Set();
|
|
203
|
-
for (const tag of model.tags) {
|
|
204
|
-
const surface = SURFACE_FOR_TAG[tag];
|
|
205
|
-
if (surface && !seen.has(surface)) {
|
|
206
|
-
seen.add(surface);
|
|
207
|
-
buckets[surface].push(model);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return catalog;
|
|
212
|
-
}
|
|
213
|
-
function hasDeepInfraSurfaceModelRows(rows) {
|
|
214
|
-
return rows.some((entry) => entryToSurfaceModel(entry) !== null);
|
|
215
|
-
}
|
|
216
|
-
function manifestChatEntryToSurfaceModel(entry) {
|
|
217
|
-
const cost = entry.cost ?? {};
|
|
218
|
-
const pricing = {};
|
|
219
|
-
if (typeof cost.input === "number") pricing.input_tokens = cost.input;
|
|
220
|
-
if (typeof cost.output === "number") pricing.output_tokens = cost.output;
|
|
221
|
-
if (typeof cost.cacheRead === "number" && cost.cacheRead > 0) pricing.cache_read_tokens = cost.cacheRead;
|
|
222
|
-
const tags = ["chat"];
|
|
223
|
-
if (entry.input?.includes("image")) tags.push("vlm");
|
|
224
|
-
if (entry.reasoning) tags.push("reasoning");
|
|
225
|
-
return {
|
|
226
|
-
id: entry.id,
|
|
227
|
-
name: entry.name ?? entry.id,
|
|
228
|
-
tags,
|
|
229
|
-
contextWindow: entry.contextWindow,
|
|
230
|
-
maxTokens: entry.maxTokens,
|
|
231
|
-
pricing
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
const STATIC_NON_CHAT_FALLBACK = [
|
|
235
|
-
{
|
|
236
|
-
id: "black-forest-labs/FLUX-1-schnell",
|
|
237
|
-
name: "black-forest-labs/FLUX-1-schnell",
|
|
238
|
-
tags: ["image-gen"],
|
|
239
|
-
pricing: { per_image_unit: .003 },
|
|
240
|
-
defaultWidth: 1024,
|
|
241
|
-
defaultHeight: 1024,
|
|
242
|
-
defaultIterations: 4
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
id: "black-forest-labs/FLUX-1-dev",
|
|
246
|
-
name: "black-forest-labs/FLUX-1-dev",
|
|
247
|
-
tags: ["image-gen"],
|
|
248
|
-
pricing: { per_image_unit: .025 },
|
|
249
|
-
defaultWidth: 1024,
|
|
250
|
-
defaultHeight: 1024,
|
|
251
|
-
defaultIterations: 28
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
id: "Qwen/Qwen-Image-Max",
|
|
255
|
-
name: "Qwen/Qwen-Image-Max",
|
|
256
|
-
tags: ["image-gen"],
|
|
257
|
-
pricing: { per_image_unit: .075 },
|
|
258
|
-
defaultWidth: 1024,
|
|
259
|
-
defaultHeight: 1024,
|
|
260
|
-
defaultIterations: 28
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
id: "stabilityai/sdxl-turbo",
|
|
264
|
-
name: "stabilityai/sdxl-turbo",
|
|
265
|
-
tags: ["image-gen"],
|
|
266
|
-
pricing: { per_image_unit: 2e-4 },
|
|
267
|
-
defaultWidth: 1024,
|
|
268
|
-
defaultHeight: 1024,
|
|
269
|
-
defaultIterations: 4
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
id: "hexgrad/Kokoro-82M",
|
|
273
|
-
name: "hexgrad/Kokoro-82M",
|
|
274
|
-
tags: ["tts"],
|
|
275
|
-
pricing: { input_characters: .65 }
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
id: "Qwen/Qwen3-TTS",
|
|
279
|
-
name: "Qwen/Qwen3-TTS",
|
|
280
|
-
tags: ["tts"],
|
|
281
|
-
pricing: { input_characters: .65 }
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
id: "ResembleAI/chatterbox-turbo",
|
|
285
|
-
name: "ResembleAI/chatterbox-turbo",
|
|
286
|
-
tags: ["tts"],
|
|
287
|
-
pricing: { input_characters: 1 }
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
id: "sesame/csm-1b",
|
|
291
|
-
name: "sesame/csm-1b",
|
|
292
|
-
tags: ["tts"],
|
|
293
|
-
pricing: { input_characters: 7 }
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
id: "openai/whisper-large-v3-turbo",
|
|
297
|
-
name: "openai/whisper-large-v3-turbo",
|
|
298
|
-
tags: ["stt"],
|
|
299
|
-
pricing: { input_seconds: 4e-5 }
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
id: "BAAI/bge-m3",
|
|
303
|
-
name: "BAAI/bge-m3",
|
|
304
|
-
tags: ["embed"],
|
|
305
|
-
pricing: { input_tokens: .01 },
|
|
306
|
-
maxTokens: 8192,
|
|
307
|
-
contextWindow: 8192
|
|
308
|
-
}
|
|
309
|
-
];
|
|
310
|
-
function manifestFallbackCatalog() {
|
|
311
|
-
const catalog = bucketBySurface([...(modelCatalog.providers.deepinfra.models ?? []).map(manifestChatEntryToSurfaceModel), ...STATIC_NON_CHAT_FALLBACK]);
|
|
312
|
-
catalog.live = false;
|
|
313
|
-
return catalog;
|
|
314
|
-
}
|
|
315
|
-
function getDeepInfraSurfaceFallbackCatalog() {
|
|
316
|
-
return manifestFallbackCatalog();
|
|
317
|
-
}
|
|
318
|
-
function buildDeepInfraModelDefinition(model) {
|
|
319
|
-
return {
|
|
320
|
-
...model,
|
|
321
|
-
compat: {
|
|
322
|
-
...model.compat,
|
|
323
|
-
supportsUsageInStreaming: model.compat?.supportsUsageInStreaming ?? true
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
function chatSurfaceModelToModelDefinition(model) {
|
|
328
|
-
const input = model.tags.includes("vlm") ? ["text", "image"] : ["text"];
|
|
329
|
-
const reasoning = model.tags.includes("reasoning") || model.tags.includes("reasoning_effort");
|
|
330
|
-
return buildDeepInfraModelDefinition({
|
|
331
|
-
id: model.id,
|
|
332
|
-
name: model.name,
|
|
333
|
-
reasoning,
|
|
334
|
-
input,
|
|
335
|
-
contextWindow: model.contextWindow ?? DEEPINFRA_DEFAULT_CONTEXT_WINDOW,
|
|
336
|
-
maxTokens: model.maxTokens ?? DEEPINFRA_DEFAULT_MAX_TOKENS,
|
|
337
|
-
cost: {
|
|
338
|
-
input: model.pricing.input_tokens ?? 0,
|
|
339
|
-
output: model.pricing.output_tokens ?? 0,
|
|
340
|
-
cacheRead: model.pricing.cache_read_tokens ?? 0,
|
|
341
|
-
cacheWrite: 0
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
function hasDeepInfraApiKey(options) {
|
|
346
|
-
const fromEnv = (options?.env ?? process.env).DEEPINFRA_API_KEY;
|
|
347
|
-
if (typeof fromEnv === "string" && fromEnv.trim() !== "") return true;
|
|
348
|
-
const providers = options?.config?.models?.providers;
|
|
349
|
-
for (const [providerId, provider] of Object.entries(providers ?? {})) if (providerId.trim().toLowerCase() === "deepinfra" && hasConfiguredSecretInput(provider?.apiKey, options?.config?.secrets?.defaults)) return true;
|
|
350
|
-
return isProviderApiKeyConfigured({
|
|
351
|
-
provider: "deepinfra",
|
|
352
|
-
agentDir: options?.agentDir
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
async function discoverDeepInfraSurfaces(options) {
|
|
356
|
-
if (process.env.VITEST) return manifestFallbackCatalog();
|
|
357
|
-
const env = options?.env ?? process.env;
|
|
358
|
-
if (!(options?.hasApiKey ?? hasDeepInfraApiKey({
|
|
359
|
-
env,
|
|
360
|
-
agentDir: options?.agentDir
|
|
361
|
-
}))) return manifestFallbackCatalog();
|
|
362
|
-
try {
|
|
363
|
-
const data = await getCachedLiveProviderModelRows({
|
|
364
|
-
providerId: "deepinfra",
|
|
365
|
-
endpoint: DEEPINFRA_MODELS_URL,
|
|
366
|
-
timeoutMs: DISCOVERY_TIMEOUT_MS,
|
|
367
|
-
ttlMs: DISCOVERY_CACHE_TTL_MS,
|
|
368
|
-
buildRequestHeaders: () => ({ Accept: "application/json" }),
|
|
369
|
-
auditContext: "deepinfra-model-discovery",
|
|
370
|
-
shouldCacheRows: hasDeepInfraSurfaceModelRows
|
|
371
|
-
});
|
|
372
|
-
if (data.length === 0) {
|
|
373
|
-
log.warn("No models found from DeepInfra agent-projection endpoint, using static catalog");
|
|
374
|
-
return manifestFallbackCatalog();
|
|
375
|
-
}
|
|
376
|
-
const seenIds = /* @__PURE__ */ new Set();
|
|
377
|
-
const surfaceModels = [];
|
|
378
|
-
for (const entry of data) {
|
|
379
|
-
const model = entryToSurfaceModel(entry);
|
|
380
|
-
if (!model || seenIds.has(model.id)) continue;
|
|
381
|
-
seenIds.add(model.id);
|
|
382
|
-
surfaceModels.push(model);
|
|
383
|
-
}
|
|
384
|
-
if (surfaceModels.length === 0) return manifestFallbackCatalog();
|
|
385
|
-
return bucketBySurface(surfaceModels);
|
|
386
|
-
} catch (error) {
|
|
387
|
-
if (error instanceof LiveModelCatalogHttpError) {
|
|
388
|
-
log.warn(`Failed to discover models: HTTP ${error.status}, using static catalog`);
|
|
389
|
-
return manifestFallbackCatalog();
|
|
390
|
-
}
|
|
391
|
-
log.warn(`Discovery failed: ${String(error)}, using static catalog`);
|
|
392
|
-
return manifestFallbackCatalog();
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
async function discoverDeepInfraModels(options) {
|
|
396
|
-
const catalog = await discoverDeepInfraSurfaces(options);
|
|
397
|
-
const chatModels = catalog.chat.length > 0 ? catalog.chat : [...catalog.chat, ...catalog.vlm];
|
|
398
|
-
if (chatModels.length === 0) return DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition);
|
|
399
|
-
const liveModels = chatModels.map(chatSurfaceModelToModelDefinition);
|
|
400
|
-
const seen = new Set(liveModels.map((model) => model.id));
|
|
401
|
-
const manifestModels = DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition).filter((model) => {
|
|
402
|
-
if (seen.has(model.id)) return false;
|
|
403
|
-
seen.add(model.id);
|
|
404
|
-
return true;
|
|
405
|
-
});
|
|
406
|
-
return [...liveModels, ...manifestModels];
|
|
407
|
-
}
|
|
408
|
-
//#endregion
|
|
409
|
-
export { discoverDeepInfraModels as a, hasDeepInfraApiKey as c, buildDeepInfraModelDefinition as i, DEEPINFRA_DEFAULT_MODEL_REF as n, discoverDeepInfraSurfaces as o, DEEPINFRA_MODEL_CATALOG as r, getDeepInfraSurfaceFallbackCatalog as s, DEEPINFRA_BASE_URL as t };
|