All Products
Search
Document Center

PolarDB:AI_SetModelToken

Last Updated:Mar 28, 2026

Sets the access token for one or more AI models in PolarDB for PostgreSQL.

Syntax

boolean AI_SetModelToken(text model_id, text model_token);

Parameters

ParameterDescription
model_idThe custom name of an existing AI model. To target multiple models at once, use a wildcard pattern (for example, dashscope%).
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 token was configured successfully.
fThe configuration failed.

Usage notes

  • This function updates only the token field in the model configuration (model_config). Other fields remain unchanged.

  • To bind a DashScope API key to a specific model, such as the DashScope general-purpose text embedding model, get your API key from Model Studio before calling this function.

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

Examples

Set the token for a single model:

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

Set the token for all models with a shared prefix using a wildcard:

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