All Products
Search
Document Center

PolarDB:AI_AlterModel

Last Updated:Mar 28, 2026

Modifies the configuration of a registered AI model in the polar_ai schema.

Syntax

boolean AI_AlterModel(text model_id, text model_url, text model_provider, text model_type, text model_name, text model_config, regprocedure model_headers_fn, regprocedure model_in_transform_fn, regprocedure model_out_transform_fn);

Parameters

ParameterDescription
model_idThe unique identifier of the AI model to update. Required. The value must differ from model_name and cannot start with an underscore (_). Built-in models created by the Polar_AI extension use the underscore prefix. To list all registered models, run SELECT * FROM polar_ai._ai_models;.
model_urlThe endpoint URL of the AI model. Supported protocols: HTTP, HTTPS, and FILE. Cannot be NULL if specified. For example, use the endpoint from the call information of a model deployed on Platform for AI (PAI).
model_providerThe provider of the AI model. Examples: AWS, Alibaba, Baidu, Tencent. Accepts NULL.
model_typeThe type of the AI model. Examples: LSTM, GRU. Accepts NULL.
model_nameThe name of the AI model. Example: text-embedding-v2. Cannot be NULL if specified.
model_configThe model authentication configuration in JSON format. Cannot be NULL if specified. Format: { "author_type": "token", "token": "<YOUR_API_KEY>" }. Both author_type and token fields are required. Only token-based authentication is supported. API keys are encrypted at rest. For example, use the token from the call information of a model deployed on PAI.
model_headers_fnThe function that constructs custom request headers. Returns JSONB. Default: NULL. Omit this parameter if the model has no special header requirements.
model_in_transform_fnThe function that converts input data to the format expected by the AI model. Cannot be NULL if specified.
model_out_transform_fnThe function that parses the raw output returned by the AI model. Cannot be NULL if specified.

Return values

ValueDescription
tThe update succeeded.
fThe update failed.

Usage notes

  • Only model_id is required. All other parameters are optional. Parameters set to NULL are ignored — the corresponding fields in the model configuration remain unchanged.

  • If you specify model_url and model_config, the values must be accurate and not NULL. Passing NULL for either parameter prevents the model from being called.

Examples

Update the model URL:

SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_url=>'http://....');

Update the model provider:

SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_provider=>'Alibaba');

Update the model type:

SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_type=>'GRU');

Update the model name:

SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_name=>'text-embedding-v3');

Update the API key:

SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_config=>'{"token": "your-new-api-key", "author_type": "token"}');

The following example returns f because the model_config parameter is set to NULL, which causes the model to fail to be called:

SELECT polar_ai.AI_AlterModel('my_text_embedding_model', model_config=>NULL);
---
f