Create a new RAG Agent with initial status draft and version beta.
Prerequisites
Obtain an Alibaba Cloud Model Studio API Key and workspace ID first. For authentication, see API Authentication. Creating an Agent requires the Knowledge Base - Create permission, which is determined by the user's role in Workspace Member Management. See Permissions.
Endpoint
POST /api/v1/indices/rag/app/create
Create a new RAG Agent. An Agent is the encapsulated entity of the knowledge Q&A / retrieval capability, containing model configuration, retrieval strategy, security policy, and more. After creation, the Agent is in the draft state with version number beta. You can modify the configuration via the Update Agent API and publish it via the Deploy Agent API. The agent_name must be unique within the same tenant and scene.
agent_config structure
The field composition of agent_config depends on the value of agent_scene:
- chat scene:
agent_policy,agent_model,enable_session_file,enable_refusal,enable_anti_leak,enable_rich_text,enable_citation,temperature,max_num_llm_calls,max_completion_tokens,session_file_max_parse_length,kb_search_configs - search scene:
agent_policy,enable_kb_router,kb_router_model,rerank_top_n,kb_search_configs,hybrid_rerank
kb_search_configs[] element fields: id, weight, credibility_level, dense_similarity_top_k, sparse_similarity_top_k, rerank_top_n, rerank_min_score, rerank, search_filters
Fields such as
name, desc, and knowledge_type are automatically filled by the system from the knowledge base; values passed in are ignored and overwritten.Request body
| Field | Required | Type | Description |
|---|---|---|---|
agent_name | Yes | string | Agent name, up to 200 characters, must be unique within the same tenant and scene. |
agent_desc | No | string | Agent description, up to 1000 characters. |
agent_scene | Yes | string | Agent scene: chat (knowledge Q&A) or search (knowledge retrieval). |
agent_config | No | object | Agent configuration. If not provided, default configuration is used. See the sub-field table below. |
| Field | Required | Type | Description |
|---|---|---|---|
agent_model | No | string | Model name used by the agent, e.g. qwen3.7-plus, qwen3.6-plus. |
agent_policy | No | string | Agent policy, e.g. agentic. |
enable_anti_leak | No | string | Whether to enable the anti-leak feature, true or false. |
enable_citation | No | string | Whether to enable citation annotations, true or false. |
enable_kb_router | No | string | Whether to enable knowledge base routing (search scene). true or false. |
enable_refusal | No | string | Whether to enable the refusal feature, true or false. |
enable_rich_text | No | string | Whether to enable rich text output, true or false. |
enable_session_file | No | string | Whether to enable the session file feature, true or false. |
hybrid_rerank | No | object | Global fusion rerank config (search scene). See the sub-field table below. |
kb_router_model | No | string | Router model name. Required when enable_kb_router is true. Must be in the platform whitelist. |
kb_search_configs | No | array<object> | List of knowledge base retrieval configurations. See the element table below. |
max_completion_tokens | No | integer | Maximum generation tokens. Must be >= 1. |
max_num_llm_calls | No | integer | Maximum number of LLM calls for the agent. |
rerank_top_n | No | integer | Fusion rerank Top N (search scene). Range [1, 20]. |
session_file_max_parse_length | No | integer | Maximum parsing length for session files. Must be less than the model's max_context_length. |
temperature | No | number | Model sampling temperature, range [0, 2]. |
user_system_prompt | No | string | Custom system prompt for the chat scene. Place it at the top level of agent_config; it is passed through without validation, and its length and effect are determined by the downstream runtime. Note the field name is user_system_prompt, not system_prompt. |
| Field | Required | Type | Description |
|---|---|---|---|
credibility_level | No | string | Knowledge base credibility level, e.g. high, medium, low. |
dense_similarity_top_k | No | integer | Top-K quantity returned by dense retrieval. |
id | No | string | Associated knowledge base Pipeline ID. |
rerank | No | object | Reranking configuration. See the sub-field table below. |
rerank_min_score | No | number | Minimum rerank score threshold. Chunks with a score below this value are filtered out. |
rerank_top_n | No | integer | Top-N quantity retained after reranking. |
search_filters | No | array | Retrieval filter conditions, validated against the knowledge base schema. |
sparse_similarity_top_k | No | integer | Sparse retrieval Top K. Range [1, 100]. |
weight | No | number | Knowledge base weight. |
| Field | Required | Type | Description |
|---|---|---|---|
model_name | No | string | Reranking model name, e.g. gte-rerank-hybrid. |
rerank_instruct | No | string | Custom rerank instruction, only effective when rerank_mode is custom. Max 500 characters. |
rerank_mode | No | string | Rerank mode: qa (question answering), similar (similarity), or custom (custom instruction). rerank_instruct is automatically cleared when not in custom mode. |
| Field | Required | Type | Description |
|---|---|---|---|
model_name | No | string | Fusion rerank model code. For VL knowledge bases, only multimodal models are supported; otherwise all rerank models are supported. |
rerank_mode | No | string | Fusion rerank mode: qa, similar, or custom. rerank_instruct is automatically cleared when not in custom mode. |
rerank_instruct | No | string | Custom fusion rerank instruction, only effective when rerank_mode is custom. Max 500 characters. |
Request example
BASE_URL is https://{workspace_id}.cn-beijing.maas.aliyuncs.com ({workspace_id} is the workspace ID), and BAILIAN_API_KEY is your Alibaba Cloud Model Studio API Key.
Response example
Returns 200 on success.
Response fields
| Field | Type | Description |
|---|---|---|
request_id | string | Unique request identifier. Provide this ID when troubleshooting issues. |
status_code | integer | HTTP status code. |
code | string | Response code. Success on success. |
message | string | Informational message. |
status | string | Request status: SUCCESS or FAILED. |
success | boolean | Whether the request succeeded. |
data.agent_id | string | ID of the created Agent. |
data.agent_name | string | Agent name. |
data.agent_version | string | Agent version number. beta for newly created agents. |
data.agent_status | string | Agent status. draft for newly created agents. |
Error codes
| HTTP status code | Error code | Description |
|---|---|---|
| 400 | Index.InvalidParameter | Invalid request parameters. Please check that all parameters are complete and correctly typed. |