AI_SetModelToken
Sets the token for one or more models.
Syntax
boolean AI_SetModelToken(text model_id, text model_token);
Parameters
Parameter | Description |
model_id | The custom name of an existing model. You can specify a single model or use a wildcard pattern for batch configuration. Example: _dashscope%. |
model_token | The token required for model requests. For example, the API key for Model Studio. |
Return values
Return value | Description |
t | The token was set successfully. |
f | The token failed to be set. |
Description
-
This function only modifies the token field in the model configuration (model_config).
NoteBefore using Polar_AI built-in models for the first time, call this function to bind the token in advance.
-
Use a wildcard pattern to batch-set model tokens. For example, '_dashscope%' sets the token for 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>'); -
Batch-set model tokens.
SELECT polar_ai.AI_SetModelToken('_dashscope%', '<YOUR_API_KEY>');