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);

Usage notes

  • model_id is required. All other parameters are optional.

  • Parameters set to NULL are ignored — the function leaves the corresponding field unchanged.

  • If you update model_url and model_config, provide accurate, non-NULL values. A NULL value for either parameter causes the AI model to fail to be called.

Parameters

ParameterDescription
model_idThe unique identifier of the AI model. Must differ from model_name. Cannot start with an underscore (_). Built-in models created by the Polar_AI extension use identifiers that start with _. To view the AI models, run SELECT * FROM polar_ai._ai_models;.
model_urlThe URL used to access the AI model. Cannot be NULL. Supported protocols: HTTP, HTTPS, and FILE. 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. Can be NULL. Examples: AWS, Alibaba, Baidu, Tencent.
model_typeThe type of the AI model. Can be NULL. Examples: LSTM, GRU.
model_nameThe name of the AI model. Cannot be NULL. Example: text-embedding-v2.
model_configThe model configuration in JSON format. Cannot be NULL. Format: {"author_type": "token", "token": "<YOUR_API_KEY>"}. The author_type field specifies the authentication type; only token-based authentication is supported. The token field is the API key used to invoke the model. 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 used to construct request headers. Returns JSONB. Set to NULL if the model has no special header requirements. Default value: NULL.
model_in_transform_fnThe function used to convert input data to the format expected by the model. Cannot be NULL.
model_out_transform_fnThe function used to parse and transform the output returned by the model. Cannot be NULL.

Return values

ValueDescription
tThe modification succeeded.
fThe modification failed.

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 in the model configuration:

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

In the following example, the AI model fails to be called because the model_config parameter is set to NULL:

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