In a globalized digital world, speaking your user's language is no longer a luxury—it's a necessity. But integrating high-quality, real-time translation can be a complex and time-consuming development task. What if you could add sophisticated, human-like translation to any application with just a few lines of code?
Meet Lexi, your autonomous AI language expert. Lexi isn't just another language model; it's a complete Language-as-a-Service platform designed to handle complex linguistic workflows. Today, we'll walk you through just how simple it is to integrate powerful, on-demand translation into your app using the lexi.do API.
Before we dive into the code, let's clarify what makes Lexi unique. Lexi.do is an autonomous AI agent designed specifically for advanced language tasks. Instead of just giving you raw model outputs, Lexi operates as an agentic workflow platform.
This means Lexi can execute complex, multi-step language jobs autonomously. It's the difference between being handed a box of engine parts and being given the keys to a running car. With Lexi, you request a valuable outcome—like a perfectly formatted translation—and the agent handles the entire process. This "Business-as-Code" approach guarantees reliable, high-value results with every API call.
Ready to see it in action? Let's add autonomous translation to a project. All you need is a Node.js environment.
First, add the official lexi.do SDK to your project using your favorite package manager.
npm install @do/sdk
To use Lexi, you'll need an API key. You can get yours by signing up at lexi.do.
Once you have your key, import and instantiate the Lexi agent in your code. It's best practice to store your API key as an environment variable.
import { lexi } from '@do/sdk';
// The SDK will automatically use the LEXI_API_KEY environment variable.
// Or, you can initialize it directly:
// const lexi = new Lexi({ apiKey: "YOUR_API_KEY" });
Now for the magic. With the agent ready, you can call the translate method. Just provide the text you want to translate and the target language's ISO 639-1 code (e.g., "es" for Spanish, "fr" for French).
Here’s the complete example:
import { lexi } from '@do/sdk';
async function runTranslation() {
try {
// Translate text from English to Spanish
const translation = await lexi.translate({
text: "Hello, world! Welcome to the future of agentic workflows.",
targetLanguage: "es"
});
console.log(translation.text);
// "Hola, mundo! Bienvenidos al futuro de los flujos de trabajo agénticos."
} catch (error) {
console.error("Translation failed:", error);
}
}
runTranslation();
That's it! In just a single API call, you've leveraged an advanced AI Language Agent to perform a high-quality translation. The response is a clean, structured JSON object, making it trivial to use the output in your application.
While easy-to-integrate translation is a powerful feature, it's just the beginning of what Lexi can do. As an autonomous digital worker specializing in Natural Language Processing, Lexi can handle a wide range of tasks, including:
Because Lexi is an agent, it can chain these skills together to perform even more complex workflows, all initiated through the same simple API structure.
You've just seen how easy it is to leverage an autonomous AI agent to add powerful linguistic capabilities to your application. By abstracting away the complexity of language models and focusing on delivering final outcomes, lexi.do empowers developers to build more sophisticated, global-ready applications faster than ever before.
Ready to perfect your app's language?
Visit lexi.do to get your API key and explore the future of agentic workflows!