Skip to main content

Create Agent

Create a new Knowledge Agent with initial status draft

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": "Customer Service Q&A Assistant",
    "agent_desc": "Intelligent customer service Q&A agent based on product documentation",
    "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": "Customer Service Q&A Assistant",
    "agent_version": "beta",
    "agent_status": "draft"
  }
}
Create a new Knowledge Agent with initial status draft and version beta.
Creating an Agent requires Knowledge Base - Create permission.
When creating a search service, explicitly provide a complete retrieval configuration in agent_config.kb_search_configs[], including rerank_min_score, rerank_top_n, dense_similarity_top_k, and sparse_similarity_top_k. If these parameters are missing, creation and deployment may succeed, but calls to the service fail with errors such as rerank_min_score is required or dense_similarity_top_k missing or invalid.

agent_config structure

The field composition of agent_config depends on the value of agent_scene:
  • Chat: 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: 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 auto-filled by the system from the Knowledge Base and will be overridden even if passed in.

Authorizations

string
header
required

DashScope API Key, obtained from the API Key page in the console.

Body

application/json
string
required

Agent name, up to 200 characters, must be unique within the same tenant and scene.

length <= 200
enum<string>
required

Agent scene: chat (knowledge Q&A) or search (knowledge retrieval).

chat,search
string

Agent description, up to 1000 characters.

length <= 1000
object

Agent configuration object. If not provided, default configuration is used.

Response

200-application/json
string

Unique request identifier. Provide this ID when troubleshooting issues.

integer

HTTP status code.

string

Response code. Success on success.

string

Informational message.

enum<string>

Request status: SUCCESS or FAILED.

SUCCESS,FAILED
boolean

Whether the request succeeded.

object