All Products
Search
Document Center

PolarDB:AI_SetModelToken

Last Updated:Mar 28, 2026

Configures a token for one or more AI models in PolarDB.

Syntax

boolean AI_SetModelToken(text model_id, text model_token);

Parameters

ParameterDescription
model_idThe custom name of an existing AI model. Specify a single model name, or use a wildcard (for example, dashscope%) to configure multiple models in bulk.
model_tokenThe token required to access the AI model. For example, the token for a model deployed on Platform for AI (PAI).

Return values

Return valueDescription
tThe configuration was successful.
fThe configuration failed.

Usage notes

  • This function modifies only the model_token field in the model configuration (model_config). Other fields in the configuration are not affected.

  • To bind an API key to a specific model — for example, Dashscope's general-purpose text embedding model — follow the instructions in Obtain an API key.

  • When you use a wildcard such as _dashscope%, the function applies the token to all models whose model_id starts with _dashscope.

Examples

Configure a token for a single model:

SELECT polar_ai.AI_SetModelToken('_dashscope/text_embedding/text_embedding_v2', '<YOUR_API_KEY>');

Configure a token for multiple models in bulk:

SELECT polar_ai.AI_SetModelToken('_dashscope%', '<YOUR_API_KEY>');

Replace <YOUR_API_KEY> with the actual token for the target model.