All Products
Search
Document Center

ApsaraDB for SelectDB:AI_TRANSLATE

Last Updated:Mar 28, 2026

Translates text into a specified language using a large language model (LLM).

Syntax

AI_TRANSLATE([<resource_name>], <text>, <target_language>)

Parameters

ParameterDescription
<resource_name>Optional. The name of the AI resource to use. If omitted, the resource set by SET default_ai_resource is used.
<text>The text to translate.
<target_language>The target language code, such as zh-CN or fr.

Return value

Returns the translated text as a string.

  • Returns NULL if any input value is NULL.

  • The output may vary between calls because it is generated by an LLM.

Examples

Example 1: Use the default AI resource

Set a default resource, then call AI_TRANSLATE with two arguments:

SET default_ai_resource = 'resource_name';
SELECT AI_TRANSLATE('In my mind, SelectDB is the best database management system.', 'zh-CN') AS Result;

Output:

+-----------------------------------------------------------------+
| Result                                                          |
+-----------------------------------------------------------------+
| In my opinion, SelectDB is the best database management system. |
+-----------------------------------------------------------------+

Example 2: Specify a resource explicitly

Pass the resource name as the first argument to override the default:

SELECT AI_TRANSLATE('resource_name', 'This is an example', 'fr') AS Result;

Output:

+------------------+
| Result           |
+------------------+
| Voici un exemple |
+------------------+