PAI-RAG offers a comprehensive set of API operations for features such as service management, knowledge base management, and chat. This topic describes the API operations and invocation methods for RAG services that are deployed using image versions v0.3.0 to v0.3.4.
Limits
This topic applies only to RAG services deployed with image versions v0.3.0 to v0.3.4.
Go to the Elastic Algorithm Service (EAS) page, click the name of the RAG service, and then view the image version in the Environment Information section on the Overview tab.
Get the service endpoint and token
Before you call a RAG service using an API operation, you must obtain the service endpoint and token:
Log on to the PAI console. Select a region on the top of the page. Then, select the desired workspace and click Elastic Algorithm Service (EAS).
Click the name of the destination service. In the Basic Information section, click View Invocation Information.
On the Invocation Information page, obtain the endpoint (EAS_SERVICE_URL) and token (EAS_Token).
ImportantRemove the forward slash (/) from the end of the EAS_SERVICE_URL.
Call the service using a public endpoint: The client must have internet access.
Call the service using a VPC endpoint: The client must be in the same virtual private cloud (VPC) as the RAG service.

Chat API
You can call the service using the OpenAI-compatible API operation. Before you call the service, you must configure the required features on the WebUI of the RAG service.
Supported features
web search: Searches the web. You must configure the web search parameters on the RAG service WebUI in advance.
chat knowledgebase: Queries a knowledge base. You must upload knowledge base files in advance.
chat llm: Uses a large language model (LLM) to provide answers. You must configure an LLM service in advance.
chat agent: Calls tools using the agent. You must configure the agent-related code on the RAG service WebUI in advance.
chat db: Queries a database or table. You must configure the data analytics settings on the RAG service WebUI in advance.
Calling method | |
URL |
|
Request method | POST |
Request headers |
|
HTTP body | Important
|
Knowledgebase API
Add a knowledge base
Calling method | |
URL |
|
Request method | POST |
Request headers |
|
Request parameters |
|
List knowledge bases
Calling method | |
URL |
|
Request method | GET |
Request headers | Authorization: EAS_TOKEN # The token for the EAS call |
Upload a knowledge base file
Calling method | |
URL |
|
Request method | POST |
Request headers |
|
Request parameters |
|
Get the upload status
Calling method | |
URL |
|
Request method | GET |
Request headers |
|
Request parameters |
|
Get the upload history
Calling method | |
URL |
|
Request method | GET |
Request headers |
|
Request parameters | name: The name of the knowledge base, such as my_milvus. |
List knowledge base files
Calling method | |
URL |
|
Request method | GET |
Request headers |
|
Request parameters | name: The name of the knowledge base, such as my_milvus. |
Delete a knowledge base file
Calling method | |
URL |
|
Request method | DELETE |
Request headers |
|
Request parameters |
|
Get information about a knowledge base
Calling method | |
URL |
|
Request method | GET |
Request headers |
|
Request parameters | name: The name of the knowledge base, such as my_milvus. |
Update a knowledge base
Calling method | |
URL |
|
Request method | PATCH |
Request headers |
|
Request parameters |
|
Delete a knowledge base
Calling method | |
URL | {EAS_SERVICE_URL}/api/v1/knowledgebases/{name} |
Request method | DELETE |
Request headers |
|
Request parameters | name: The name of the knowledge base, such as new_milvus. |
Retrieve from a knowledge base
v0.3.0-v0.3.3
Calling method | |
URL |
|
Request method | POST |
Request headers |
|
Request parameters |
|
v0.3.4
Calling method | |
URL |
|
Request method | POST |
Request headers |
|
Request parameters |
|
Other API operations
Get the RAG service configuration
Calling method | |
URL |
|
Request method | GET |
Request headers |
|
Update the RAG service configuration
Calling method | |
URL |
|
Request method | PATCH |
Request headers |
|
Load CHAT_DB information
Upload an Excel or CSV file for table content query in Chat_DB
Calling method | |
URL |
|
Request method | POST |
Request headers |
|
Request parameters | file: The Excel or CSV file. |
Upload a JSON file to supplement Chat_DB database information with Q&A pairs
Calling method | |
URL |
|
Request method | POST |
Request headers |
|
Request parameters |
|
Upload a CSV file to supplement Chat_DB database information with column descriptions
Calling method | |
URL |
|
Request method | POST |
Request headers |
|
Request parameters |
|
Load database information
Calling method | |
URL |
|
Request method | POST |
Request headers |
|