Translation
Ask for a translation the same way you'd ask any other question — through /v1/chat/completions. No separate endpoint, no target-language parameter: say what you want in the message.
There is no /v1/translations endpoint. A translation is a normal chat completion — send the text and say which language you want back. Call larsa-auto and the router notices the instruction and routes it consistently; call larsa-general (or larsa-general-fast) directly and you get exactly the same model, one hop sooner.
What the router listens for
When you call larsa-auto, it reads your message for a translation instruction before anything else — this decides which backend answers, not what the answer says. A phrase it recognises settles the route in microseconds, with no extra model call:
| Language | Recognised as a translation instruction |
|---|---|
| English | translate — anywhere in the message |
| Persian | ترجمه کن · ترجمه بکن · به اسپانیایی ترجمه کن · برگردان به |
| Spanish | traduce · traducir · traduzca |
larsa-auto. Phrase it differently, or call larsa-general directly, and translation still works — the sentence is still an instruction the model follows, the router just isn't the one deciding that for you.Forcing the target language
There is no target_language field. Name the language in the instruction and the model does the rest — put it early in the sentence rather than trusting it to notice a language named only at the end of a long passage.
/v1/chat/completionscurl -s https://api.console.larsa.larsima.com/v1/chat/completions \
-H "Authorization: Bearer $LARSA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "larsa-auto",
"messages": [{
"role": "user",
"content": "Translate the following into Spanish: مهلت تجدیدنظرخواهی بیست روز از تاریخ ابلاغ است."
}]
}'
# {"choices":[{"message":{"content":
# "El plazo para apelar es de veinte días a partir de la fecha de notificación."
# }}], "model":"larsa-general", ...}
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.console.larsa.larsima.com/v1",
api_key=os.environ["LARSA_API_KEY"])
resp = client.chat.completions.create(
model="larsa-auto",
messages=[{
"role": "user",
"content": "Translate the following into Spanish: "
"مهلت تجدیدنظرخواهی بیست روز از تاریخ ابلاغ است.",
}],
)
print(resp.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.console.larsa.larsima.com/v1",
apiKey: process.env.LARSA_API_KEY,
});
const resp = await client.chat.completions.create({
model: "larsa-auto",
messages: [{
role: "user",
content: "Translate the following into Spanish: "
+ "مهلت تجدیدنظرخواهی بیست روز از تاریخ ابلاغ است.",
}],
});
console.log(resp.choices[0].message.content);
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.console.larsa.larsima.com/v1",
apiKey: process.env.LARSA_API_KEY,
});
const resp = await client.chat.completions.create({
model: "larsa-auto",
messages: [{
role: "user" as const,
content: "Translate the following into Spanish: "
+ "مهلت تجدیدنظرخواهی بیست روز از تاریخ ابلاغ است.",
}],
});
console.log(resp.choices[0].message.content);
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]any{
"model": "larsa-auto",
"messages": []map[string]string{{
"role": "user",
"content": "Translate the following into Spanish: " +
"مهلت تجدیدنظرخواهی بیست روز از تاریخ ابلاغ است.",
}},
})
req, _ := http.NewRequest("POST",
"https://api.console.larsa.larsima.com/v1/chat/completions", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("LARSA_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var out map[string]any
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out)
}
// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }
// serde_json = "1", tokio = { version = "1", features = ["full"] }
use serde_json::json;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let key = env::var("LARSA_API_KEY")?;
let client = reqwest::Client::new();
let body = json!({
"model": "larsa-auto",
"messages": [{
"role": "user",
"content": "Translate the following into Spanish: \
مهلت تجدیدنظرخواهی بیست روز از تاریخ ابلاغ است."
}]
});
let resp = client
.post("https://api.console.larsa.larsima.com/v1/chat/completions")
.bearer_auth(key)
.json(&body)
.send()
.await?
.text()
.await?;
println!("{resp}");
Ok(())
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
public class Translate {
public static void main(String[] args) throws Exception {
String text = "Translate the following into Spanish: "
+ "\u0645\u0647\u0644\u062a \u062a\u062c\u062f\u06cc\u062f\u0646\u0638\u0631\u062e\u0648\u0627\u0647\u06cc "
+ "\u0628\u06cc\u0633\u062a \u0631\u0648\u0632 \u0627\u0632 \u062a\u0627\u0631\u06cc\u062e "
+ "\u0627\u0628\u0644\u0627\u063a \u0627\u0633\u062a.";
String body = "{\"model\":\"larsa-auto\",\"messages\":"
+ "[{\"role\":\"user\",\"content\":\"" + text.replace("\"", "\\\"") + "\"}]}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.console.larsa.larsima.com/v1/chat/completions"))
.header("Authorization", "Bearer " + System.getenv("LARSA_API_KEY"))
.header("Content-Type", "application/json; charset=utf-8")
.POST(HttpRequest.BodyPublishers.ofString(body, StandardCharsets.UTF_8))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
var payload = new {
model = "larsa-auto",
messages = new[] {
new {
role = "user",
content = "Translate the following into Spanish: "
+ "مهلت تجدیدنظرخواهی بیست روز از تاریخ ابلاغ است.",
},
},
};
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("LARSA_API_KEY"));
var content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.console.larsa.larsima.com/v1/chat/completions", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
<?php
$payload = [
"model" => "larsa-auto",
"messages" => [[
"role" => "user",
"content" => "Translate the following into Spanish: "
. "مهلت تجدیدنظرخواهی بیست روز از تاریخ ابلاغ است.",
]],
];
$ch = curl_init("https://api.console.larsa.larsima.com/v1/chat/completions");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("LARSA_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE),
]);
echo curl_exec($ch);
require "net/http"
require "json"
require "uri"
payload = {
model: "larsa-auto",
messages: [{
role: "user",
content: "Translate the following into Spanish: "\
"مهلت تجدیدنظرخواهی بیست روز از تاریخ ابلاغ است.",
}],
}
uri = URI("https://api.console.larsa.larsima.com/v1/chat/completions")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch('LARSA_API_KEY')}"
request["Content-Type"] = "application/json"
request.body = payload.to_json
puts http.request(request).body
The three languages this system is built around
English, Persian and Spanish are what the rest of the product is built from — the Iranian and Spanish/EU legal corpora, the interface, the support that reads your traffic. Translation among these three is what actually gets exercised. Anything else routes to the same general-purpose model and its broader multilingual ability, which has not been measured here — treat it as best effort, not a guarantee, and check a sample before you rely on it.
Checking the route without spending tokens
POST /v1/route runs the same classification larsa-auto runs, without answering — useful while you're deciding how to phrase something.
curl -s https://api.console.larsa.larsima.com/v1/route \
-H "Authorization: Bearer $LARSA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"traduce esto al persa"}]}'
# {"route":"translate","decided_by":"signal",
# "backend":"http://127.0.0.1:8085/v1","elapsed":0.001}| Parameter | Type | Description |
|---|---|---|
| route Optional | string | law-ir · law-es · translate · code · general — which backend would answer. |
| decided_by Optional | string | signal (settled from the text), model (a cheap classification call was needed), or image (a picture was attached). |