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
| Parameter | Description |
|---|---|
model_id | The custom name of an existing AI model. To target multiple models at once, use a wildcard pattern (for example, dashscope%). |
model_token | The token required to access the AI model. For example, the token for a model deployed on Platform for AI (PAI). |
Return values
| Return value | Description |
|---|---|
t | The token was configured successfully. |
f | The configuration failed. |
Usage notes
This function updates only the
tokenfield 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 whosemodel_idstarts 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>');