Skip to content

Translation

Shows how to translate text between languages using Upstage Solar Translation models.

This example assumes using Upstage; is in scope and apiKey contains your Upstage API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
// Create an authenticated client using your Upstage API key.
using var client = new UpstageClient(apiKey);

// Translate English text to Korean using the Solar translation model.
// The `TranslateAsync` method requires the model name, text, source language,
// and target language.
var response = await client.Translation.TranslateAsync(
    model: "solar-1-mini-translate-enko",
    text: "Hello, how are you?",
    sourceLang: "en",
    targetLang: "ko");

// The response contains the translated text along with the detected
// source language and the target language.

Console.WriteLine($"Translated text: {response.Output.Text}");
Console.WriteLine($"Source language: {response.Output.SourceLang}");
Console.WriteLine($"Target language: {response.Output.TargetLang}");