Skip to main content
RAG API

API Overview

Learn about the Knowledge Studio API's service endpoints, protocol conventions, request formats, and rate limiting rules.

The Knowledge Studio API enables programmatic management of knowledge bases, document ingestion, retrieval operations, and knowledge-based question-answering services. All APIs are served through the DashScope gateway.
Before calling the API, obtain your API Key.

Service Endpoint

{workspaceId} is the business workspace ID (e.g., llm-xxxxxxxxxxxx). You can view or create it on the console’s Workspace Management page. All APIs use the same base endpoint:
https://{workspaceId}.cn-beijing.maas.aliyuncs.com
The Knowledge Studio API comprises three groups of endpoints, each with a distinct path prefix:
API GroupPath PrefixDescription
Knowledge Base Management/api/v1/indices/CRUD operations for knowledge bases, document management, chunk management, and retrieval
Data Ingestion/api/v1/connector/dash/Category management, file uploads, and connector configuration
Knowledge Q&A/api/v2/apps/knowledge/Knowledge-based question-answering service (SSE streaming)
For example, the full URL for the retrieval API is:
https://llm-xxxxxxxxxxxx.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/index/retrieve

Protocol Conventions

  • All APIs are accessible only via HTTPS; HTTP is not supported.
  • Request and response bodies are in JSON format, using UTF-8 encoding.
  • Most APIs—including knowledge base management, document management, chunk management, retrieval, and data ingestion—use the POST method. A few read-only query APIs use GET, passing parameters via the query string. These include: listing knowledge bases, listing documents, and checking ingestion task status. Always refer to individual API documentation for the exact HTTP method and parameter location.

Common Request Headers

HeaderRequiredDescription
AuthorizationYesBearer <API-Key>. Obtain your key from the console API Key page. See Authentication for details.
Content-TypeYesFor POST requests: application/json.

Common Response Format

All APIs return responses in a consistent JSON structure. Successful Response:
{
  "code": "Success",
  "status_code": 200,
  "data": { },
  "success": true,
  "message": "success",
  "request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
Failed Response:
{
  "code": "Index.InvalidParameter",
  "status_code": 400,
  "message": "Required parameter(xxx) missing or invalid, please check the request parameters.",
  "request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
When troubleshooting, provide the request_id to help technical support quickly identify the issue. Full error codes are listed in the Error Code Reference.

Pagination

List APIs support pagination. However, pagination parameters vary across endpoints in terms of HTTP method, naming, and location. Pay close attention when calling:
Applicable APIMethodPage Number ParameterItems Per PageParameter Location
List Knowledge BasesGETpage_number (1-indexed)page_sizeQuery String
List DocumentsGETpage_numpage_sizeQuery String
List ChunksPOSTpage_numpage_sizeRequest Body
List File DetailsPOSTpageNumber (1-indexed)pageSizeRequest Body
For listing knowledge bases, pagination parameters must be passed in the query string (page_number, page_size) — note it's page_number, not page_num. If included in the request body, the server will ignore them and return results using default values.

Rate Limiting

Each API enforces request rate limits. Exceeding these limits returns HTTP status 429. Full rate-limiting rules are documented in the Rate Limits Guide.
Overview
Managed Agent API
Sandbox API
Memory API
Flow Agent API
RAG API
Connector API
Framework Integration
Assistant API (Deprecating)
  • Overview