Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Guidance for building and deploying AI solutions on Azure using Azure AI services and Copilot for Azure
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/sdk/azure-ai-translation-ts.md
1# Azure Translation — TypeScript SDK Quick Reference23> Condensed from **azure-ai-translation-ts**. Full patterns (document translation, batch SAS, transliterate)4> in the **azure-ai-translation-ts** plugin skill if installed.56## Install7```bash8npm install @azure-rest/ai-translation-text @azure/identity9```1011## Quick Start12```typescript13import TextTranslationClient, { TranslatorCredential, isUnexpected } from "@azure-rest/ai-translation-text";14const credential: TranslatorCredential = { key: process.env.TRANSLATOR_SUBSCRIPTION_KEY!, region: process.env.TRANSLATOR_REGION! };15const client = TextTranslationClient(process.env.TRANSLATOR_ENDPOINT!, credential);16```1718## Non-Obvious Patterns19- REST client — `TextTranslationClient` is a function, not a class20- Translate via `client.path("/translate").post({ body: { inputs: [...] } })`21- Document translation: separate package `@azure-rest/ai-translation-document`22- Batch docs require SAS URLs for source/target blob containers2324## Best Practices251. Auto-detect source — omit `language` parameter to auto-detect262. Batch requests — translate multiple texts in one call for efficiency273. Use SAS tokens — for document translation, use time-limited SAS URLs284. Handle errors — always check `isUnexpected(response)` before accessing body295. Regional endpoints — use regional endpoints for lower latency30