Call the translation engine directly from your own scripts with @shipi18n/core.
npm install @shipi18n/core @anthropic-ai/sdk
# or, for OpenAI
npm install @shipi18n/core openaiSet your own LLM key in the environment. It is read at translation time and never written to disk or sent anywhere except your provider:
# .env — never commit this
ANTHROPIC_API_KEY=your-key-hereUse OPENAI_API_KEY instead if you pass --provider openai.
const { result } = await translateJSON({ content, from: 'en', to: 'es' })import { translateJSON } from '@shipi18n/core'
const { result, stats } = await translateJSON({
content: { greeting: 'Hello {{name}}' },
from: 'en',
to: 'es',
provider: 'anthropic',
})
console.log(result) // { greeting: 'Hola {{name}}' }
console.log(stats) // { translated, reused, placeholderWarnings }const { result } = await translateJSON({
content: source,
from: 'en',
to: 'fr',
provider: 'anthropic',
existing: previousFrench, // only new or empty keys are sent
})const myAdapter = {
name: 'my-llm',
async complete(prompt) {
// call your model however you like, return its text
return await callMyModel(prompt)
},
}
await translateJSON({ content, from: 'en', to: 'de', provider: myAdapter })The provider SDKs are optional peer dependencies so you only install the one you use. Run npm install @anthropic-ai/sdk (or openai).
@shipi18n/core is ESM. Use "type": "module" in package.json, an .mjs file, or a dynamic import() from CommonJS.
Need help? Read the docs