All Products
Search
Document Center

PolarDB:AI_SetModelToken

Last Updated:Apr 16, 2025

Configures a token for one or multiple models.

Syntax

boolean AI_SetModelToken(text model_id, text model_token);

Parameters

Parameter

Description

model_id

The custom name of an existing AI model. You can specify a single model or use wildcards (for example, dashscope%) to specify multiple models in bulk.

model_token

The token required to access the AI model. For example, the token for the model deployed on Platform for AI (PAI).

Return values

Return value

Description

t

The configuration was successful.

f

The configuration failed.

Description

  • This function is designed to modify only the token field in the model configuration (model_config).

  • When you bind an API key to a specified model, such as Dashscope's general-purpose text embedding model, refer to the instructions on obtaining and specifying the API key in Obtain an API key.

  • If you use a wildcard to specify multiple model names, such as _dashscope%, the system 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>');