@openclaw/deepinfra-provider 2026.11.3 → 2026.11.5-beta.2
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/.source-module-urls/e47411ce0a5b380d6718c7048f00db584c526b307735b67498f0ef6f921381f5.json +1 -0
- package/dist/embedding-adapter.js +43 -36
- package/dist/index.js +23 -14
- package/dist/media-models.js +12 -58
- package/dist/media-understanding-provider.js +21 -24
- package/dist/provider-models.js +23 -80
- package/dist/speech-provider.js +2 -2
- package/dist/surface-model-catalogs.js +5 -10
- package/dist/video-generation-provider.js +46 -85
- package/package.json +4 -4
- package/dist/cache-wrapper.js +0 -19
- package/dist/embedding-provider.js +0 -27
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"entries":[{"output":"api.js","source":"extensions/deepinfra/api.ts"},{"output":"capability-catalog.js","source":"extensions/deepinfra/capability-catalog.ts"},{"output":"doctor-contract-api.js","source":"extensions/deepinfra/doctor-contract-api.ts"},{"output":"embedding-adapter.js","source":"extensions/deepinfra/embedding-adapter.ts"},{"output":"image-generation-provider.js","source":"extensions/deepinfra/image-generation-provider.ts"},{"output":"index.js","source":"extensions/deepinfra/index.ts"},{"output":"media-models.js","source":"extensions/deepinfra/media-models.ts"},{"output":"media-understanding-provider.js","source":"extensions/deepinfra/media-understanding-provider.ts"},{"output":"onboard.js","source":"extensions/deepinfra/onboard.ts"},{"output":"pricing-api.js","source":"extensions/deepinfra/pricing-api.ts"},{"output":"provider-catalog.js","source":"extensions/deepinfra/provider-catalog.ts"},{"output":"provider-discovery.js","source":"extensions/deepinfra/provider-discovery.ts"},{"output":"provider-models.js","source":"extensions/deepinfra/provider-models.ts"},{"output":"provider-policy-api.js","source":"extensions/deepinfra/provider-policy-api.ts"},{"output":"provider-static-catalog.js","source":"extensions/deepinfra/provider-static-catalog.ts"},{"output":"speech-provider.js","source":"extensions/deepinfra/speech-provider.ts"},{"output":"surface-model-catalogs.js","source":"extensions/deepinfra/surface-model-catalogs.ts"},{"output":"video-generation-provider.js","source":"extensions/deepinfra/video-generation-provider.ts"}],"chunks":[{"output":".setup/openclaw.plugin-5ywdmEQ1.mjs","sha256":"d886336558c66de379832139f1279b29f472f5ab0553f9cd5bfcbd8d32a29556","facadeSource":null,"sources":["extensions/deepinfra/openclaw.plugin.json"]},{"output":"api.js","sha256":"438836f453467ae64fad54a72be481c489e621e13373b8130b5a4668d1faeea5","facadeSource":"extensions/deepinfra/api.ts","sources":[]},{"output":"capability-catalog.js","sha256":"652b9dbcc865f6c6422128640d9d8b482007bf8c8925e2151daf3b6f5b340dc5","facadeSource":"extensions/deepinfra/capability-catalog.ts","sources":["extensions/deepinfra/capability-catalog.ts"]},{"output":"doctor-contract-api.js","sha256":"5624ca2cfee48bd49bfd4422c4c48fed2553a42de770ed399cdd34027423de7a","facadeSource":"extensions/deepinfra/doctor-contract-api.ts","sources":["extensions/deepinfra/doctor-contract-api.ts","packages/normalization-core/src/record-coerce.ts","src/config/channel-config-normalization.ts","src/plugin-sdk/legacy-webhook-listener-migration.ts"]},{"output":"embedding-adapter.js","sha256":"cf8491405afba2aabc0f9d3a086d758768d8c673e8feb52fc81f26f6a04c4eaa","facadeSource":"extensions/deepinfra/embedding-adapter.ts","sources":["extensions/deepinfra/embedding-adapter.ts"]},{"output":"image-generation-provider.js","sha256":"baf39611a1fbc1fd7f097a83ed184a88197bb44d19f5b7d8b98d91a7dcf95d86","facadeSource":"extensions/deepinfra/image-generation-provider.ts","sources":["extensions/deepinfra/image-generation-provider.ts"]},{"output":"index.js","sha256":"82e7d26f24ecde1d55cb09f0afecdc24fd4addfea92b76e0a2299f14805543d9","facadeSource":"extensions/deepinfra/index.ts","sources":["extensions/deepinfra/index.ts"]},{"output":"media-models.js","sha256":"719d553095a9c38352493e64e3080572aabca5fc01a8933b93cf769143ee9488","facadeSource":"extensions/deepinfra/media-models.ts","sources":["extensions/deepinfra/media-models.ts"]},{"output":"media-understanding-provider.js","sha256":"78e89e3a6e8f98bf463c68788b2155acaf5a67365270b45ec06222d896c2b210","facadeSource":"extensions/deepinfra/media-understanding-provider.ts","sources":["extensions/deepinfra/media-understanding-provider.ts"]},{"output":"onboard.js","sha256":"89eb2e93f3f175df13b36d0907f84ec76a99efc76e1e8f2ac9aae9c7fbd80699","facadeSource":"extensions/deepinfra/onboard.ts","sources":["extensions/deepinfra/onboard.ts"]},{"output":"pricing-api.js","sha256":"cbaa06b6effaa3974bd58136be88c19e50595847736fd9c157f70f2f0dc3e2e5","facadeSource":"extensions/deepinfra/pricing-api.ts","sources":["extensions/deepinfra/pricing-api.ts"]},{"output":"provider-catalog.js","sha256":"6b2122854ffcfbeb405e9363e757c0c37f5de85e39a752ef0bcd4a2252e79830","facadeSource":"extensions/deepinfra/provider-catalog.ts","sources":["extensions/deepinfra/provider-catalog.ts"]},{"output":"provider-discovery.js","sha256":"73391b0c584877d01c72249587fb00bd7c0fed10699446b1bd5772758fbfd343","facadeSource":"extensions/deepinfra/provider-discovery.ts","sources":["extensions/deepinfra/provider-discovery.ts"]},{"output":"provider-models.js","sha256":"5ddb7c93644113c80044d97afeeda4a26fda69348e1e4a82f352e3df18e1fec1","facadeSource":"extensions/deepinfra/provider-models.ts","sources":["extensions/deepinfra/provider-models.ts"]},{"output":"provider-policy-api.js","sha256":"090ba6961fb3d7af446553e4066aa7252279b5ed375c4e6dc56371a14fe25d27","facadeSource":"extensions/deepinfra/provider-policy-api.ts","sources":["extensions/deepinfra/provider-policy-api.ts"]},{"output":"provider-static-catalog.js","sha256":"d63150533e69b8b9e39bf4bbba64aac4736874c3dee8ee0156772caa9722d09b","facadeSource":"extensions/deepinfra/provider-static-catalog.ts","sources":["extensions/deepinfra/provider-static-catalog.ts"]},{"output":"speech-provider.js","sha256":"04cfea875ec1b5eb60a7522cdb7ee95009cf0714bdd2cde0bdba673eb50e23cd","facadeSource":"extensions/deepinfra/speech-provider.ts","sources":["extensions/deepinfra/speech-provider.ts"]},{"output":"surface-model-catalogs.js","sha256":"dfc2f57ed48dac49aea9076c0c17b4813bad86fdacbdfa5df257e0fef28922db","facadeSource":"extensions/deepinfra/surface-model-catalogs.ts","sources":["extensions/deepinfra/surface-model-catalogs.ts"]},{"output":"video-generation-provider.js","sha256":"dbe57890396d11d4ac061ad394f74fd2e6d6a40efe29690e4b9696d86691d14f","facadeSource":"extensions/deepinfra/video-generation-provider.ts","sources":["extensions/deepinfra/video-generation-provider.ts"]}],"unrenderedSources":["extensions/deepinfra/api.ts"]}
|
|
@@ -1,48 +1,55 @@
|
|
|
1
|
-
import { DEEPINFRA_BASE_URL } from "./media-models.js";
|
|
2
|
-
import {
|
|
3
|
-
import { embeddingProviderOwnsDestination, sanitizeEmbeddingCacheHeaders } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
1
|
+
import { DEEPINFRA_BASE_URL, DEEPINFRA_EMBED_FALLBACK_MODELS, normalizeDeepInfraModelRef } from "./media-models.js";
|
|
2
|
+
import { createRemoteEmbeddingProvider, embeddingProviderOwnsDestination, resolveRemoteEmbeddingClient, sanitizeEmbeddingCacheHeaders } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
4
3
|
//#region extensions/deepinfra/embedding-adapter.ts
|
|
4
|
+
const DEFAULT_DEEPINFRA_EMBEDDING_MODEL = DEEPINFRA_EMBED_FALLBACK_MODELS[0];
|
|
5
5
|
const EXCLUDED_EMBEDDING_HEADERS = [
|
|
6
6
|
"authorization",
|
|
7
7
|
"content-type",
|
|
8
8
|
"x-api-key",
|
|
9
9
|
"api-key"
|
|
10
10
|
];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const deepinfraEmbeddingProviderAdapter = {
|
|
12
|
+
id: "deepinfra",
|
|
13
|
+
defaultModel: DEFAULT_DEEPINFRA_EMBEDDING_MODEL,
|
|
14
|
+
transport: "remote",
|
|
15
|
+
authProviderId: "deepinfra",
|
|
16
|
+
create: async (createOptions) => {
|
|
17
|
+
const client = await resolveRemoteEmbeddingClient({
|
|
18
|
+
provider: "deepinfra",
|
|
19
|
+
options: {
|
|
20
20
|
...createOptions,
|
|
21
21
|
provider: "deepinfra",
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
model: normalizeDeepInfraModelRef(createOptions.model, DEFAULT_DEEPINFRA_EMBEDDING_MODEL)
|
|
23
|
+
},
|
|
24
|
+
defaultBaseUrl: DEEPINFRA_BASE_URL,
|
|
25
|
+
normalizeModel: (model) => normalizeDeepInfraModelRef(model, DEFAULT_DEEPINFRA_EMBEDDING_MODEL)
|
|
26
|
+
});
|
|
27
|
+
const provider = createRemoteEmbeddingProvider({
|
|
28
|
+
id: "deepinfra",
|
|
29
|
+
client,
|
|
30
|
+
errorPrefix: "DeepInfra embeddings API error",
|
|
31
|
+
batchQueryInputs: true
|
|
32
|
+
});
|
|
33
|
+
const headers = sanitizeEmbeddingCacheHeaders(client.headers, EXCLUDED_EMBEDDING_HEADERS);
|
|
34
|
+
const usesDefaultIdentity = headers.length === 0 && embeddingProviderOwnsDestination({
|
|
35
|
+
baseUrl: client.baseUrl,
|
|
36
|
+
providerBaseUrl: DEEPINFRA_BASE_URL
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
provider,
|
|
40
|
+
runtime: {
|
|
41
|
+
id: "deepinfra",
|
|
42
|
+
cacheKeyData: {
|
|
43
|
+
provider: "deepinfra",
|
|
44
|
+
model: client.model,
|
|
45
|
+
...usesDefaultIdentity ? {} : {
|
|
46
|
+
baseUrl: client.baseUrl,
|
|
47
|
+
headers
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const deepinfraEmbeddingProviderAdapter = buildDeepInfraEmbeddingAdapter();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
47
54
|
//#endregion
|
|
48
|
-
export {
|
|
55
|
+
export { deepinfraEmbeddingProviderAdapter };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { createDeepInfraAnthropicCacheWrapper } from "./cache-wrapper.js";
|
|
2
1
|
import { t as openclaw_plugin_default } from "./.setup/openclaw.plugin-5ywdmEQ1.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { deepinfraEmbeddingProviderAdapter } from "./embedding-adapter.js";
|
|
4
3
|
import { buildDeepInfraImageGenerationProvider } from "./image-generation-provider.js";
|
|
5
|
-
import {
|
|
4
|
+
import { deepinfraMediaUnderstandingProvider } from "./media-understanding-provider.js";
|
|
6
5
|
import { DEEPINFRA_DEFAULT_MODEL_REF, buildStaticDeepInfraProvider } from "./provider-static-catalog.js";
|
|
7
6
|
import { applyDeepInfraConfig } from "./onboard.js";
|
|
8
|
-
import { getDeepInfraSurfaceFallbackCatalog } from "./provider-models.js";
|
|
9
7
|
import { buildDeepInfraApiKeyCatalog } from "./provider-catalog.js";
|
|
10
8
|
import { buildDeepInfraSpeechProvider } from "./speech-provider.js";
|
|
11
9
|
import { listDeepInfraImageGenCatalog, listDeepInfraVideoGenCatalog } from "./surface-model-catalogs.js";
|
|
@@ -13,6 +11,7 @@ import { buildDeepInfraVideoGenerationProvider } from "./video-generation-provid
|
|
|
13
11
|
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
14
12
|
import { applyModelCompatPatch, buildProviderReplayFamilyHooks } from "openclaw/plugin-sdk/provider-model-shared";
|
|
15
13
|
import { createOpenRouterWrapper, isProxyReasoningUnsupported } from "openclaw/plugin-sdk/provider-stream";
|
|
14
|
+
import { applyAnthropicEphemeralCacheControlMarkers, applyCompletionsAnthropicCacheControl, createPayloadPatchStreamWrapper } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
16
15
|
//#region extensions/deepinfra/index.ts
|
|
17
16
|
const PROVIDER_ID = "deepinfra";
|
|
18
17
|
var deepinfra_default = defineSingleProviderPluginEntry({
|
|
@@ -41,26 +40,36 @@ var deepinfra_default = defineSingleProviderPluginEntry({
|
|
|
41
40
|
}) : model,
|
|
42
41
|
wrapStreamFn: (ctx) => {
|
|
43
42
|
const thinkingLevel = isProxyReasoningUnsupported(ctx.modelId) ? void 0 : ctx.thinkingLevel;
|
|
44
|
-
|
|
43
|
+
const baseStreamFn = createOpenRouterWrapper(ctx.streamFn, thinkingLevel);
|
|
44
|
+
const extraParams = ctx.extraParams;
|
|
45
|
+
return (model, context, options) => {
|
|
46
|
+
if (!model.id.toLowerCase().startsWith("anthropic/")) return baseStreamFn(model, context, options);
|
|
47
|
+
const isCompletions = model.api === "openai-completions";
|
|
48
|
+
const configured = options?.cacheRetention ?? extraParams?.cacheRetention;
|
|
49
|
+
const cacheRetention = configured === "none" || configured === "long" ? configured : "short";
|
|
50
|
+
return createPayloadPatchStreamWrapper(baseStreamFn, ({ payload }) => {
|
|
51
|
+
if (isCompletions) applyCompletionsAnthropicCacheControl(payload, cacheRetention === "none" ? null : { type: "ephemeral" });
|
|
52
|
+
else applyAnthropicEphemeralCacheControlMarkers(payload);
|
|
53
|
+
})(model, context, isCompletions ? {
|
|
54
|
+
...options,
|
|
55
|
+
cacheRetention
|
|
56
|
+
} : options);
|
|
57
|
+
};
|
|
45
58
|
},
|
|
46
59
|
isModernModelRef: () => true,
|
|
47
60
|
isCacheTtlEligible: (ctx) => ctx.modelId.toLowerCase().startsWith("anthropic/")
|
|
48
61
|
},
|
|
49
62
|
register(api) {
|
|
50
|
-
|
|
51
|
-
api.registerImageGenerationProvider(buildDeepInfraImageGenerationProvider({ imageGenModels: catalog.imageGen }));
|
|
63
|
+
api.registerImageGenerationProvider(buildDeepInfraImageGenerationProvider());
|
|
52
64
|
api.registerModelCatalogProvider({
|
|
53
65
|
provider: PROVIDER_ID,
|
|
54
66
|
kinds: ["image_generation"],
|
|
55
67
|
liveCatalog: listDeepInfraImageGenCatalog
|
|
56
68
|
});
|
|
57
|
-
api.registerMediaUnderstandingProvider(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
api.registerEmbeddingProvider(buildDeepInfraEmbeddingAdapter({ embedModels: catalog.embed }));
|
|
62
|
-
api.registerSpeechProvider(buildDeepInfraSpeechProvider({ ttsModels: catalog.tts }));
|
|
63
|
-
api.registerVideoGenerationProvider(buildDeepInfraVideoGenerationProvider({ videoGenModels: catalog.videoGen }));
|
|
69
|
+
api.registerMediaUnderstandingProvider(deepinfraMediaUnderstandingProvider);
|
|
70
|
+
api.registerEmbeddingProvider(deepinfraEmbeddingProviderAdapter);
|
|
71
|
+
api.registerSpeechProvider(buildDeepInfraSpeechProvider());
|
|
72
|
+
api.registerVideoGenerationProvider(buildDeepInfraVideoGenerationProvider());
|
|
64
73
|
api.registerModelCatalogProvider({
|
|
65
74
|
provider: PROVIDER_ID,
|
|
66
75
|
kinds: ["video_generation"],
|
package/dist/media-models.js
CHANGED
|
@@ -12,64 +12,18 @@ const DEEPINFRA_VIDEO_ASPECT_RATIOS = [
|
|
|
12
12
|
"9:16"
|
|
13
13
|
];
|
|
14
14
|
const DEEPINFRA_VIDEO_DURATIONS = [5, 8];
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
id: "Qwen/Qwen-Image-Max",
|
|
28
|
-
price: .075,
|
|
29
|
-
iterations: 28
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: "stabilityai/sdxl-turbo",
|
|
33
|
-
price: 2e-4,
|
|
34
|
-
iterations: 4
|
|
35
|
-
}
|
|
36
|
-
].map(({ id, price, iterations }) => ({
|
|
37
|
-
id,
|
|
38
|
-
name: id,
|
|
39
|
-
tags: ["image-gen"],
|
|
40
|
-
pricing: { per_image_unit: price },
|
|
41
|
-
defaultWidth: 1024,
|
|
42
|
-
defaultHeight: 1024,
|
|
43
|
-
defaultIterations: iterations
|
|
44
|
-
}));
|
|
45
|
-
const DEEPINFRA_IMAGE_FALLBACK_MODELS = DEEPINFRA_IMAGE_FALLBACK_CATALOG.map(({ id }) => id);
|
|
46
|
-
const DEEPINFRA_TTS_FALLBACK_CATALOG = [
|
|
47
|
-
{
|
|
48
|
-
id: "hexgrad/Kokoro-82M",
|
|
49
|
-
name: "hexgrad/Kokoro-82M",
|
|
50
|
-
tags: ["tts"],
|
|
51
|
-
pricing: { input_characters: .65 }
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: "Qwen/Qwen3-TTS",
|
|
55
|
-
name: "Qwen/Qwen3-TTS",
|
|
56
|
-
tags: ["tts"],
|
|
57
|
-
pricing: { input_characters: .65 }
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
id: "ResembleAI/chatterbox-turbo",
|
|
61
|
-
name: "ResembleAI/chatterbox-turbo",
|
|
62
|
-
tags: ["tts"],
|
|
63
|
-
pricing: { input_characters: 1 }
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
id: "sesame/csm-1b",
|
|
67
|
-
name: "sesame/csm-1b",
|
|
68
|
-
tags: ["tts"],
|
|
69
|
-
pricing: { input_characters: 7 }
|
|
70
|
-
}
|
|
15
|
+
const DEEPINFRA_IMAGE_FALLBACK_MODELS = [
|
|
16
|
+
"black-forest-labs/FLUX-1-schnell",
|
|
17
|
+
"black-forest-labs/FLUX-1-dev",
|
|
18
|
+
"Qwen/Qwen-Image-Max",
|
|
19
|
+
"stabilityai/sdxl-turbo"
|
|
20
|
+
];
|
|
21
|
+
const DEEPINFRA_TTS_FALLBACK_MODELS = [
|
|
22
|
+
"hexgrad/Kokoro-82M",
|
|
23
|
+
"Qwen/Qwen3-TTS",
|
|
24
|
+
"ResembleAI/chatterbox-turbo",
|
|
25
|
+
"sesame/csm-1b"
|
|
71
26
|
];
|
|
72
|
-
const DEEPINFRA_TTS_FALLBACK_MODELS = DEEPINFRA_TTS_FALLBACK_CATALOG.map(({ id }) => id);
|
|
73
27
|
const DEEPINFRA_VIDEO_FALLBACK_MODELS = [
|
|
74
28
|
"Pixverse/Pixverse-T2V",
|
|
75
29
|
"Pixverse/Pixverse-T2V-HD",
|
|
@@ -87,4 +41,4 @@ function normalizeDeepInfraBaseUrl(value, fallback = DEEPINFRA_BASE_URL) {
|
|
|
87
41
|
return (normalizeOptionalString(value) ?? fallback).replace(/\/+$/u, "");
|
|
88
42
|
}
|
|
89
43
|
//#endregion
|
|
90
|
-
export { DEEPINFRA_BASE_URL, DEEPINFRA_EMBED_FALLBACK_MODELS,
|
|
44
|
+
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,28 +1,25 @@
|
|
|
1
1
|
import { DEEPINFRA_BASE_URL, DEEPINFRA_STT_FALLBACK_MODELS, DEEPINFRA_VLM_FALLBACK_MODELS } from "./media-models.js";
|
|
2
2
|
import { describeImageWithModel, describeImagesWithModel, transcribeOpenAiCompatibleAudio } from "openclaw/plugin-sdk/media-understanding";
|
|
3
3
|
//#region extensions/deepinfra/media-understanding-provider.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
const deepinfraMediaUnderstandingProvider = buildDeepInfraMediaUnderstandingProvider();
|
|
4
|
+
const deepinfraMediaUnderstandingProvider = {
|
|
5
|
+
id: "deepinfra",
|
|
6
|
+
capabilities: ["image", "audio"],
|
|
7
|
+
defaultModels: {
|
|
8
|
+
image: DEEPINFRA_VLM_FALLBACK_MODELS[0],
|
|
9
|
+
audio: DEEPINFRA_STT_FALLBACK_MODELS[0]
|
|
10
|
+
},
|
|
11
|
+
autoPriority: {
|
|
12
|
+
image: 45,
|
|
13
|
+
audio: 45
|
|
14
|
+
},
|
|
15
|
+
transcribeAudio: (params) => transcribeOpenAiCompatibleAudio({
|
|
16
|
+
...params,
|
|
17
|
+
provider: "deepinfra",
|
|
18
|
+
defaultBaseUrl: DEEPINFRA_BASE_URL,
|
|
19
|
+
defaultModel: DEEPINFRA_STT_FALLBACK_MODELS[0]
|
|
20
|
+
}),
|
|
21
|
+
describeImage: describeImageWithModel,
|
|
22
|
+
describeImages: describeImagesWithModel
|
|
23
|
+
};
|
|
27
24
|
//#endregion
|
|
28
|
-
export {
|
|
25
|
+
export { deepinfraMediaUnderstandingProvider };
|
package/dist/provider-models.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DEEPINFRA_BASE_URL
|
|
1
|
+
import { DEEPINFRA_BASE_URL } from "./media-models.js";
|
|
2
2
|
import { DEEPINFRA_MODEL_CATALOG, buildDeepInfraModelDefinition } from "./provider-static-catalog.js";
|
|
3
3
|
import { parseDeepInfraPricingCatalog } from "./pricing-api.js";
|
|
4
|
-
import { resolveDefaultModelMaxTokens } from "openclaw/plugin-sdk/provider-model-shared";
|
|
5
4
|
import { asPositiveSafeInteger, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
5
|
import { fetchLiveProviderModelRows } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
|
|
7
6
|
import { getCachedLiveCatalogValue } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
7
|
+
import { isStringArray } from "openclaw/plugin-sdk/collection-input-runtime";
|
|
8
8
|
import { withTrustedEnvProxyGuardedFetchMode } from "openclaw/plugin-sdk/fetch-runtime";
|
|
9
9
|
import { isProviderApiKeyConfiguredAsync } from "openclaw/plugin-sdk/provider-auth";
|
|
10
10
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
@@ -14,6 +14,7 @@ const log = createSubsystemLogger("deepinfra-models");
|
|
|
14
14
|
const DEEPINFRA_MODELS_URL = `${DEEPINFRA_BASE_URL}/models?sort_by=openclaw&filter=with_meta`;
|
|
15
15
|
const DEEPINFRA_PRICING_URL = "https://api.deepinfra.com/models/list";
|
|
16
16
|
const DEEPINFRA_DEFAULT_CONTEXT_WINDOW = 128e3;
|
|
17
|
+
const DEEPINFRA_DEFAULT_MAX_TOKENS = 8192;
|
|
17
18
|
const DISCOVERY_TIMEOUT_MS = 5e3;
|
|
18
19
|
const DISCOVERY_CACHE_TTL_MS = 3e5;
|
|
19
20
|
function entryToSurfaceModel(entry) {
|
|
@@ -21,86 +22,15 @@ function entryToSurfaceModel(entry) {
|
|
|
21
22
|
if (!id) return null;
|
|
22
23
|
const metadata = entry.metadata;
|
|
23
24
|
if (metadata === null) return null;
|
|
24
|
-
if (!isRecord(metadata) || !
|
|
25
|
-
const pricing = metadata.pricing ?? {};
|
|
25
|
+
if (!isRecord(metadata) || !isStringArray(metadata.tags)) throw new Error("DeepInfra model metadata discovery unavailable.");
|
|
26
26
|
return {
|
|
27
27
|
id,
|
|
28
28
|
name: id,
|
|
29
|
-
description: typeof metadata.description === "string" ? metadata.description : void 0,
|
|
30
29
|
tags: metadata.tags,
|
|
31
30
|
contextWindow: asPositiveSafeInteger(metadata.context_length),
|
|
32
|
-
maxTokens: asPositiveSafeInteger(metadata.max_tokens)
|
|
33
|
-
pricing,
|
|
34
|
-
defaultWidth: asPositiveSafeInteger(metadata.default_width),
|
|
35
|
-
defaultHeight: asPositiveSafeInteger(metadata.default_height),
|
|
36
|
-
defaultIterations: asPositiveSafeInteger(metadata.default_iterations)
|
|
31
|
+
maxTokens: asPositiveSafeInteger(metadata.max_tokens)
|
|
37
32
|
};
|
|
38
33
|
}
|
|
39
|
-
function bucketBySurface(models) {
|
|
40
|
-
const catalog = {
|
|
41
|
-
chat: [],
|
|
42
|
-
vlm: [],
|
|
43
|
-
embed: [],
|
|
44
|
-
imageGen: [],
|
|
45
|
-
videoGen: [],
|
|
46
|
-
tts: [],
|
|
47
|
-
stt: [],
|
|
48
|
-
live: true
|
|
49
|
-
};
|
|
50
|
-
const buckets = /* @__PURE__ */ new Map([
|
|
51
|
-
["chat", catalog.chat],
|
|
52
|
-
["vlm", catalog.vlm],
|
|
53
|
-
["embed", catalog.embed],
|
|
54
|
-
["image-gen", catalog.imageGen],
|
|
55
|
-
["video-gen", catalog.videoGen],
|
|
56
|
-
["tts", catalog.tts],
|
|
57
|
-
["stt", catalog.stt]
|
|
58
|
-
]);
|
|
59
|
-
for (const model of models) for (const tag of new Set(model.tags)) buckets.get(tag)?.push(model);
|
|
60
|
-
return catalog;
|
|
61
|
-
}
|
|
62
|
-
function manifestChatEntryToSurfaceModel(entry) {
|
|
63
|
-
const { cost } = entry;
|
|
64
|
-
const pricing = {
|
|
65
|
-
input_tokens: cost.input,
|
|
66
|
-
output_tokens: cost.output,
|
|
67
|
-
...cost.cacheRead > 0 ? { cache_read_tokens: cost.cacheRead } : {}
|
|
68
|
-
};
|
|
69
|
-
const tags = ["chat"];
|
|
70
|
-
if (entry.input.includes("image")) tags.push("vlm");
|
|
71
|
-
if (entry.reasoning) tags.push("reasoning");
|
|
72
|
-
return {
|
|
73
|
-
id: entry.id,
|
|
74
|
-
name: entry.name,
|
|
75
|
-
tags,
|
|
76
|
-
contextWindow: entry.contextWindow,
|
|
77
|
-
maxTokens: entry.maxTokens,
|
|
78
|
-
pricing
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
const STATIC_NON_CHAT_FALLBACK = [
|
|
82
|
-
...DEEPINFRA_IMAGE_FALLBACK_CATALOG,
|
|
83
|
-
...DEEPINFRA_TTS_FALLBACK_CATALOG,
|
|
84
|
-
{
|
|
85
|
-
id: "openai/whisper-large-v3-turbo",
|
|
86
|
-
name: "openai/whisper-large-v3-turbo",
|
|
87
|
-
tags: ["stt"],
|
|
88
|
-
pricing: { input_seconds: 4e-5 }
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
id: "BAAI/bge-m3",
|
|
92
|
-
name: "BAAI/bge-m3",
|
|
93
|
-
tags: ["embed"],
|
|
94
|
-
pricing: { input_tokens: .01 },
|
|
95
|
-
maxTokens: 8192,
|
|
96
|
-
contextWindow: 8192
|
|
97
|
-
}
|
|
98
|
-
];
|
|
99
|
-
function getDeepInfraSurfaceFallbackCatalog() {
|
|
100
|
-
const catalog = bucketBySurface([...DEEPINFRA_MODEL_CATALOG.map(manifestChatEntryToSurfaceModel), ...STATIC_NON_CHAT_FALLBACK]);
|
|
101
|
-
catalog.live = false;
|
|
102
|
-
return catalog;
|
|
103
|
-
}
|
|
104
34
|
function chatSurfaceModelToModelDefinition(model) {
|
|
105
35
|
const manifestModel = DEEPINFRA_MODEL_CATALOG.find((entry) => entry.id === model.id);
|
|
106
36
|
const input = model.tags.includes("vlm") ? ["text", "image"] : ["text"];
|
|
@@ -112,13 +42,13 @@ function chatSurfaceModelToModelDefinition(model) {
|
|
|
112
42
|
input,
|
|
113
43
|
...manifestModel?.compat ? { compat: manifestModel.compat } : {},
|
|
114
44
|
contextWindow: model.contextWindow ?? DEEPINFRA_DEFAULT_CONTEXT_WINDOW,
|
|
115
|
-
maxTokens: model.maxTokens ??
|
|
45
|
+
maxTokens: model.maxTokens ?? DEEPINFRA_DEFAULT_MAX_TOKENS
|
|
116
46
|
};
|
|
117
47
|
}
|
|
118
48
|
async function canDiscoverDeepInfra(options) {
|
|
119
49
|
if (options?.hasApiKey !== void 0) return options.hasApiKey;
|
|
120
50
|
const fromEnv = (options?.env ?? process.env).DEEPINFRA_API_KEY;
|
|
121
|
-
return
|
|
51
|
+
return Boolean(fromEnv?.trim()) || await isProviderApiKeyConfiguredAsync({
|
|
122
52
|
provider: "deepinfra",
|
|
123
53
|
agentDir: options?.agentDir
|
|
124
54
|
});
|
|
@@ -129,7 +59,7 @@ async function discoverDeepInfraSurfaces(options) {
|
|
|
129
59
|
} catch (error) {
|
|
130
60
|
log.warn(`Model metadata discovery unavailable: ${String(error)}`);
|
|
131
61
|
}
|
|
132
|
-
return
|
|
62
|
+
return null;
|
|
133
63
|
}
|
|
134
64
|
async function loadDeepInfraSurfaces() {
|
|
135
65
|
return getCachedLiveCatalogValue({
|
|
@@ -156,7 +86,20 @@ async function loadDeepInfraSurfaces() {
|
|
|
156
86
|
surfaceModels.push(model);
|
|
157
87
|
}
|
|
158
88
|
if (data.length > 0 && surfaceModels.length === 0) throw new Error("DeepInfra model metadata discovery unavailable.");
|
|
159
|
-
|
|
89
|
+
const catalog = {
|
|
90
|
+
chat: [],
|
|
91
|
+
vlm: [],
|
|
92
|
+
imageGen: [],
|
|
93
|
+
videoGen: []
|
|
94
|
+
};
|
|
95
|
+
const buckets = /* @__PURE__ */ new Map([
|
|
96
|
+
["chat", catalog.chat],
|
|
97
|
+
["vlm", catalog.vlm],
|
|
98
|
+
["image-gen", catalog.imageGen],
|
|
99
|
+
["video-gen", catalog.videoGen]
|
|
100
|
+
]);
|
|
101
|
+
for (const model of surfaceModels) for (const tag of new Set(model.tags)) buckets.get(tag)?.push(model);
|
|
102
|
+
return catalog;
|
|
160
103
|
}
|
|
161
104
|
});
|
|
162
105
|
}
|
|
@@ -217,4 +160,4 @@ async function discoverDeepInfraModels(options) {
|
|
|
217
160
|
}));
|
|
218
161
|
}
|
|
219
162
|
//#endregion
|
|
220
|
-
export { discoverDeepInfraModels, discoverDeepInfraSurfaces
|
|
163
|
+
export { discoverDeepInfraModels, discoverDeepInfraSurfaces };
|
package/dist/speech-provider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEEPINFRA_BASE_URL,
|
|
1
|
+
import { DEEPINFRA_BASE_URL, DEEPINFRA_TTS_FALLBACK_MODELS, DEFAULT_DEEPINFRA_TTS_VOICE, normalizeDeepInfraModelRef } from "./media-models.js";
|
|
2
2
|
import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { createOpenAiCompatibleSpeechProvider } from "openclaw/plugin-sdk/speech-provider";
|
|
4
4
|
//#region extensions/deepinfra/speech-provider.ts
|
|
@@ -11,7 +11,7 @@ const DEEPINFRA_TTS_RESPONSE_FORMATS = [
|
|
|
11
11
|
];
|
|
12
12
|
function buildDeepInfraSpeechProvider(options) {
|
|
13
13
|
const ids = options?.ttsModels && options.ttsModels.length > 0 ? options.ttsModels.map((model) => model.id) : [...DEEPINFRA_TTS_FALLBACK_MODELS];
|
|
14
|
-
const defaultModel = ids[0] ??
|
|
14
|
+
const defaultModel = ids[0] ?? DEEPINFRA_TTS_FALLBACK_MODELS[0];
|
|
15
15
|
return createOpenAiCompatibleSpeechProvider({
|
|
16
16
|
id: "deepinfra",
|
|
17
17
|
label: "DeepInfra",
|
|
@@ -28,16 +28,17 @@ async function listDeepInfraGenerationCatalog(ctx, kind) {
|
|
|
28
28
|
hasApiKey: true,
|
|
29
29
|
env: ctx.env
|
|
30
30
|
});
|
|
31
|
+
if (!catalog) return null;
|
|
31
32
|
const models = kind === "image_generation" ? catalog.imageGen : catalog.videoGen;
|
|
32
|
-
if (
|
|
33
|
+
if (models.length === 0) return null;
|
|
33
34
|
return models.map((model) => {
|
|
34
35
|
const entry = {
|
|
35
36
|
kind,
|
|
36
37
|
provider: PROVIDER_ID,
|
|
37
38
|
model: model.id,
|
|
38
|
-
source: "live"
|
|
39
|
+
source: "live",
|
|
40
|
+
label: model.name
|
|
39
41
|
};
|
|
40
|
-
if (model.name) entry.label = model.name;
|
|
41
42
|
if (kind === "video_generation") entry.capabilities = buildDeepInfraVideoModelCapabilities();
|
|
42
43
|
return entry;
|
|
43
44
|
});
|
|
@@ -48,11 +49,5 @@ function listDeepInfraImageGenCatalog(ctx) {
|
|
|
48
49
|
function listDeepInfraVideoGenCatalog(ctx) {
|
|
49
50
|
return listDeepInfraGenerationCatalog(ctx, "video_generation");
|
|
50
51
|
}
|
|
51
|
-
async function resolveDeepInfraVideoModelCapabilities(ctx) {
|
|
52
|
-
const rawId = typeof ctx.model === "string" ? ctx.model : "";
|
|
53
|
-
const normalized = rawId.startsWith(`${PROVIDER_ID}/`) ? rawId.slice(10) : rawId;
|
|
54
|
-
const catalog = await discoverDeepInfraSurfaces({ env: process.env });
|
|
55
|
-
return catalog.videoGen.find((m) => m.id === normalized) ?? catalog.videoGen.find((m) => m.id === rawId) ? buildDeepInfraVideoModelCapabilities() : void 0;
|
|
56
|
-
}
|
|
57
52
|
//#endregion
|
|
58
|
-
export { buildDeepInfraVideoModelCapabilities, listDeepInfraImageGenCatalog, listDeepInfraVideoGenCatalog
|
|
53
|
+
export { buildDeepInfraVideoModelCapabilities, listDeepInfraImageGenCatalog, listDeepInfraVideoGenCatalog };
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import { DEEPINFRA_BASE_URL, DEEPINFRA_VIDEO_FALLBACK_MODELS, normalizeDeepInfraBaseUrl, normalizeDeepInfraModelRef } from "./media-models.js";
|
|
2
|
-
import { buildDeepInfraVideoModelCapabilities
|
|
2
|
+
import { buildDeepInfraVideoModelCapabilities } from "./surface-model-catalogs.js";
|
|
3
3
|
import { asSafeIntegerInRange, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { isProviderApiKeyConfiguredAsync } from "openclaw/plugin-sdk/provider-auth";
|
|
5
5
|
import { resolveGeneratedMediaMaxBytes } from "openclaw/plugin-sdk/media-generation-runtime";
|
|
6
6
|
import { detectMime, extensionForMime, mediaKindFromMime, normalizeMimeType } from "openclaw/plugin-sdk/media-mime";
|
|
7
7
|
import { canonicalizeBase64, estimateBase64DecodedBytes } from "openclaw/plugin-sdk/media-runtime";
|
|
8
|
-
import {
|
|
9
|
-
import { assertOkOrThrowHttpError, createProviderOperationDeadline, pollProviderOperationJson, postJsonRequest, readProviderJsonResponse, resolveProviderHttpRequestConfig, resolveProviderOperationTimeoutMs, sanitizeConfiguredModelProviderRequest } from "openclaw/plugin-sdk/provider-http";
|
|
8
|
+
import { createProviderOperationDeadline, pollProviderOperationJson, postJsonResponse, resolveProviderApiKeyHttpRequestConfig, resolveProviderOperationTimeoutMs, sanitizeConfiguredModelProviderRequest } from "openclaw/plugin-sdk/provider-http";
|
|
10
9
|
//#region extensions/deepinfra/video-generation-provider.ts
|
|
11
10
|
const DEFAULT_HTTP_TIMEOUT_MS = 6e4;
|
|
12
11
|
const POLL_INTERVAL_MS = 5e3;
|
|
13
12
|
const MAX_POLL_ATTEMPTS = 120;
|
|
14
|
-
function normalizeDeepInfraVideoUrl(url, baseUrl) {
|
|
15
|
-
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("data:")) return url;
|
|
16
|
-
return new URL(url, baseUrl).href;
|
|
17
|
-
}
|
|
18
13
|
async function parseVideoDataUrl(url, maxBytes) {
|
|
19
14
|
if (!url.startsWith("data:")) return;
|
|
20
15
|
const match = /^data:([^;,]+);base64,(.*)$/su.exec(url);
|
|
@@ -35,55 +30,6 @@ async function parseVideoDataUrl(url, maxBytes) {
|
|
|
35
30
|
fileName: `video-1.${extensionForMime(detectedMime)?.slice(1) ?? "mp4"}`
|
|
36
31
|
};
|
|
37
32
|
}
|
|
38
|
-
function resolveDurationSeconds(value) {
|
|
39
|
-
if (typeof value !== "number" || !Number.isFinite(value)) return;
|
|
40
|
-
return value <= 6.5 ? 5 : 8;
|
|
41
|
-
}
|
|
42
|
-
function buildDeepInfraVideoBody(req, model) {
|
|
43
|
-
const options = req.providerOptions ?? {};
|
|
44
|
-
const body = {
|
|
45
|
-
model,
|
|
46
|
-
prompt: req.prompt
|
|
47
|
-
};
|
|
48
|
-
const aspectRatio = normalizeOptionalString(req.aspectRatio);
|
|
49
|
-
if (aspectRatio) body.aspect_ratio = aspectRatio;
|
|
50
|
-
const duration = resolveDurationSeconds(req.durationSeconds);
|
|
51
|
-
if (duration) body.seconds = duration;
|
|
52
|
-
const seed = asSafeIntegerInRange(options.seed, {
|
|
53
|
-
min: 0,
|
|
54
|
-
max: 4294967295
|
|
55
|
-
});
|
|
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
|
-
return body;
|
|
62
|
-
}
|
|
63
|
-
function firstDeepInfraVideoUrl(job) {
|
|
64
|
-
for (const entry of job.data ?? []) {
|
|
65
|
-
const videoUrl = entry ? normalizeOptionalString(entry.url) : void 0;
|
|
66
|
-
if (videoUrl) return videoUrl;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async function extractDeepInfraVideoAsset(job, baseUrl, maxBytes) {
|
|
70
|
-
const videoUrl = firstDeepInfraVideoUrl(job);
|
|
71
|
-
if (!videoUrl) throw new Error("DeepInfra video response missing video URL");
|
|
72
|
-
const normalizedUrl = normalizeDeepInfraVideoUrl(videoUrl, baseUrl);
|
|
73
|
-
const dataAsset = await parseVideoDataUrl(normalizedUrl, maxBytes);
|
|
74
|
-
if (dataAsset) return dataAsset;
|
|
75
|
-
return {
|
|
76
|
-
url: normalizedUrl,
|
|
77
|
-
mimeType: "video/mp4",
|
|
78
|
-
fileName: "video-1.mp4"
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function resolveDeepInfraVideoBaseUrl(req) {
|
|
82
|
-
const providerConfig = req.cfg?.models?.providers?.deepinfra;
|
|
83
|
-
const baseUrl = normalizeDeepInfraBaseUrl(providerConfig?.baseUrl, DEEPINFRA_BASE_URL);
|
|
84
|
-
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).");
|
|
85
|
-
return baseUrl;
|
|
86
|
-
}
|
|
87
33
|
function buildDeepInfraVideoGenerationProvider(options) {
|
|
88
34
|
const ids = options?.videoGenModels && options.videoGenModels.length > 0 ? options.videoGenModels.map((model) => model.id) : [...DEEPINFRA_VIDEO_FALLBACK_MODELS];
|
|
89
35
|
const defaultModel = ids[0] ?? DEEPINFRA_VIDEO_FALLBACK_MODELS[0];
|
|
@@ -93,7 +39,6 @@ function buildDeepInfraVideoGenerationProvider(options) {
|
|
|
93
39
|
label: "DeepInfra",
|
|
94
40
|
defaultModel,
|
|
95
41
|
models: ids,
|
|
96
|
-
resolveModelCapabilities: resolveDeepInfraVideoModelCapabilities,
|
|
97
42
|
isConfiguredAsync: (ctx) => isProviderApiKeyConfiguredAsync({
|
|
98
43
|
provider: "deepinfra",
|
|
99
44
|
...ctx
|
|
@@ -108,49 +53,54 @@ function buildDeepInfraVideoGenerationProvider(options) {
|
|
|
108
53
|
async generateVideo(req) {
|
|
109
54
|
if ((req.inputImages?.length ?? 0) > 0) throw new Error("DeepInfra video generation currently supports text-to-video only.");
|
|
110
55
|
if ((req.inputVideos?.length ?? 0) > 0) throw new Error("DeepInfra video generation does not support video reference inputs.");
|
|
111
|
-
const
|
|
56
|
+
const model = normalizeDeepInfraModelRef(req.model, defaultModel);
|
|
57
|
+
const providerConfig = req.cfg?.models?.providers?.deepinfra;
|
|
58
|
+
const configuredBaseUrl = normalizeDeepInfraBaseUrl(providerConfig?.baseUrl, DEEPINFRA_BASE_URL);
|
|
59
|
+
if (configuredBaseUrl.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).");
|
|
60
|
+
const { baseUrl, allowPrivateNetwork, headers, dispatcherPolicy } = await resolveProviderApiKeyHttpRequestConfig({
|
|
61
|
+
req,
|
|
62
|
+
missingApiKeyMessage: "DeepInfra API key missing",
|
|
63
|
+
baseUrl: configuredBaseUrl,
|
|
64
|
+
defaultBaseUrl: DEEPINFRA_BASE_URL,
|
|
112
65
|
provider: "deepinfra",
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
store: req.authStore
|
|
66
|
+
capability: "video",
|
|
67
|
+
request: sanitizeConfiguredModelProviderRequest(req.cfg?.models?.providers?.deepinfra?.request)
|
|
116
68
|
});
|
|
117
|
-
if (!auth.apiKey) throw new Error("DeepInfra API key missing");
|
|
118
|
-
const model = normalizeDeepInfraModelRef(req.model, defaultModel);
|
|
119
69
|
const deadline = createProviderOperationDeadline({
|
|
120
70
|
timeoutMs: req.timeoutMs,
|
|
121
71
|
label: "DeepInfra video generation"
|
|
122
72
|
});
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
73
|
+
const bodyOptions = req.providerOptions ?? {};
|
|
74
|
+
const body = {
|
|
75
|
+
model,
|
|
76
|
+
prompt: req.prompt
|
|
77
|
+
};
|
|
78
|
+
const aspectRatio = normalizeOptionalString(req.aspectRatio);
|
|
79
|
+
if (aspectRatio) body.aspect_ratio = aspectRatio;
|
|
80
|
+
const duration = req.durationSeconds;
|
|
81
|
+
if (typeof duration === "number" && Number.isFinite(duration)) body.seconds = duration <= 6.5 ? 5 : 8;
|
|
82
|
+
const seed = asSafeIntegerInRange(bodyOptions.seed, {
|
|
83
|
+
min: 0,
|
|
84
|
+
max: 4294967295
|
|
134
85
|
});
|
|
135
|
-
|
|
86
|
+
if (seed != null) body.seed = seed;
|
|
87
|
+
const negativePrompt = normalizeOptionalString(bodyOptions.negative_prompt) ?? normalizeOptionalString(bodyOptions.negativePrompt);
|
|
88
|
+
if (negativePrompt) body.negative_prompt = negativePrompt;
|
|
89
|
+
const style = normalizeOptionalString(bodyOptions.style);
|
|
90
|
+
if (style) body.style = style;
|
|
91
|
+
const submitted = await postJsonResponse({
|
|
136
92
|
url: `${baseUrl}/videos`,
|
|
137
93
|
headers,
|
|
138
|
-
body
|
|
94
|
+
body,
|
|
139
95
|
timeoutMs: resolveProviderOperationTimeoutMs({
|
|
140
96
|
deadline,
|
|
141
97
|
defaultTimeoutMs: DEFAULT_HTTP_TIMEOUT_MS
|
|
142
98
|
}),
|
|
143
99
|
fetchFn: fetch,
|
|
144
100
|
allowPrivateNetwork,
|
|
145
|
-
dispatcherPolicy
|
|
101
|
+
dispatcherPolicy,
|
|
102
|
+
errorLabel: "DeepInfra video generation failed"
|
|
146
103
|
});
|
|
147
|
-
let submitted;
|
|
148
|
-
try {
|
|
149
|
-
await assertOkOrThrowHttpError(response, "DeepInfra video generation failed");
|
|
150
|
-
submitted = await readProviderJsonResponse(response, "DeepInfra video generation failed");
|
|
151
|
-
} finally {
|
|
152
|
-
await release();
|
|
153
|
-
}
|
|
154
104
|
const jobId = normalizeOptionalString(submitted.id);
|
|
155
105
|
if (!jobId) throw new Error("DeepInfra video generation response missing job id");
|
|
156
106
|
if (submitted.status === "failed") throw new Error(normalizeOptionalString(submitted.error) ?? "DeepInfra video generation failed");
|
|
@@ -170,8 +120,19 @@ function buildDeepInfraVideoGenerationProvider(options) {
|
|
|
170
120
|
isComplete: (payload) => payload.status === "succeeded",
|
|
171
121
|
getFailureMessage: (payload) => payload.status === "failed" ? normalizeOptionalString(payload.error) ?? "DeepInfra video generation failed" : void 0
|
|
172
122
|
});
|
|
123
|
+
let videoUrl;
|
|
124
|
+
for (const entry of completed.data ?? []) {
|
|
125
|
+
videoUrl = entry ? normalizeOptionalString(entry.url) : void 0;
|
|
126
|
+
if (videoUrl) break;
|
|
127
|
+
}
|
|
128
|
+
if (!videoUrl) throw new Error("DeepInfra video response missing video URL");
|
|
129
|
+
const normalizedUrl = videoUrl.startsWith("http://") || videoUrl.startsWith("https://") || videoUrl.startsWith("data:") ? videoUrl : new URL(videoUrl, baseUrl).href;
|
|
173
130
|
return {
|
|
174
|
-
videos: [await
|
|
131
|
+
videos: [await parseVideoDataUrl(normalizedUrl, resolveGeneratedMediaMaxBytes(req.cfg, "video")) ?? {
|
|
132
|
+
url: normalizedUrl,
|
|
133
|
+
mimeType: "video/mp4",
|
|
134
|
+
fileName: "video-1.mp4"
|
|
135
|
+
}],
|
|
175
136
|
model: normalizeOptionalString(completed.model) ?? model,
|
|
176
137
|
metadata: {
|
|
177
138
|
jobId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/deepinfra-provider",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.5-beta.2",
|
|
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.11.
|
|
21
|
+
"pluginApi": ">=2026.11.5-beta.2"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.11.
|
|
24
|
+
"openclawVersion": "2026.11.5-beta.2",
|
|
25
25
|
"bundledDist": false
|
|
26
26
|
},
|
|
27
27
|
"release": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"assets/activity.svg"
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"openclaw": ">=2026.11.
|
|
43
|
+
"openclaw": ">=2026.11.5-beta.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"openclaw": {
|
package/dist/cache-wrapper.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { applyAnthropicEphemeralCacheControlMarkers, applyCompletionsAnthropicCacheControl, createPayloadPatchStreamWrapper } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
2
|
-
//#region extensions/deepinfra/cache-wrapper.ts
|
|
3
|
-
function createDeepInfraAnthropicCacheWrapper(baseStreamFn, extraParams) {
|
|
4
|
-
return (model, context, options) => {
|
|
5
|
-
if (!model.id.toLowerCase().startsWith("anthropic/")) return baseStreamFn(model, context, options);
|
|
6
|
-
const isCompletions = model.api === "openai-completions";
|
|
7
|
-
const configured = options?.cacheRetention ?? extraParams?.cacheRetention;
|
|
8
|
-
const cacheRetention = configured === "none" || configured === "long" ? configured : "short";
|
|
9
|
-
return createPayloadPatchStreamWrapper(baseStreamFn, ({ payload }) => {
|
|
10
|
-
if (isCompletions) applyCompletionsAnthropicCacheControl(payload, cacheRetention === "none" ? null : { type: "ephemeral" });
|
|
11
|
-
else applyAnthropicEphemeralCacheControlMarkers(payload);
|
|
12
|
-
})(model, context, isCompletions ? {
|
|
13
|
-
...options,
|
|
14
|
-
cacheRetention
|
|
15
|
-
} : options);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { createDeepInfraAnthropicCacheWrapper };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { DEEPINFRA_BASE_URL, DEEPINFRA_EMBED_FALLBACK_MODELS, normalizeDeepInfraModelRef } from "./media-models.js";
|
|
2
|
-
import { createRemoteEmbeddingProvider, resolveRemoteEmbeddingClient } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
3
|
-
//#region extensions/deepinfra/embedding-provider.ts
|
|
4
|
-
const DEFAULT_DEEPINFRA_EMBEDDING_MODEL = DEEPINFRA_EMBED_FALLBACK_MODELS[0];
|
|
5
|
-
async function createDeepInfraEmbeddingProvider(options) {
|
|
6
|
-
const defaultModel = options.defaultModel ?? DEFAULT_DEEPINFRA_EMBEDDING_MODEL;
|
|
7
|
-
const client = await resolveRemoteEmbeddingClient({
|
|
8
|
-
provider: "deepinfra",
|
|
9
|
-
options: {
|
|
10
|
-
...options,
|
|
11
|
-
model: normalizeDeepInfraModelRef(options.model, defaultModel)
|
|
12
|
-
},
|
|
13
|
-
defaultBaseUrl: DEEPINFRA_BASE_URL,
|
|
14
|
-
normalizeModel: (model) => normalizeDeepInfraModelRef(model, defaultModel)
|
|
15
|
-
});
|
|
16
|
-
return {
|
|
17
|
-
provider: createRemoteEmbeddingProvider({
|
|
18
|
-
id: "deepinfra",
|
|
19
|
-
client,
|
|
20
|
-
errorPrefix: "DeepInfra embeddings API error",
|
|
21
|
-
batchQueryInputs: true
|
|
22
|
-
}),
|
|
23
|
-
client
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { DEFAULT_DEEPINFRA_EMBEDDING_MODEL, createDeepInfraEmbeddingProvider };
|