Configures a token for one or more AI models in PolarDB.
Syntax
boolean AI_SetModelToken(text model_id, text model_token);Parameters
| Parameter | Description |
|---|---|
model_id | The 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_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 configuration was successful. |
f | The configuration failed. |
Usage notes
This function modifies only the
model_tokenfield 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 whosemodel_idstarts 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.