All Products
Search
Document Center

AnalyticDB:CREATE MODEL

Last Updated:Mar 28, 2026

CREATE MODEL registers an AI model in AnalyticDB for MySQL so you can call it directly in SQL queries. Use this statement to connect either the built-in inference platform or an external model service such as Alibaba Cloud Model Studio.

Syntax

CREATE MODEL model_name
OPTIONS(
  type     = 'internal|external',
  name     = 'connected_model_name',
  provider = 'provider_name'
  [, interface        = 'interface_str']   -- optional; default: TEXT_TO_TEXT
  [, api_key          = 'sk-xxx']          -- required when type = 'external'
  [, endpoint         = 'endpoint_url']    -- required when type = 'external'
  [, model_properties = ...]               -- optional; Qwen series only
)

Parameters

ParameterRequiredDescription
model_nameYesThe name you assign to the model in AnalyticDB for MySQL.
nameYesThe model name on the model service side. For example, qwen-max or qwen-plus for Alibaba Cloud Model Studio.
typeYesThe model service type. Set to internal to use the built-in inference platform of AnalyticDB for MySQL, or external to connect an external model service.
providerYesThe model service provider. ADB_MODEL_SERVER for the built-in inference platform, or BAILIAN for Alibaba Cloud Model Studio.
interfaceNoThe modality type. This parameter helps distinguish multimodal model services. Omit this parameter to use the default TEXT_TO_TEXT. Separate multiple values with commas.
api_keyNoThe API key for the external model service. Required when type = 'external'.
endpointNoThe endpoint URL of the external model service. Required when type = 'external'.
model_propertiesNoHyperparameters that control model output. Currently limited to Alibaba Cloud Model Studio Qwen series models.

Interface types

The interface parameter accepts the following values:

ValueDescription
TEXT_TO_TEXTText generation model (default)
TEXT_TO_EMBEDDINGText embedding model
IMAGE_TO_TEXTImage-to-text model
IMAGE_TO_EMBEDDINGImage embedding model
AUDIO_TO_TEXTSpeech-to-text model
AUDIO_TO_EMBEDDINGSpeech embedding model

Model parameters

The model_properties parameter accepts the following hyperparameters. Currently limited to Alibaba Cloud Model Studio Qwen series models.

ParameterTypeDescription
top_kintSamples from the top K most probable tokens. Lower values narrow the token pool and make output more deterministic.
top_pdoubleNucleus sampling threshold. Selects the smallest set of tokens whose cumulative probability reaches top_p. Lower values focus the output more tightly.
enable_searchbooleanEnables web search to retrieve up-to-date or external information.
seedintRandom seed for generation. Identical seeds produce identical outputs when all other parameters remain unchanged.
temperaturefloatControls output randomness. Higher values increase diversity; lower values make the output more deterministic. Range: 0.0–2.0.
max_tokensintMaximum number of tokens to generate. Applies to output length only, not input.

Examples

Register an external model

Connect a Qwen model from Alibaba Cloud Model Studio. Before running this statement, configure the network to allow outbound access to the external service.

CREATE MODEL my_qwen_model
OPTIONS(
  type     = 'external',
  name     = 'qwen-plus',
  provider = 'BAILIAN',
  api_key  = '<your-api-key>',
  endpoint = '<your-endpoint-url>'
)

Replace the placeholders with your actual values:

PlaceholderDescription
<your-api-key>Your model access key from Alibaba Cloud Model Studio
<your-endpoint-url>The model service endpoint for your selected model