Retrieval-Augmented Generation (RAG) of Platform for AI (PAI) provides various APIs for features, such as service management and chat. This topic describes the APIs and calling methods supported by RAG services deployed by using images with the versions earlier than v0.3.0.
Limits
This document is applicable only to RAG services deployed by using images with the versions earlier than v0.3.0.
To view the image version, perform the following operations: On the Elastic Algorithm Service (EAS) page, click the name of the desired RAG service. In the Environment Information section of the Overview tab, view the image version.

Obtain the access address and token of the service
Before you call a RAG service by using an API, obtain the access address and token of the service.
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 desired service. In the Basic Information section of the Overview tab, click View Endpoint Information.
On the Shared Gateway tab of the Invocation Method dialog box, obtain the service access address (EAS_SERVICE_URL) and token (EAS_Token).
ImportantRemove the forward slash (/) from the end of EAS_SERVICE_URL.
To call the service by using a public endpoint, the client that you use must support access over the Internet.
To call the service by using a VPC endpoint, the client that you use must be in the same virtual private cloud (VPC) as the service.

Chat API
Call the service by using the OpenAI API that is compatible with the service. Before calling the service, you need to complete the corresponding configurations on the WebUI page of the RAG service based on your business requirements.
Supported features
Web search: You need to configure web search parameters.
Knowledge base query: You need to upload knowledge base files.
LLM chat: Use large language model (LLM) services to provide answers. You need to configure LLM services.
Agent chat: You need to complete agent-related code configurations on the WebUI page of the RAG service.
Database or table query: You need to complete chat_db-related parameters on the WebUI page of the RAG service.
Method | |
URL |
|
Request method | POST |
Request header |
|
HTTP body | Important
|
Management API
Upload knowledge base files
Method | |
URL |
|
Request method | POST |
Request header |
|
Request parameter |
|
Query the upload status
Method | |
URL |
|
Request method | GET |
Request header |
|
Query a knowledge base
Method | |
URL |
|
Request method | POST |
Request header |
|
Request parameter |
|
Upload EXCEL or CSV files to query chat_db tables
Method | |
URL |
|
Request method | POST |
Request header |
|
Request parameter | The EXCEL or CSV file. |
Upload JSON files to supplement chat_db database information - Q&A pairs
Method | |
URL |
|
Request method | POST |
Request header |
|
Request parameter |
|
Load database information
Method | |
URL |
|
Request method | POST |
Request header |
|
Query all knowledge base indexes
Method | |
URL |
|
Request method | GET |
Request header |
|
Create a knowledge base index
Method | |
URL |
|
Request method | POST |
Request header |
|
Request parameter |
|
Update a knowledge base index
Method | |
URL |
|
Request method | PATCH |
Request header |
|
Request parameter |
|
Delete a knowledge base index
Method | |
URL |
|
Request method | DELETE |
Request header |
|
Request parameter | index_name: the index name. |
Query the configurations of a RAG service
Method | |
URL |
|
Request method | GET |
Request header |
|
Update the configurations of a RAG service
Method | |
URL |
|
Request method | PATCH |
Request header |
|
Request parameter | new_config: the updated configuration. |