// Venice plugin entrypoint registers its OpenClaw integration. import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry"; import { applyModelCompatPatch, type ModelCompatConfig, } from "openclaw/plugin-sdk/provider-model-shared"; import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime"; import { applyVeniceConfig, VENICE_DEFAULT_MODEL_REF } from "./onboard.js"; import { buildVeniceProvider } from "./provider-catalog.js"; import { createVeniceDeepSeekV4Wrapper } from "./stream.js"; import { fetchVeniceUsage } from "./usage.js"; const PROVIDER_ID = "venice"; const XAI_UNSUPPORTED_SCHEMA_KEYWORDS = [ "minLength", "maxLength", "minItems", "maxItems", "minContains", "maxContains", ] as const; function applyXaiModelCompat(model: T): T { return applyModelCompatPatch(model as T & { compat?: ModelCompatConfig }, { toolSchemaProfile: "xai", unsupportedToolSchemaKeywords: [...XAI_UNSUPPORTED_SCHEMA_KEYWORDS], nativeWebSearchTool: true, toolCallArgumentsEncoding: "html-entities", }) as T; } function isXaiBackedVeniceModel(modelId: string): boolean { return normalizeLowercaseStringOrEmpty(modelId).includes("grok"); } export default defineSingleProviderPluginEntry({ id: PROVIDER_ID, name: "Venice Provider", description: "Bundled Venice provider plugin", provider: { label: "Venice", docsPath: "/providers/venice", auth: [ { methodId: "api-key", label: "Venice AI API key", hint: "Privacy-focused (uncensored models)", optionKey: "veniceApiKey", flagName: "--venice-api-key", envVar: "VENICE_API_KEY", promptMessage: "Enter Venice AI API key", defaultModel: VENICE_DEFAULT_MODEL_REF, applyConfig: (cfg) => applyVeniceConfig(cfg), noteMessage: [ "Venice AI provides privacy-focused inference with uncensored models.", "Get your API key at: https://venice.ai/settings/api", "Supports 'private' (fully private) and 'anonymized' (proxy) modes.", ].join("\n"), noteTitle: "Venice AI", wizard: { groupLabel: "Venice AI", }, }, ], catalog: { buildProvider: buildVeniceProvider, }, normalizeResolvedModel: ({ modelId, model }) => isXaiBackedVeniceModel(modelId) ? applyXaiModelCompat(model) : undefined, wrapStreamFn: (ctx) => createVeniceDeepSeekV4Wrapper(ctx.streamFn, ctx.thinkingLevel), resolveUsageAuth: async (ctx) => { const apiKey = ctx.resolveApiKeyFromConfigAndStore({ envDirect: [ctx.env.VENICE_API_KEY], }); return apiKey ? { token: apiKey } : null; }, fetchUsageSnapshot: async (ctx) => await fetchVeniceUsage({ token: ctx.token, timeoutMs: ctx.timeoutMs, fetchFn: ctx.fetchFn, }), }, });