← All @molecule/* packages · App templates
@molecule/api-ai-translation-deeplProvider bond · ai-translation · API (Node) · v1.0.1 · Apache-2.0
DeepL translation provider for molecule.dev — text translation via DeepL API
npm install @molecule/api-ai-translation-deeplnpm · Source on GitHub · Implements @molecule/api-ai-translation
@molecule/api-ai-translation-deepl is a provider bond on the API (Node) side: it implements the ai-translation core interface (@molecule/api-ai-translation) 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.
import { setProvider, requireProvider } from '@molecule/api-ai-translation'
import { provider } from '@molecule/api-ai-translation-deepl'
setProvider(provider) // at startup — lazy; reads DEEPL_API_KEY on first use
const { translations } = await requireProvider().translate({
text: 'Hello, world!',
targetLang: 'DE',
})Works with: @molecule/api-ai-translation, @molecule/api-secrets
Secrets: DEEPL_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.
DeepL translation provider for molecule.dev.
Implements the full @molecule/api-ai-translation contract (translate,
getSupportedLanguages, getUsage) over the DeepL REST API, auto-batching
large inputs (50 texts per request, DeepL's limit).
import { setProvider, requireProvider } from '@molecule/api-ai-translation'
import { provider } from '@molecule/api-ai-translation-deepl'
setProvider(provider) // at startup — lazy; reads DEEPL_API_KEY on first use
const { translations } = await requireProvider().translate({
text: 'Hello, world!',
targetLang: 'DE',
})
provider
npm install @molecule/api-ai-translation-deepl @molecule/api-ai-translation @molecule/api-secrets
DeeplConfigConfiguration for the DeepL translation provider.
interface DeeplConfig {
/** DeepL API key. Defaults to DEEPL_API_KEY env var. */
apiKey?: string
/**
* Base URL for the DeepL API.
* Defaults to 'https://api-free.deepl.com' for free keys (ending in ':fx'),
* or 'https://api.deepl.com' for pro keys.
*/
baseUrl?: string
/** Default formality preference. Defaults to 'default'. */
defaultFormality?: 'default' | 'more' | 'less' | 'prefer_more' | 'prefer_less'
/** Default model type preference. Defaults to 'latency_optimized'. */
defaultModelType?: 'quality_optimized' | 'prefer_quality_optimized' | 'latency_optimized'
}
createProvider(config)Creates a DeepL translation provider instance.
function createProvider(config?: DeeplConfig): AITranslationProvider
config — DeepL-specific configuration (API key, base URL, defaults).Returns: An AITranslationProvider backed by the DeepL REST API.
aiTranslationDeeplSecretDefinitionsSecret definitions required by the DeepL translation bond.
const aiTranslationDeeplSecretDefinitions: SecretDefinition[]
providerThe provider implementation.
const provider: AITranslationProvider
Implements @molecule/api-ai-translation interface.
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/api-ai-translation'
import { provider } from '@molecule/api-ai-translation-deepl'
export function setupAiTranslationDeepl(): void {
setProvider(provider)
}
Peer dependencies:
@molecule/api-ai-translation >=1.0.1@molecule/api-secrets ^1.0.1DEEPL_API_KEY (required) — DeepL API key
279a2e9d-...:fx@molecule/api-ai-translation
@molecule/api-secrets
Wiring: bond the lazy provider export once — setProvider(provider) — or
setProvider(createProvider(config?)) to pass explicit config. Use the core's
setProvider, NOT bond('ai-translation', …).
Config: DEEPL_API_KEY (required; free keys end in :fx and auto-route to
https://api-free.deepl.com, pro keys to https://api.deepl.com); DEEPL_BASE_URL
(optional) overrides the endpoint outright — it deliberately wins over the key-shape
heuristic so credential brokers/gateways work with either key type.
Integration checklist — drive the real UI (live preview, no mocks), adapt each item to this app's actual screens/flows, 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 a live AI provider, so translations run for real; output is non-deterministic, so assert on the resulting LANGUAGE/meaning, never an exact string: