translate( )
Translates text from one language to another using a specified translation model. Supports both NMT (Neural Machine Translation) and LLM models.
function translate(params: TranslateClientParams): { stats: Promise<any>; text: Promise<string>; tokenStream: AsyncGenerator<string> }Description
Translates text from one language to another using a specified translation model. Supports both NMT (Neural Machine Translation) and LLM models.
Parameters
| Name | Type | Required? | Description |
|---|---|---|---|
params | TranslateClientParams | ✓ | Translation configuration object |
Returns
{ stats: Promise<any>; text: Promise<string>; tokenStream: AsyncGenerator<string> }Examples
// Streaming mode (default)
const result = translate({
modelId: "modelId",
text: "Hello world",
from: "en",
to: "es"
modelType: "llm",
});
for await (const token of result.tokenStream) {
console.log(token);
}
// Non-streaming mode
const response = translate({
modelId: "modelId",
text: "Hello world",
from: "en",
to: "es"
modelType: "llm",
stream: false,
});
console.log(await response.text);transcribeStream( )
This function streams audio transcription results in real-time, yielding text chunks as they become available from the model.
unloadModel( )
Unloads a previously loaded model from the server. When the last model is unloaded (no more models remain), this function automatically closes the RPC connection, allowing the process to exit naturally without requiring manual cleanup.