Building Adaptive Multilingual Apps Using TypeScript and Azure AI Translator API
Julia Muiruri guides developers through leveraging the 2025-05-01-preview Azure AI Translator API in TypeScript applications, with a focus on adaptive translation, LLM integration, and migration best practices.
Building Adaptive Multilingual Apps Using TypeScript and Azure AI Translator API
Author: Julia Muiruri
Azure AI Translator enhances multilingual capabilities for modern applications via a REST API, introducing the 2025-05-01-preview version with new Large Language Model (LLM) translation options that expand beyond traditional Neural Machine Translation (NMT). This release provides TypeScript developers with greater control over translation style, tone, and gender, as well as hybrid flows that optimize for cost, speed, and linguistic nuance.
Key Features in 2025-05-01-preview
- LLM Translation Support:
- Option to select GPT-4o or GPT-4o-mini model deployments to achieve richer, context-sensitive translations (requires Azure AI Foundry resource).
- Enhance outputs with tone (formal/informal/neutral) and gender (male/female/neutral) customization.
- Adaptive Customization:
- Supports up to five reference translation pairs or datasets for few-shot style adaptation—valuable for organizations seeking compliance with brand voice or regulatory wording.
- Hybrid Translation Flows:
- Combine NMT and LLM targets in a single request, making it possible to tailor strategies for high-volume versus high-precision scenarios and optimize billing (character-based for NMT, token-based for LLM).
- Migration Improvements:
- Transitioning from v3 to preview requires request body structure changes, new API params, deprecation of some features, and updated error logging and response handling.
Example Scenario
A support agent (English) at Zava, a home improvement retailer, chats with a French-speaking customer. Key translation tasks include tone adaptation (formal for official support, casual on community forums), gender specificity, generating variants for QA or compliance, and providing NMT fallback if LLM is unavailable or unsupported.
Sample Code Snippets (TypeScript)
Neural Machine Translation (NMT)
async function translateWithNMT(text: string, from: string, to: string) {
const headers = {
'Ocp-Apim-Subscription-Key': process.env.API_KEY!,
'Ocp-Apim-Subscription-Region': process.env.REGION!,
'Content-type': 'application/json',
};
const params = new URLSearchParams({ 'api-version': '2025-05-01-preview' });
const body = [
{ text: "J'ai un problème avec ma commande.", language: "fr", targets: [{ language: "en" }] }
];
const response = await axios.post(`${globalEndpoint}/translate`, body, { headers, params });
return response.data;
}
Expected output: English translation — I have a problem with my order.
LLM Translation with Tone & Gender
async function translateWithLLM(text: string, from: string, to: string, model: string, tone: string, gender: string) {
const headers = {
'Ocp-Apim-Subscription-Key': process.env.FOUNDRY_API_KEY!,
'Ocp-Apim-Subscription-Region': process.env.REGION!,
'Content-type': 'application/json',
};
const params = new URLSearchParams({ 'api-version': '2025-05-01-preview' });
const body = [
{
text: "Your case has been forwarded to the support supervisor, April Gittens. She will contact you today to review the situation.",
language: "en",
targets: [
{ language: "fr", deploymentName: "gpt-4o-mini", tone: "formal", gender: "female" },
{ language: "fr", deploymentName: "gpt-4o-mini", tone: "formal", gender: "male" },
{ language: "fr" }
]
}
];
const response = await axios.post(`${globalEndpoint}/translate`, body, { headers, params });
return response.data;
}
Expected output: French translations with male/female variation and tone adaptation.
Migration Guide (v3 ➔ 2025-05-01-preview)
- Refactor requests to use an array of objects with
text,language, andtargetsfields. - Remove features like BreakSentence, Detect, and Dictionary operations.
- Add Foundry API keys for LLM use.
- Validate language codes and update error handling to fit new schema.
- Monitor both character and token usage.
Data Privacy & Compliance Considerations
- Select regional endpoints to control data geography; the global endpoint might route across regions during outages.
- LLM deployments are configured by geography (global, data zone, regional) during setup for regulatory compliance.
- Enable Virtual Network (VNET) and private endpoints for stricter security; note that these do not support global endpoints or token authentication.
Resources and Further Reading
- Azure AI Translator Code Examples (Python & TypeScript)
- Azure AI Translator Preview Overview
- Translate API (Preview) Documentation
- Migration Guide
- Create Translator Resources
- Supported Language Codes
Updated Oct 30, 2025
Authored by Julia Muiruri. For more detailed walkthroughs or to see the complete code repository, follow the resources above.
This post appeared first on “Microsoft Tech Community”. Read the entire article here