Skip to main content

Create an Agent

Create a new RAG Agent in draft status

POST
/api/v1/indices/rag/app/create
cURL
curl -X POST "https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/app/create" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_name": "客服知识问答助手",
    "agent_desc": "基于产品文档的智能客服问答 Agent",
    "agent_scene": "chat",
    "agent_config": {
        "agent_policy": "agentic",
        "agent_model": "qwen3.7-plus",
        "enable_session_file": "false",
        "enable_refusal": "true",
        "enable_anti_leak": "false",
        "enable_rich_text": "false",
        "enable_citation": "true",
        "temperature": 0.5,
        "kb_search_configs": [
            {
                "id": "pipeline-xxxxxx",
                "weight": 1,
                "credibility_level": "high",
                "dense_similarity_top_k": 10,
                "rerank_top_n": 5,
                "rerank_min_score": 0.3,
                "rerank": {
                    "model_name": "gte-rerank-hybrid",
                    "rerank_mode": "qa"
                }
            }
        ]
    }
}'
{
  "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "status_code": 200,
  "code": "Success",
  "message": "",
  "status": "SUCCESS",
  "success": true,
  "data": {
    "agent_id": "aid-8f3a1b2c4d5e6f70",
    "agent_name": "客服知识问答助手",
    "agent_version": "beta",
    "agent_status": "draft"
  }
}
Creates a new RAG Agent with initial status draft and version beta.
Creating an Agent requires the “Knowledge Base — Create” permission.

agent_config Structure

The fields included in agent_config depend on the value of agent_scene:
  • Chat scenario: 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 scenario: agent_policy, enable_kb_router, kb_router_model, rerank_top_n, kb_search_configs, hybrid_rerank
Fields within each kb_search_configs[] element: 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 populated by the system from the knowledge base; any values provided in the request will be ignored and overwritten.

Authorizations

string
header
required

DashScope API Key,在控制台 API Key 页面 获取。

Body

application/json
string
required

Agent 名称,最长 200 字符,同租户同场景下唯一。

length <= 200
enum<string>
required

Agent 场景:chat(知识问答)或 search(知识检索)。

chat,search
string

Agent 描述,最长 1000 字符。

length <= 1000
object

Agent 配置对象,不传则使用默认配置。

Response

200-application/json
string

请求唯一标识,排查问题时请提供此 ID。

integer

HTTP 状态码。

string

响应码,成功时为 Success。

string

提示信息。

enum<string>

请求状态:SUCCESS 或 FAILED。

SUCCESS,FAILED
boolean

请求是否成功。

object