← All @molecule/* packages · App templates
@molecule/api-ai-deepseekProvider bond · ai · API (Node) · v1.0.1 · Apache-2.0
Deepseek ai-deepseek provider for molecule.dev.
npm install @molecule/api-ai-deepseeknpm · Source on GitHub · Implements @molecule/api-ai
@molecule/api-ai-deepseek is a provider bond on the API (Node) side: it implements the ai core interface (@molecule/api-ai) with a concrete vendor or library behind it.
Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.
Works with: @molecule/api-bond, @molecule/api-i18n, @molecule/api-secrets
Secrets: DEEPSEEK_API_KEY
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
DeepSeek AI provider for molecule.dev.
provider
npm install @molecule/api-ai-deepseek @molecule/api-ai @molecule/api-bond @molecule/api-i18n @molecule/api-secrets
DeepseekConfigConfiguration for DeepSeek.
interface DeepseekConfig {
/** API key. Defaults to DEEPSEEK_API_KEY env var. */
apiKey?: string
/** Default model. Defaults to 'deepseek-v4-flash'. */
defaultModel?: string
/** Maximum tokens for completions. */
maxTokens?: number
/** Base URL override (for proxies). Defaults to 'https://api.deepseek.com'. */
baseUrl?: string
/**
* Chat-completions path appended to {@link baseUrl}. Defaults to
* `/v1/chat/completions` (DeepSeek-direct puts the version in the path). Set
* this when the same open-weight model is served by a US OpenAI-compatible
* host whose version prefix lives in the base URL instead — e.g. DeepInfra:
* `baseUrl='https://api.deepinfra.com/v1/openai'` + `completionsPath='/chat/completions'`.
*/
completionsPath?: string
/**
* Optional catalog-id → upstream-model-id map, applied to the outbound request
* ONLY. Lets a US OpenAI-compatible host (DeepInfra) receive its namespaced id
* (`deepseek-ai/DeepSeek-V4-Flash`) while the rest of the platform — pricing,
* cost ceilings, display — keeps using the canonical catalog id
* (`deepseek-v4-flash`). An id not in the map passes through unchanged.
*/
modelMap?: Record<string, string>
/** Called on each rate-limited/overloaded upstream response, before any retry sleep. */
onRateLimit?: AiRateLimitCallback
}
ProcessEnvProcess Env interface.
interface ProcessEnv {
DEEPSEEK_API_KEY: string
/** Base URL override (for credential brokers / gateways / US OpenAI-compatible hosts). */
DEEPSEEK_BASE_URL?: string
/** Chat-completions path override (see {@link DeepseekConfig.completionsPath}). */
DEEPSEEK_COMPLETIONS_PATH?: string
}
createProvider(config)Creates a DeepSeek AI provider instance.
function createProvider(config?: DeepseekConfig): AIProvider
config — DeepSeek-specific configuration (API key, model, max tokens, base URL).Returns: An AIProvider backed by the DeepSeek Chat Completions API.
aiDeepseekSecretDefinitionsSecret definitions required by the DeepSeek AI bond.
const aiDeepseekSecretDefinitions: SecretDefinition[]
DeepseekAIProviderBack-compat alias for the provider class (the scaffold exported this name).
const DeepseekAIProvider: typeof DeepseekAIProviderImpl
providerThe provider implementation.
const provider: AIProvider
Implements @molecule/api-ai interface.
Setup function to register this provider with the bond system:
import { bond } from '@molecule/api-bond'
import { provider } from '@molecule/api-ai-deepseek'
export function setupAiDeepseek(): void {
bond('ai', 'deepseek', provider)
}
Peer dependencies:
@molecule/api-ai ^1.0.1@molecule/api-bond ^1.0.1@molecule/api-i18n ^1.0.1@molecule/api-secrets ^1.0.1DEEPSEEK_API_KEY (required) — DeepSeek API key
sk-...@molecule/api-ai@molecule/api-bond@molecule/api-i18n@molecule/api-secretsConfig: DEEPSEEK_API_KEY (SERVER-side only) plus an optional default model id/base URL.
Missing DEEPSEEK_API_KEY fails fast: the provider throws naming the exact env var on
first use (the exported provider is a lazy proxy, so this fires on the first chat() call,
not at bond/module-load time) — it never silently sends an empty key.
Error message disambiguation: a plain 400 that ISN'T a context-length error (bad param, malformed tool schema) gets its own non-retryable message distinct from the generic "AI service error. Please try again." used for retryable failures.
Integration checklist — drive the real UI (live preview, no mocks), adapt each item to this app's actual chat/AI screens, and check every box off one by one. A box you can't check is an integration bug to fix — not a skip. The sandbox HAS an AI provider bonded, so the flow runs live end-to-end; AI output is NON-DETERMINISTIC, so assert on STRUCTURE/behavior, not exact text:
chat() yields text chunks then a final done; a single late
blob means the reply was awaited whole and streaming is broken.)messages history is sent, not just the last
line.