AiBrow
  • Welcome
  • AiBrow web API
    • Getting started
    • Feature comparison
  • AiBrow Extension
    • Getting started
    • Web polyfill
    • Helping users install the AiBrow extension
    • Remove the on-device helper or models
  • Examples
    • CoreModel API
    • Embedding API
    • LanguageDetector API
    • LanguageModel API
    • Rewriter API
    • Summarizer API
    • Translator API
    • Writer API
    • Using different models
    • Model download feedback
    • Getting JSON output
  • API Reference
    • AI
      • AiBrowAI
      • BrowserAI
      • WebAI
    • AiBrow
      • CoreModelFactory
        • CoreModel
        • CoreModelCapabilities
      • EmbeddingFactory
        • Embedding
        • EmbeddingCapabilities
      • LanguageDetectorFactory
        • LanguageDetector
        • LanguageDectectorCapabilities
      • LanguageModelFactory
        • LanguageModel
        • LanguageModelCapabilities
      • RewriterFactory
        • Rewriter
        • RewriterCapabilities
      • SummarizerFactory
        • Summarizer
        • SummarizerCapabilities
      • TranslatorFactory
        • Translator
        • TranslatorCapabilities
      • WriterFactory
        • Writer
        • WriterCapabilities
    • Types
      • AICapabilityAvailability
      • AICapabilityGpuEngine
      • AICreateMonitor
      • AILanguageDetectorDetectResult
      • AIRewriterFormat
      • AIRewriterLength
      • AIRewriterTone
      • AISummarizerFormat
      • AISummarizerLength
      • AISummarizerType
      • AIWriterFormat
      • AIWriterLength
      • AIWriterTone
      • AIModelDtype
    • Models
Powered by GitBook
On this page
  1. Examples

Translator API

PreviousSummarizer APINextWriter API

Last updated 5 months ago

The translation API allows you to rewrite some text in a different language

This API is compatible with the shipping with Google Chrome

Use the translation API to translate a block of text

const translator = await window.aibrow.translator.create({
  sourceLanguage: 'en',
  targetLanguage: 'es'
});

// Prompt the model and wait for the whole result to come back.
const result = await translator.translate("If you don't build your dream, someone else will hire you to help them build theirs.");
console.log(result);

// Prompt the model and stream the result:
const stream = await translator.translateStreaming("If you don't build your dream, someone else will hire you to help them build theirs.");
for await (const chunk of stream) {
  console.log(chunk);
}
Translation API proposal