mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
// Deepinfra provider module implements model/runtime integration.
|
|
import {
|
|
buildSingleProviderApiKeyCatalog,
|
|
type ProviderCatalogContext,
|
|
type ProviderCatalogResult,
|
|
} from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
|
import {
|
|
DEEPINFRA_BASE_URL,
|
|
DEEPINFRA_MODEL_CATALOG,
|
|
buildDeepInfraModelDefinition,
|
|
discoverDeepInfraModels,
|
|
} from "./provider-models.js";
|
|
|
|
export function buildStaticDeepInfraProvider(): ModelProviderConfig {
|
|
return {
|
|
baseUrl: DEEPINFRA_BASE_URL,
|
|
api: "openai-completions",
|
|
models: DEEPINFRA_MODEL_CATALOG.map(buildDeepInfraModelDefinition),
|
|
};
|
|
}
|
|
|
|
export async function buildDeepInfraProvider(options?: {
|
|
hasApiKey?: boolean;
|
|
env?: NodeJS.ProcessEnv;
|
|
agentDir?: string;
|
|
}): Promise<ModelProviderConfig> {
|
|
const models = await discoverDeepInfraModels(options);
|
|
return {
|
|
baseUrl: DEEPINFRA_BASE_URL,
|
|
api: "openai-completions",
|
|
models,
|
|
};
|
|
}
|
|
|
|
export function buildDeepInfraApiKeyCatalog(
|
|
ctx: ProviderCatalogContext,
|
|
): Promise<ProviderCatalogResult> {
|
|
return buildSingleProviderApiKeyCatalog({
|
|
ctx,
|
|
providerId: "deepinfra",
|
|
// The shared API-key helper already resolved env/profile credentials.
|
|
// Pass that fact into discovery so profile-only setups get the live catalog.
|
|
buildProvider: () =>
|
|
buildDeepInfraProvider({
|
|
hasApiKey: true,
|
|
env: ctx.env,
|
|
agentDir: ctx.agentDir,
|
|
}),
|
|
});
|
|
}
|