Updated on 2025-08-13 GMT+08:00

Creating a Model

Function

The API is used to create a model. The configuration includes the model name, description, endpoint, and relevant settings.

**Note: When using a third-party LLM, it is your responsibility to ensure that the model output is secure and compliant. **

There is a strong connection between the embedding model and the cache generation model. When an embedding model is created, the system automatically generates a cache generation model. If any configuration information is deleted by mistake, the model must be rebuilt using the same configuration parameters. For example, if the name of the embedding model is pangu_embedding, the name of the matching cache generation model is pangu_embedding_faq.

When creating a knowledge base, both the embedding model (pangu_embedding) and cache generation model (pangu_embedding_faq) are required. If the cache generation model (pangu_embedding_faq) does not exist or is not accessible, an error is returned. In this case, the administrator needs to check whether the pangu_embedding_faq model exists or whether the knowledge base user has access to it. If the model is missing, create it. If the knowledge base user does not have access to it, grant them the access permission.

URI

POST /v1/{project_id}/applications/{application_id}/uni-search/models

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition:

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Constraints:

N/A

Value range:

The value can contain 1 to 64 characters. Only digits, letters, hyphens (-), and underscores (_) are allowed. The value must start with a letter.

Default value:

N/A

application_id

Yes

String

Definition:

Application ID. For details about how to obtain the application ID, see Obtaining an Application ID.

Constraints:

Character string

Value range:

The value can contain 1 to 64 characters. Only digits, letters, hyphens (-), and underscores (_) are allowed. The value must start with a letter.

Default value:

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition:

Token used for API authentication. For details about how to obtain the token, see Obtaining an IAM User Token.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Definition:

Model name.

Constraints:

The length for the embedding model is 28 characters, and 32 characters for other models.

Value range:

The value contains 1 to 32 characters. It can only contain letters, digits, underscores (_), and hyphens (-), and must start with a letter or digit.

Default value:

N/A

alias

No

String

Definition:

Model name required for the Ascend model scenario.

Constraints:

N/A

Value range:

The value cannot be empty. It can contain 1 to 32 characters. It can only contain letters, digits, periods (.), hyphens (-), colons (:), and slashes (/), and must start with a letter or digit.

Default value:

N/A

detail

Yes

String

Definition:

Model details.

Constraints:

N/A

Value range:

This parameter cannot be left blank. The value can contain 1 to 512 characters and can contain any characters.

Default value:

N/A

endpoint

Yes

String

Definition:

Model endpoint.

Constraints:

N/A

Value range:

The value cannot be empty. It can contain 1 to 512 characters, including any characters.

Default value:

N/A

type

Yes

String

Definition:

Model type.

Constraints:

N/A

Value range:

  • Pangu_chat Pangu chat model

  • pangu_llm Pangu model deployed on bare metal

  • embedding Embedding model

  • query2query query2query model

  • rerank Reranking model

  • search_plan Search planning model

  • llm LLM

  • ai_engine Enhance web search service

  • search_engine Search engine

  • mllm: multimodal model

Default value:

N/A

extend_config

Yes

ModelExtendConfig object

Definition:

User-defined model configuration, in JSON format.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

project_id

No

String

Definition:

Project ID.

Constraints:

N/A

Value range:

Optional. The value must be a string of 1 to 64 characters. It can only contain letters, digits, underscores (_), and hyphens (-).

Default value:

N/A

Table 4 ModelExtendConfig

Parameter

Mandatory

Type

Description

iam_info

Yes

IamInfo object

Definition:

IAM authentication agency information

Constraints:

N/A

Value range:

N/A

Default value:

N/A

custom_header

No

map<string, object>

Definition:

Extended request header.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

deployment_id

No

String

Definition:

Model deployment ID.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

vector_config

No

VectorConfig object

Definition:

Vector model configuration.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

nlp_config

No

NlpConfig object

Definition:

Configuration of the NLP foundation model.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

guard_enabled

No

Boolean

Definition:

Whether to enable moderation.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

query_key

No

String

Definition:

Key value of the query request body.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

custom_param

No

Map<String,String>

Definition:

Request parameter.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

custom_enabled

No

Boolean

Definition:

Custom field.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

custom_json_parse

No

Map<String,String>

Definition:

Result parsing.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

proxy_enabled

No

Boolean

Definition:

Whether to enable the proxy. This parameter is enabled when the web search engine is configured.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

time_detect_enabled

No

Boolean

Definition:

Whether to enable periodic detection. This parameter is enabled when the web search engine is configured.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

agree_disclaimer

No

String

Definition:

If the disclaimer has been agreed, AGREE is sent. By default, this parameter is left empty.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

Table 5 IamInfo

Parameter

Mandatory

Type

Description

iam_enabled

No

Boolean

Definition:

Indicates whether to enable authentication.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

agency_enabled

No

Boolean

Definition:

Indicates whether to use an agency account for authentication

Constraints:

N/A

Value range:

N/A

Default value:

N/A

project_id

No

String

Definition:

Project ID of the IAM user. This parameter is mandatory when iam_enable is set to true.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

domain_name

No

String

Definition:

Name of the agency account.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

agency_name

No

String

Definition:

Agency name.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

Table 6 VectorConfig

Parameter

Mandatory

Type

Description

embedding_url

Yes

String

Definition:

URL for calling the embedding or query2query model.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

rerank_url

No

String

Definition:

URL for calling the reranking model.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

Table 7 NlpConfig

Parameter

Mandatory

Type

Description

context_length

Yes

Integer

Definition:

Context length, that is, the maximum number of tokens that can be considered by the NLP foundation model during a specific inference.

Constraints:

N/A

Value range:

N/A

Default value:

N/A

Response Parameters

Status code: 200

Added successfully.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error Code.

Value range:

N/A

error_msg

String

Definition:

Error message.

Value range:

N/A

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error Code.

Value range:

N/A

error_msg

String

Definition:

Error message.

Value range:

N/A

Example Requests

Add a model.

/v1/b25446daeb1a41a7953c5deba2b2677a/applications/cefb2a59-2f9e-4268-b56b-eab15dc0b9d6/uni-search/models

{
  "name" : "25-test-enbedding",
  "type" : "embedding",
  "endpoint" : "https://xxxxxx",
  "detail" : "test",
  "extend_config" : {
    "iam_info" : {
      "iam_enabled" : false,
      "agency_enabled" : false
    },
    "vector_config" : {
      "embedding_url" : "/app/search/v1/vector"
    },
    "time_detect_enabled" : true,
    "custom_enabled" : true,
    "custom_header" : { }
  }
}

Example Responses

None

Status Codes

Status Code

Description

200

Added successfully.

400

Incorrect request body.

500

Internal error.

Error Codes

See Error Codes.