nativ-vercel-ai
v0.1.0
Published
Nativ localization tools for the Vercel AI SDK — translate, search TM, and more as AI agent tools
Maintainers
Readme
nativ-vercel-ai
Nativ localization tools for the Vercel AI SDK. Give any AI agent the ability to translate, search translation memory, and manage localization settings — all using your team's brand voice and style guides.
Install
npm install nativ-vercel-ai ai zodQuick start
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { createNativTools } from "nativ-vercel-ai";
const nativTools = createNativTools(); // reads NATIV_API_KEY from env
const { text } = await generateText({
model: openai("gpt-4o"),
tools: nativTools,
maxSteps: 5,
prompt: 'Translate "Welcome back!" into French, German, and Japanese.',
});
console.log(text);Configuration
// Pass options explicitly
const tools = createNativTools({
apiKey: "nativ_...",
baseUrl: "https://api.usenativ.com", // default
timeout: 120_000, // default: 2 minutes
});
// Or set environment variable
// NATIV_API_KEY=nativ_...
const tools = createNativTools();Get your API key at dashboard.usenativ.com → Settings → API Keys.
Available tools
| Tool | Description |
|------|-------------|
| nativ_translate | Translate text with cultural adaptation, TM matching, and rationale |
| nativ_translate_batch | Translate multiple texts to the same target language |
| nativ_search_translation_memory | Search existing translations for consistency |
| nativ_add_translation_memory | Store an approved translation for future reuse |
| nativ_get_languages | List configured languages with formality settings |
| nativ_get_style_guides | Get all style guides |
| nativ_get_brand_voice | Get the brand voice prompt |
| nativ_get_tm_stats | Translation memory statistics |
Use with streamText
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";
import { createNativTools } from "nativ-vercel-ai";
const result = streamText({
model: openai("gpt-4o"),
tools: createNativTools(),
maxSteps: 5,
prompt: "What languages do we support?",
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}Cherry-pick tools
const allTools = createNativTools();
// Only expose translate to the model
const { text } = await generateText({
model: openai("gpt-4o"),
tools: {
nativ_translate: allTools.nativ_translate,
},
prompt: 'Say "Thank you" in Korean',
});Next.js route handler
// app/api/chat/route.ts
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";
import { createNativTools } from "nativ-vercel-ai";
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model: openai("gpt-4o"),
tools: createNativTools(),
maxSteps: 10,
messages,
});
return result.toDataStreamResponse();
}How it works
createNativTools() instantiates a nativ-sdk client and wraps each API method as a Vercel AI SDK tool() with typed Zod schemas. The tools are provider-agnostic — they work with OpenAI, Anthropic, Google, and any model the AI SDK supports.
Related packages
| Package | Description | |---------|-------------| | nativ-sdk | Node.js/TypeScript SDK | | nativ | Python SDK | | langchain-nativ | LangChain tools | | nativ-mcp | MCP server |
License
MIT — see LICENSE.
