Skip to main content

Overview

Endpoints, protocol, request format, endpoint catalog, and rate limits for the RAG API.

The RAG API lets you manage Knowledge Bases, import documents, run retrievals, and call the Knowledge Q&A service programmatically. Every endpoint is served through the DashScope gateway.
Before calling the API, create an API key.

Endpoint

{workspace_id} is the Workspace ID (e.g., llm-xxxxxxxxxxxx). View or create workspaces on the Workspace Management page. All endpoints share the same base URL:
https://{workspace_id}.cn-beijing.maas.aliyuncs.com
The RAG API has three endpoint groups with different path prefixes:
GroupPath prefixPurpose
Knowledge Base management/api/v1/indices/CRUD on Knowledge Bases, document and chunk management, retrieval
Data import/api/v1/connector/dash/Categories, file upload, connector configuration
Knowledge Q&A/api/v2/apps/knowledge/Knowledge Q&A service (SSE streaming)
For example, the full URL for the retrieve endpoint is:
https://llm-xxxxxxxxxxxx.cn-beijing.maas.aliyuncs.com/api/v1/indices/rag/index/retrieve

Protocol

  • All endpoints use HTTPS. HTTP is not supported.
  • Request and response bodies are JSON encoded as UTF-8.
  • Knowledge Base management, document/chunk management, retrieval, and data-import endpoints all use POST. A few query endpoints use GET and pass parameters via query string: List Knowledge Bases, List Documents, and Get Import Job Status. Refer to each endpoint page for its actual method and parameter location.

Common request headers

HeaderRequiredDescription
AuthorizationYesBearer <API-Key> — create one on the console API Key page. See Authentication.
Content-TypeYesapplication/json for POST requests.

Common response format

Every endpoint returns the same JSON envelope. Success:
{
  "code": "Success",
  "status_code": 200,
  "data": { },
  "success": true,
  "message": "success",
  "request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
Failure:
{
  "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 you report a problem, include the request_id so support can find the request quickly. The full error catalog is in Errors.

Pagination

List endpoints support pagination. The HTTP method, parameter names, and where parameters live differ across endpoints — check carefully:
EndpointMethodPage parameterPage sizeWhere
List Knowledge BasesGETpage_number (starts at 1)page_sizeQuery string
List DocumentsGETpage_numpage_sizeQuery string
List ChunksPOSTpage_numpage_sizeRequest body
List Document DetailsPOSTpageNumber (starts at 1)pageSizeRequest body
List Knowledge Bases takes pagination via query string (page_number, page_size — note page_number, not page_num). Sent in the request body, the server ignores them and returns the default page size.

Endpoint catalog

Knowledge Base

EndpointDescription
Create Knowledge Base and ImportCreate a Knowledge Base and import files in a single call.
List Knowledge BasesPaginate through every Knowledge Base in the current workspace.
Update Knowledge BaseUpdate the description of a Knowledge Base.
Delete Knowledge BasePermanently delete a Knowledge Base along with all of its documents and chunks.
Get Knowledge Base MonitoringGet storage usage and QPS metrics for a Knowledge Base.

Document Management

EndpointDescription
List DocumentsList the documents in a Knowledge Base.
List Document DetailsGet detailed document information, including chunk count and parsing status.
Delete DocumentDelete a document and all of its chunks from a Knowledge Base.

Chunk Management

EndpointDescription
Add ChunkAdd a chunk to a specified knowledge base.
List ChunksPaginate through the chunks in a Knowledge Base.
Update ChunkUpdate the content of a single chunk.
Delete ChunksDelete chunks in batch — up to 10 per call.

Sync Jobs

EndpointDescription
Submit Import JobAppend documents to an existing Knowledge Base.
Get Job StatusCheck the status of a Knowledge Base import job.

Data Import

EndpointDescription
List CategoriesList categories under the current workspace. Filter by type or name.
Create CategoryCreate a new category under the current workspace.
Delete CategoryDelete a category.
List FilesList files under the current workspace. Filter by category, file name, or file ID.
Describe FileGet a file's metadata, including size, MD5, tags, and timestamps.
Delete FilePermanently delete a file.
Batch Update File TagsUpdate tags on multiple files in one call. Supports overwrite and append modes.
Request Upload LeaseFirst step in uploading a file to the data center. Returns an OSS presigned URL and a lease ID.
Register FileFinal step of the upload flow — register an OSS-uploaded file with the data center.
Import from OSSBatch-import files from an authorized Alibaba Cloud OSS bucket into the data center.
Create ConnectorCreate a new Data Connector that manages where imported files come from.
Get ConnectorGet the details of a connector.

Knowledge Retrieval & QA

EndpointDescription
Knowledge SearchRun a joined semantic search across multiple Knowledge Bases.
Knowledge ChatSSE-based Streaming Q&A grounded in your Knowledge Bases.

Agent Management

EndpointDescription
Agent Management OverviewFull lifecycle management APIs for RAG Agent instances.
Create AgentCreate a new RAG Agent with initial status draft.
Update AgentUpdate the Agent name, description, or draft config.
Deploy AgentPublish the beta draft as a new version.
Delete AgentSoft delete an Agent, marking status as deleted.
List AgentsPaginated query of Agents under the current tenant.
Get AgentGet full Agent details, supports specifying a version.
Copy AgentCopy an existing Agent to generate a new draft.

Rate limits

Each endpoint has a request rate limit. Going over returns HTTP 429. See Rate Limits for the full table.
Managed Agent API
Flow Agent API
Sandbox API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration