@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.
@@ -0,0 +1,179 @@
1
+ import { DEEPINFRA_NATIVE_BASE_URL, DEEPINFRA_VIDEO_ASPECT_RATIOS, DEEPINFRA_VIDEO_DURATIONS, DEEPINFRA_VIDEO_FALLBACK_MODELS, normalizeDeepInfraBaseUrl, normalizeDeepInfraModelRef } from "./media-models.js";
2
+ import { resolveDeepInfraVideoModelCapabilities } from "./surface-model-catalogs.js";
3
+ import { asFiniteNumber, asSafeIntegerInRange, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth";
5
+ import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
6
+ import { canonicalizeBase64 } from "openclaw/plugin-sdk/media-runtime";
7
+ import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
8
+ import { assertOkOrThrowHttpError, postJsonRequest, resolveProviderHttpRequestConfig } from "openclaw/plugin-sdk/provider-http";
9
+ //#region extensions/deepinfra/video-generation-provider.ts
10
+ function encodeDeepInfraModelPath(model) {
11
+ return model.split("/").map(encodeURIComponent).join("/");
12
+ }
13
+ function resolveDeepInfraNativeBaseUrl(req) {
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) {
22
+ if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("data:")) return url;
23
+ return new URL(url, "https://api.deepinfra.com").href;
24
+ }
25
+ function parseVideoDataUrl(url) {
26
+ const match = /^data:([^;,]+);base64,(.+)$/u.exec(url);
27
+ if (!match) return;
28
+ const mimeType = match[1] ?? "video/mp4";
29
+ const ext = extensionForMime(mimeType)?.slice(1) ?? "mp4";
30
+ const canonicalBase64 = canonicalizeBase64(match[2] ?? "");
31
+ if (!canonicalBase64) throw new Error("DeepInfra video response returned malformed data URL base64");
32
+ return {
33
+ buffer: Buffer.from(canonicalBase64, "base64"),
34
+ mimeType,
35
+ fileName: `video-1.${ext}`
36
+ };
37
+ }
38
+ function resolveDurationSeconds(value) {
39
+ if (typeof value !== "number" || !Number.isFinite(value)) return;
40
+ return value <= 6.5 ? 5 : 8;
41
+ }
42
+ function resolveSeed(value) {
43
+ return asSafeIntegerInRange(value, {
44
+ min: 0,
45
+ max: 4294967295
46
+ });
47
+ }
48
+ function buildDeepInfraVideoBody(req, model) {
49
+ const options = req.providerOptions ?? {};
50
+ const body = { prompt: req.prompt };
51
+ const aspectRatio = normalizeOptionalString(req.aspectRatio);
52
+ if (aspectRatio) body.aspect_ratio = aspectRatio;
53
+ const duration = resolveDurationSeconds(req.durationSeconds);
54
+ if (duration) body.duration = duration;
55
+ const seed = resolveSeed(options.seed);
56
+ if (seed != null) body.seed = seed;
57
+ const negativePrompt = normalizeOptionalString(options.negative_prompt) ?? normalizeOptionalString(options.negativePrompt);
58
+ if (negativePrompt) body.negative_prompt = negativePrompt;
59
+ const style = normalizeOptionalString(options.style);
60
+ 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
+ return body;
64
+ }
65
+ function firstDeepInfraVideoUrl(payload) {
66
+ const direct = normalizeOptionalString(payload.video_url) ?? normalizeOptionalString(payload.video);
67
+ if (direct) return direct;
68
+ for (const entry of payload.videos ?? []) {
69
+ const videoUrl = typeof entry === "string" ? normalizeOptionalString(entry) : normalizeOptionalString(entry.url) ?? normalizeOptionalString(entry.video_url);
70
+ if (videoUrl) return videoUrl;
71
+ }
72
+ }
73
+ function extractDeepInfraVideoAsset(payload) {
74
+ const videoUrl = firstDeepInfraVideoUrl(payload);
75
+ if (!videoUrl) throw new Error("DeepInfra video response missing video URL");
76
+ const normalizedUrl = normalizeDeepInfraVideoUrl(videoUrl);
77
+ const dataAsset = parseVideoDataUrl(normalizedUrl);
78
+ if (dataAsset) return dataAsset;
79
+ return {
80
+ url: normalizedUrl,
81
+ mimeType: "video/mp4",
82
+ fileName: "video-1.mp4"
83
+ };
84
+ }
85
+ function failureMessage(payload) {
86
+ const status = (normalizeOptionalString(payload.inference_status?.status) ?? normalizeOptionalString(payload.status))?.toLowerCase();
87
+ if (status === "failed" || status === "error") return "DeepInfra video generation failed";
88
+ }
89
+ function buildDeepInfraVideoGenerationProvider(options) {
90
+ const ids = options?.videoGenModels && options.videoGenModels.length > 0 ? options.videoGenModels.map((model) => model.id) : [...DEEPINFRA_VIDEO_FALLBACK_MODELS];
91
+ const defaultModel = ids[0] ?? DEEPINFRA_VIDEO_FALLBACK_MODELS[0];
92
+ return {
93
+ id: "deepinfra",
94
+ label: "DeepInfra",
95
+ defaultModel,
96
+ models: ids,
97
+ resolveModelCapabilities: resolveDeepInfraVideoModelCapabilities,
98
+ isConfigured: ({ agentDir }) => isProviderApiKeyConfigured({
99
+ provider: "deepinfra",
100
+ agentDir
101
+ }),
102
+ capabilities: {
103
+ generate: {
104
+ maxVideos: 1,
105
+ maxDurationSeconds: 8,
106
+ supportedDurationSeconds: [...DEEPINFRA_VIDEO_DURATIONS],
107
+ supportsAspectRatio: true,
108
+ aspectRatios: [...DEEPINFRA_VIDEO_ASPECT_RATIOS],
109
+ providerOptions: {
110
+ seed: "number",
111
+ negative_prompt: "string",
112
+ negativePrompt: "string",
113
+ style: "string",
114
+ guidance_scale: "number",
115
+ guidanceScale: "number"
116
+ }
117
+ },
118
+ imageToVideo: { enabled: false },
119
+ videoToVideo: { enabled: false }
120
+ },
121
+ async generateVideo(req) {
122
+ if ((req.inputImages?.length ?? 0) > 0) throw new Error("DeepInfra video generation currently supports text-to-video only.");
123
+ if ((req.inputVideos?.length ?? 0) > 0) throw new Error("DeepInfra video generation does not support video reference inputs.");
124
+ const auth = await resolveApiKeyForProvider({
125
+ provider: "deepinfra",
126
+ cfg: req.cfg,
127
+ agentDir: req.agentDir,
128
+ store: req.authStore
129
+ });
130
+ if (!auth.apiKey) throw new Error("DeepInfra API key missing");
131
+ const model = normalizeDeepInfraModelRef(req.model, defaultModel);
132
+ const { baseUrl, allowPrivateNetwork, headers, dispatcherPolicy } = resolveProviderHttpRequestConfig({
133
+ baseUrl: resolveDeepInfraNativeBaseUrl(req),
134
+ defaultBaseUrl: DEEPINFRA_NATIVE_BASE_URL,
135
+ allowPrivateNetwork: false,
136
+ defaultHeaders: {
137
+ Authorization: `Bearer ${auth.apiKey}`,
138
+ "Content-Type": "application/json"
139
+ },
140
+ provider: "deepinfra",
141
+ capability: "video",
142
+ transport: "http"
143
+ });
144
+ const { response, release } = await postJsonRequest({
145
+ url: `${baseUrl}/${encodeDeepInfraModelPath(model)}`,
146
+ headers,
147
+ body: buildDeepInfraVideoBody(req, model),
148
+ timeoutMs: req.timeoutMs,
149
+ fetchFn: fetch,
150
+ allowPrivateNetwork,
151
+ dispatcherPolicy
152
+ });
153
+ try {
154
+ await assertOkOrThrowHttpError(response, "DeepInfra video generation failed");
155
+ let payload;
156
+ try {
157
+ payload = await response.json();
158
+ } catch (cause) {
159
+ throw new Error("DeepInfra video generation failed: malformed JSON response", { cause });
160
+ }
161
+ const failed = failureMessage(payload);
162
+ if (failed) throw new Error(failed);
163
+ return {
164
+ videos: [extractDeepInfraVideoAsset(payload)],
165
+ model,
166
+ metadata: {
167
+ requestId: normalizeOptionalString(payload.request_id),
168
+ seed: resolveSeed(payload.seed),
169
+ status: payload.inference_status?.status ?? payload.status
170
+ }
171
+ };
172
+ } finally {
173
+ await release();
174
+ }
175
+ }
176
+ };
177
+ }
178
+ //#endregion
179
+ export { buildDeepInfraVideoGenerationProvider };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@openclaw/deepinfra-provider",
3
+ "version": "2026.6.9",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "@openclaw/deepinfra-provider",
9
+ "version": "2026.6.9"
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,224 @@
1
+ {
2
+ "id": "deepinfra",
3
+ "activation": {
4
+ "onStartup": false
5
+ },
6
+ "enabledByDefault": true,
7
+ "providers": ["deepinfra"],
8
+ "providerCatalogEntry": "./provider-discovery.ts",
9
+ "providerAuthEnvVars": {
10
+ "deepinfra": ["DEEPINFRA_API_KEY"]
11
+ },
12
+ "providerEndpoints": [
13
+ {
14
+ "endpointClass": "deepinfra-native",
15
+ "hosts": ["api.deepinfra.com"]
16
+ }
17
+ ],
18
+ "providerRequest": {
19
+ "providers": {
20
+ "deepinfra": {
21
+ "family": "deepinfra"
22
+ }
23
+ }
24
+ },
25
+ "setup": {
26
+ "providers": [
27
+ {
28
+ "id": "deepinfra",
29
+ "authMethods": ["api-key"],
30
+ "envVars": ["DEEPINFRA_API_KEY"]
31
+ }
32
+ ]
33
+ },
34
+ "modelCatalog": {
35
+ "providers": {
36
+ "deepinfra": {
37
+ "baseUrl": "https://api.deepinfra.com/v1/openai",
38
+ "api": "openai-completions",
39
+ "models": [
40
+ {
41
+ "id": "deepseek-ai/DeepSeek-V4-Flash",
42
+ "name": "DeepSeek V4 Flash",
43
+ "reasoning": true,
44
+ "input": ["text"],
45
+ "contextWindow": 1048576,
46
+ "maxTokens": 1048576,
47
+ "cost": {
48
+ "input": 0.1,
49
+ "output": 0.2,
50
+ "cacheRead": 0.02,
51
+ "cacheWrite": 0
52
+ },
53
+ "compat": {
54
+ "supportsUsageInStreaming": true
55
+ }
56
+ },
57
+ {
58
+ "id": "deepseek-ai/DeepSeek-V3.2",
59
+ "name": "DeepSeek V3.2",
60
+ "reasoning": false,
61
+ "input": ["text"],
62
+ "contextWindow": 163840,
63
+ "maxTokens": 163840,
64
+ "cost": {
65
+ "input": 0.26,
66
+ "output": 0.38,
67
+ "cacheRead": 0.13,
68
+ "cacheWrite": 0
69
+ },
70
+ "compat": {
71
+ "supportsUsageInStreaming": true
72
+ }
73
+ },
74
+ {
75
+ "id": "zai-org/GLM-5.1",
76
+ "name": "GLM-5.1",
77
+ "reasoning": true,
78
+ "input": ["text"],
79
+ "contextWindow": 202752,
80
+ "maxTokens": 202752,
81
+ "cost": {
82
+ "input": 1.05,
83
+ "output": 3.5,
84
+ "cacheRead": 0.205000005,
85
+ "cacheWrite": 0
86
+ },
87
+ "compat": {
88
+ "supportsUsageInStreaming": true
89
+ }
90
+ },
91
+ {
92
+ "id": "stepfun-ai/Step-3.5-Flash",
93
+ "name": "Step 3.5 Flash",
94
+ "reasoning": false,
95
+ "input": ["text"],
96
+ "contextWindow": 262144,
97
+ "maxTokens": 262144,
98
+ "cost": {
99
+ "input": 0.1,
100
+ "output": 0.3,
101
+ "cacheRead": 0.02,
102
+ "cacheWrite": 0
103
+ },
104
+ "compat": {
105
+ "supportsUsageInStreaming": true
106
+ }
107
+ },
108
+ {
109
+ "id": "MiniMaxAI/MiniMax-M2.5",
110
+ "name": "MiniMax M2.5",
111
+ "reasoning": true,
112
+ "input": ["text"],
113
+ "contextWindow": 196608,
114
+ "maxTokens": 196608,
115
+ "cost": {
116
+ "input": 0.15,
117
+ "output": 1.15,
118
+ "cacheRead": 0.03,
119
+ "cacheWrite": 0
120
+ },
121
+ "compat": {
122
+ "supportsUsageInStreaming": true
123
+ }
124
+ },
125
+ {
126
+ "id": "moonshotai/Kimi-K2.5",
127
+ "name": "Kimi K2.5",
128
+ "reasoning": true,
129
+ "input": ["text", "image"],
130
+ "contextWindow": 262144,
131
+ "maxTokens": 262144,
132
+ "cost": {
133
+ "input": 0.45,
134
+ "output": 2.25,
135
+ "cacheRead": 0.070000002,
136
+ "cacheWrite": 0
137
+ },
138
+ "compat": {
139
+ "supportsUsageInStreaming": true
140
+ }
141
+ },
142
+ {
143
+ "id": "nvidia/NVIDIA-Nemotron-3-Super-120B-A12B",
144
+ "name": "NVIDIA Nemotron 3 Super 120B A12B",
145
+ "reasoning": true,
146
+ "input": ["text"],
147
+ "contextWindow": 262144,
148
+ "maxTokens": 262144,
149
+ "cost": {
150
+ "input": 0.1,
151
+ "output": 0.5,
152
+ "cacheRead": 0,
153
+ "cacheWrite": 0
154
+ },
155
+ "compat": {
156
+ "supportsUsageInStreaming": true
157
+ }
158
+ },
159
+ {
160
+ "id": "meta-llama/Llama-3.3-70B-Instruct-Turbo",
161
+ "name": "Llama 3.3 70B Instruct Turbo",
162
+ "reasoning": false,
163
+ "input": ["text"],
164
+ "contextWindow": 131072,
165
+ "maxTokens": 131072,
166
+ "cost": {
167
+ "input": 0.1,
168
+ "output": 0.32,
169
+ "cacheRead": 0,
170
+ "cacheWrite": 0
171
+ },
172
+ "compat": {
173
+ "supportsUsageInStreaming": true
174
+ }
175
+ }
176
+ ]
177
+ }
178
+ },
179
+ "discovery": {
180
+ "deepinfra": "refreshable"
181
+ }
182
+ },
183
+ "providerAuthChoices": [
184
+ {
185
+ "provider": "deepinfra",
186
+ "method": "api-key",
187
+ "choiceId": "deepinfra-api-key",
188
+ "choiceLabel": "DeepInfra API key",
189
+ "choiceHint": "Unified API for open source models",
190
+ "groupId": "deepinfra",
191
+ "groupLabel": "DeepInfra",
192
+ "groupHint": "Unified API for open source models",
193
+ "optionKey": "deepinfraApiKey",
194
+ "cliFlag": "--deepinfra-api-key",
195
+ "cliOption": "--deepinfra-api-key <key>",
196
+ "cliDescription": "DeepInfra API key"
197
+ }
198
+ ],
199
+ "contracts": {
200
+ "mediaUnderstandingProviders": ["deepinfra"],
201
+ "memoryEmbeddingProviders": ["deepinfra"],
202
+ "imageGenerationProviders": ["deepinfra"],
203
+ "speechProviders": ["deepinfra"],
204
+ "videoGenerationProviders": ["deepinfra"]
205
+ },
206
+ "mediaUnderstandingProviderMetadata": {
207
+ "deepinfra": {
208
+ "capabilities": ["image", "audio"],
209
+ "defaultModels": {
210
+ "image": "moonshotai/Kimi-K2.5",
211
+ "audio": "openai/whisper-large-v3-turbo"
212
+ },
213
+ "autoPriority": {
214
+ "image": 45,
215
+ "audio": 45
216
+ }
217
+ }
218
+ },
219
+ "configSchema": {
220
+ "type": "object",
221
+ "additionalProperties": false,
222
+ "properties": {}
223
+ }
224
+ }
package/package.json CHANGED
@@ -1,14 +1,50 @@
1
1
  {
2
2
  "name": "@openclaw/deepinfra-provider",
3
- "version": "0.0.0",
4
- "description": "Reserved package name for an official OpenClaw plugin.",
5
- "license": "MIT",
3
+ "version": "2026.6.9",
4
+ "description": "OpenClaw DeepInfra provider plugin.",
6
5
  "repository": {
7
6
  "type": "git",
8
- "url": "git+https://github.com/openclaw/openclaw.git"
7
+ "url": "https://github.com/openclaw/openclaw"
9
8
  },
10
- "publishConfig": {
11
- "access": "public",
12
- "tag": "placeholder"
13
- }
9
+ "type": "module",
10
+ "openclaw": {
11
+ "extensions": [
12
+ "./index.ts"
13
+ ],
14
+ "install": {
15
+ "clawhubSpec": "clawhub:@openclaw/deepinfra-provider",
16
+ "npmSpec": "@openclaw/deepinfra-provider",
17
+ "defaultChoice": "npm",
18
+ "minHostVersion": ">=2026.6.8"
19
+ },
20
+ "compat": {
21
+ "pluginApi": ">=2026.6.9"
22
+ },
23
+ "build": {
24
+ "openclawVersion": "2026.6.9",
25
+ "bundledDist": false
26
+ },
27
+ "release": {
28
+ "publishToClawHub": true,
29
+ "publishToNpm": true
30
+ },
31
+ "runtimeExtensions": [
32
+ "./dist/index.js"
33
+ ]
34
+ },
35
+ "files": [
36
+ "dist/**",
37
+ "openclaw.plugin.json",
38
+ "npm-shrinkwrap.json",
39
+ "README.md"
40
+ ],
41
+ "peerDependencies": {
42
+ "openclaw": ">=2026.6.9"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "openclaw": {
46
+ "optional": true
47
+ }
48
+ },
49
+ "bundledDependencies": []
14
50
  }