All Products
Search
Document Center

:Applicable to image versions v0.3.0 to v0.3.4

Last Updated:Sep 30, 2025

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.image

Get the service endpoint and token

Before you call a RAG service using an API operation, you must obtain the service endpoint and token:

  1. 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).

  2. Click the name of the destination service. In the Basic Information section, click View Invocation Information.

  3. On the Invocation Information page, obtain the endpoint (EAS_SERVICE_URL) and token (EAS_Token).

    Important
    • Remove 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.

    image

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

{EAS_SERVICE_URL}/v1/chat/completions

Request method

POST

Request headers

Authorization: EAS_TOKEN (The token for the EAS call)

HTTP body

{
    "model": "default",  # The model name. Set this to default or a model name that is configured on the WebUI. 
    "messages": [
        {"role": "user", "content": "Hello"},
        {"role": "assistant", "content": "Hello, how can I help you?"},
        {"role": "user", "content": "What is the capital of Zhejiang?"},
        {"role": "assistant", "content": "Hangzhou is the capital of Zhejiang."},
        {"role": "user", "content": "What are some fun places to visit?"},
    ],
    "stream": true,  # Specifies whether to enable streaming output.
    "chat_knowledgebase": true,  # Specifies whether to query the local knowledge base.
    "search_web": false,  # Specifies whether to use web search.
    "chat_llm": false,  # Specifies whether to use only the LLM for chat.
    "chat_agent": false,  # Specifies whether to use the agent.
    "chat_db": false,  # Specifies whether to query the database.
    "index_name": "default",  # The index name for RAG scenarios. You can specify only one index name. If you do not specify an index name, the system uses the default index.
    "max_tokens": 1024,  # The maximum output length, such as 1024.
    "temperature": 0.1,  # Controls the randomness of the generated content. The value must be in the range of [0, 1]. A smaller value indicates more deterministic content. A larger value indicates more diverse content.
}
Important
  • If you enable multiple features at the same time, the system calls them based on the following priority, from highest to lowest: search_web, chat_knowledgebase, chat_agent, chat_db, and chat_llm. For each feature, the system performs intent recognition to determine whether to call the feature or directly use the LLM to generate a response.

  • If all feature flags are set to false or are not passed, the service queries the local knowledge base by default (that is, "chat_knowledgebase": true).

Request example (click to view details)

Web search

from openai import OpenAI

##### API configuration #####

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
openai_api_key = "<EAS_TOKEN>"
openai_api_base = "<EAS_SERVICE_URL>/v1"
client = OpenAI(
    api_key=openai_api_key,
    base_url=openai_api_base,
)


#### Chat ######
def chat():
    stream = True
    chat_completion = client.chat.completions.create(
        model="default",
        stream=stream,
        messages=[
            {"role": "user", "content": "Hello"},
            {"role": "assistant", "content": "Hello, how can I help you?"},
            {"role": "user", "content": "What is the capital of Zhejiang?"},
            {"role": "assistant", "content": "Hangzhou is the capital of Zhejiang."},
            {"role": "user", "content": "What are some fun places to visit?"},
        ],
        extra_body={
            "search_web": True,
        },
    )

    if stream:
        for chunk in chat_completion:
            print(chunk.choices[0].delta.content, end="")
    else:
        result = chat_completion.choices[0].message.content
        print(result)


chat()

Query a database

from openai import OpenAI

##### API configuration #####
# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.

openai_api_key = "<EAS_TOKEN>"
openai_api_base = "<EAS_SERVICE_URL>/v1"
client = OpenAI(
    api_key=openai_api_key,
    base_url=openai_api_base,
)


#### Chat ####
def chat():
    stream = True
    chat_completion = client.chat.completions.create(
        model="default",
        stream=stream,
        messages=[
            {"role": "user", "content": "How many cats are there?"},
            {"role": "assistant", "content": "There are 2 cats."},
            {"role": "user", "content": "And dogs?"},
        ],
        extra_body={
            "chat_db": True,
        },
    )

    if stream:
        for chunk in chat_completion:
            print(chunk.choices[0].delta.content, end="")
    else:
        result = chat_completion.choices[0].message.content
        print(result)


chat()

Knowledgebase API

Add a knowledge base

Calling method

URL

{EAS_SERVICE_URL}/api/v1/knowledgebases/{name}

Request method

POST

Request headers

  • Authorization: EAS_TOKEN

  • Content-Type: application/json

Request parameters

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Replace <name> with the name of your knowledge base. Update vector_store_config to your vector database configuration. 
 
curl -X 'POST' <EAS_SERVICE_URL>/api/v1/knowledgebases/<name> \
-H 'Authorization: <EAS_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
      "name":"<name>",
      "vector_store_config":
      {
          "persist_path":"./localdata/knowledgebase/default/.index/.faiss",
          "type":"milvus",
          "is_image_store":false,
          "host":"c-exxx11f4c.milvus.aliyuncs.com",
          "port":19530,
          "user":"root",
          "password":"xxx",
          "database":"default",
          "collection_name":"test",
          "reranker_weights":[0.5,0.5]
      },
      "embedding_config":
      {
          "source":"huggingface",
          "model":"bge-m3",
          "embed_batch_size":10,
          "enable_sparse":false
      }
  }'

The preceding code shows an example of using Milvus for the vector_store_config parameter. The following sections describe the vector_store_config configurations for other vector databases.

faiss

"vector_store_config":
      {
          "persist_path":"./localdata/knowledgebase/default/.index/.faiss",
          "type":"faiss",
          "is_image_store":false
      }

hologres

"vector_store_config":
      {
          "persist_path":"./localdata/knowledgebase/default/.index/.faiss",
          "type":"hologres",
          "is_image_store":false,
          "host":"xxx",
          "port":xxx,
          "user":"xxx",
          "password":"xxx",
          "database":"default",
          "table_name":"test",
          "pre_delete_table":"false"
      }

elasticsearch

"vector_store_config":
      {
          "persist_path":"./localdata/knowledgebase/default/.index/.faiss",
          "type":"elasticsearch",
          "is_image_store":false,
          "es_url":"xxx",
          "es_user":"xxx",
          "es_password":"xxx",
          "es_index":"xxx"
      }

opensearch

"vector_store_config":
      {
          "persist_path":"./localdata/knowledgebase/default/.index/.faiss",
          "type":"opensearch",
          "is_image_store":false,
          "endpoint":"xxx",
          "instance_id":"xxx",
          "username":"xxx",
          "password":"xxx",
          "table_name":"xxx"
      }

analyticdb

"vector_store_config":
      {
          "persist_path":"./localdata/knowledgebase/default/.index/.faiss",
          "type":"analyticdb",
          "is_image_store":false,
          "ak":"xxx",
          "sk":"xxx",
          "region_id":"xxx",
          "instance_id":"xxx",
          "account":"xxx",
          "account_password":"xxx",
          "namespace":"xxx",
          "collection":"xxx"
      }

tablestore

"vector_store_config":
      {
          "persist_path":"./localdata/knowledgebase/default/.index/.faiss",
          "type":"tablestore",
          "is_image_store":false,
          "endpoint":"xxx",
          "instance_name":"xxx",
          "access_key_id":"xxx",
          "access_key_secret":"xxx",
          "table_name":"xxx"
      }

dashvector

"vector_store_config":
      {
          "persist_path":"./localdata/knowledgebase/default/.index/.faiss",
          "type":"dashvector",
          "is_image_store":false,
          "endpoint":"xxx",
          "api_key":"xxx",
          "collection_name":"xxx",
          "partition_name":"xxx"
      }

Response example (click to view details)

{ "msg": "Add knowledgebase 'xxx' successfully." }

List knowledge bases

Calling method

URL

{EAS_SERVICE_URL}/api/v1/knowledgebases

Request method

GET

Request headers

Authorization: EAS_TOKEN # The token for the EAS call

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
curl -X 'GET' <EAS_SERVICE_URL>/api/v1/knowledgebases -H 'Authorization: <EAS_TOKEN>'

Response example (click to view details)

{
  "knowledgebases": {
    "default": {
      "name": "default",
      "vector_store_config": {
        "persist_path": "./localdata/knowledgebase/default/.index/.faiss",
        "type": "milvus",
        "is_image_store": false,
        "host": "c-exxx1911f4c.milvus.aliyuncs.com",
        "port": 19530,
        "user": "root",
        "password": "xxx",
        "database": "default",
        "collection_name": "test",
        "reranker_weights": [0.5, 0.5]
      },
      "embedding_config": {
        "source": "huggingface",
        "model": "bge-m3",
        "embed_batch_size": 10,
        "enable_sparse": false
      },
      "knowledgebase_paths": {
        "base_path": "localdata/knowledgebase/default",
        "docs_path": "localdata/knowledgebase/default/docs",
        "index_path": "localdata/knowledgebase/default/.index",
        "logs_path": "localdata/knowledgebase/default/.logs",
        "parse_path": "localdata/knowledgebase/default/.index/parse",
        "split_path": "localdata/knowledgebase/default/.index/split",
        "embed_path": "localdata/knowledgebase/default/.index/embed",
        "faiss_index_path": "localdata/knowledgebase/default/.index/.faiss",
        "doc_ids_map_file": "localdata/knowledgebase/default/.index/file_to_docid_map.json"
      }
    },
    "my_milvus": {
      "name": "my_milvus",
      "vector_store_config": {
        "persist_path": "./localdata/knowledgebase/default/.index/.faiss",
        "type": "milvus",
        "is_image_store": false,
        "host": "c-e6xxx11f4c.milvus.aliyuncs.com",
        "port": 19530,
        "user": "root",
        "password": "xxx",
        "database": "default",
        "collection_name": "test",
        "reranker_weights": [0.5, 0.5]
      },
      "embedding_config": {
        "source": "huggingface",
        "model": "bge-m3",
        "embed_batch_size": 10,
        "enable_sparse": false
      },
      "knowledgebase_paths": {
        "base_path": "localdata/knowledgebase/my_milvus",
        "docs_path": "localdata/knowledgebase/my_milvus/docs",
        "index_path": "localdata/knowledgebase/my_milvus/.index",
        "logs_path": "localdata/knowledgebase/my_milvus/.logs",
        "parse_path": "localdata/knowledgebase/my_milvus/.index/parse",
        "split_path": "localdata/knowledgebase/my_milvus/.index/split",
        "embed_path": "localdata/knowledgebase/my_milvus/.index/embed",
        "faiss_index_path": "localdata/knowledgebase/my_milvus/.index/.faiss",
        "doc_ids_map_file": "localdata/knowledgebase/my_milvus/.index/file_to_docid_map.json"
      }
    }
  }
}

Upload a knowledge base file

Calling method

URL

{EAS_SERVICE_URL}/api/v1/knowledgebases/{name}/files

Request method

POST

Request headers

  • Authorization: EAS_TOKEN # The token for the EAS call

  • Content-Type: multipart/form-data

Request parameters

  • files: The file.

  • name: The name of the knowledge base, such as my_milvus.

cURL request example (click to view details)

  • Upload a single file (use -F 'files=@path' to upload the file)

    # Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
    # Replace <name> with the name of your knowledge base. 
    # Replace the path after "-F 'files=@" with your knowledge base file path. 
    curl -X 'POST' <EAS_SERVICE_URL>/api/v1/knowledgebases/<name>/files \
    -H 'Authorization: <EAS_TOKEN>' \
    -H 'Content-Type: multipart/form-data' \
    -F 'files=@example_data/paul_graham/paul_graham_essay.txt'
  • Upload multiple files

    Use multiple -F 'files=@path' parameters. Each parameter corresponds to a file to upload. For example:

    # Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
    # Replace <name> with the name of your knowledge base. 
    # Replace the path after "-F 'files=@" with your knowledge base file path.
    curl -X 'POST' <EAS_SERVICE_URL>/api/v1/knowledgebases/<name>/files \
    -H 'Authorization: <EAS_TOKEN>' \
    -H 'Content-Type: multipart/form-data' \
    -F 'files=@example_data/paul_graham/paul_graham_essay.txt' \
    -F 'files=@example_data/another_file1.md' \
    -F 'files=@example_data/another_file2.pdf' \

Response example (click to view details)

{ "message": "Files have been successfully uploaded." }

Get the upload status

Calling method

URL

{EAS_SERVICE_URL}/api/v1//knowledgebases/{name}/files/{file_name}

Request method

GET

Request headers

Authorization: EAS_TOKEN # The token for the EAS call

Request parameters

  • file_name: The name of the file.

  • name: The name of the knowledge base, such as my_milvus.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Replace <name> with your knowledge base name and <file_name> with your file name. 
curl -X 'GET' <EAS_SERVICE_URL>/api/v1/knowledgebases/<name>/files/<file_name> -H 'Authorization: <EAS_TOKEN>'

Response example (click to view details)

{
  "task_id": "50fe181921a83edf63b5ecaa487e****",
  "operation": "UPDATE",
  "file_name": "localdata/knowledgebase/my_milvus/docs/paul_graham_essay.txt",
  "status": "done",
  "message": null,
  "last_modified_time": "2025-03-12 11:50:37"
}

Get the upload history

Calling method

URL

{EAS_SERVICE_URL}/api/v1/knowledgebases/{name}/history

Request method

GET

Request headers

Authorization: EAS_TOKEN # The token for the EAS call

Request parameters

name: The name of the knowledge base, such as my_milvus.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Replace <name> with the name of your knowledge base. 
curl -X 'GET' <EAS_SERVICE_URL>/api/v1/knowledgebases/<name>/history -H 'Authorization: <EAS_TOKEN>'

Response example (click to view details)

[
  {
    "task_id": "50fe181921a83edf63b5ecaa487e****",
    "operation": "UPDATE",
    "file_name": "localdata/knowledgebase/my_milvus/docs/paul_graham_essay.txt",
    "status": "done",
    "message": null,
    "last_modified_time": "2025-03-12 11:50:37"
  },
  {
    "task_id": "0162e61cbe605ddab865fff5f7d8****",
    "operation": "ADD",
    "file_name": "localdata/knowledgebase/my_milvus/docs/demo.pdf",
    "status": "failed",
    "message": "Error loading file",
    "last_modified_time": "2025-03-12 13:46:11"
  }
]

List knowledge base files

Calling method

URL

{EAS_SERVICE_URL}/api/v1/knowledgebases/{name}/files

Request method

GET

Request headers

Authorization: EAS_TOKEN # The token for the EAS call

Request parameters

name: The name of the knowledge base, such as my_milvus.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Replace <name> with the name of your knowledge base. 
curl -X 'GET' <EAS_SERVICE_URL>/api/v1/knowledgebases/<name>/files -H 'Authorization: <EAS_TOKEN>'

Response example (click to view details)

[
  {
    "file_name": "localdata/knowledgebase/my_milvus/docs/paul_graham_essay.txt",
    "doc_id": "50fe181921a83edf63b5ecaa487e****",
    "last_modified_time": "2025-03-12 14:38:51"
  }
]

Delete a knowledge base file

Calling method

URL

{EAS_SERVICE_URL}/api/v1/knowledgebases/{name}/files/{file_name}

Request method

DELETE

Request headers

Authorization: EAS_TOKEN # The token for the EAS call

Request parameters

  • file_name: The name of the file.

  • name: The name of the knowledge base, such as my_milvus.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Replace <name> with your knowledge base name. Replace <file_name> with the name of the file to delete. 
curl -X 'DELETE' <EAS_SERVICE_URL>/api/v1/knowledgebases/<name>/files/<file_name> -H 'Authorization: <EAS_TOKEN>'

Response example (click to view details)

{ "message": "File 'paul_graham_essay.txt' have been successfully removed." }

Get information about a knowledge base

Calling method

URL

{EAS_SERVICE_URL}/api/v1/knowledgebases/{name}

Request method

GET

Request headers

Authorization: EAS_TOKEN # The token for the EAS call

Request parameters

name: The name of the knowledge base, such as my_milvus.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Replace <name> with the name of your knowledge base. 
curl -X 'GET' <EAS_SERVICE_URL>/api/v1/knowledgebases/<name> -H 'Authorization: <EAS_TOKEN>'

Response example (click to view details)

{
  "name": "my_milvus",
  "vector_store_config": {
    "persist_path": "./localdata/knowledgebase/default/.index/.faiss",
    "type": "milvus",
    "is_image_store": false,
    "host": "c-exxx1****.milvus.aliyuncs.com",
    "port": 19530,
    "user": "root",
    "password": "xxx",
    "database": "default",
    "collection_name": "test",
    "reranker_weights": [0.5, 0.5]
  },
  "embedding_config": {
    "source": "huggingface",
    "model": "bge-m3",
    "embed_batch_size": 10,
    "enable_sparse": false
  },
  "knowledgebase_paths": {
    "base_path": "localdata/knowledgebase/my_milvus",
    "docs_path": "localdata/knowledgebase/my_milvus/docs",
    "index_path": "localdata/knowledgebase/my_milvus/.index",
    "logs_path": "localdata/knowledgebase/my_milvus/.logs",
    "parse_path": "localdata/knowledgebase/my_milvus/.index/parse",
    "split_path": "localdata/knowledgebase/my_milvus/.index/split",
    "embed_path": "localdata/knowledgebase/my_milvus/.index/embed",
    "faiss_index_path": "localdata/knowledgebase/my_milvus/.index/.faiss",
    "doc_ids_map_file": "localdata/knowledgebase/my_milvus/.index/file_to_docid_map.json"
  }
}

Update a knowledge base

Calling method

URL

{EAS_SERVICE_URL}/api/v1/knowledgebases/{name}

Request method

PATCH

Request headers

  • Authorization: EAS_TOKEN # The token for the EAS call

  • Content-Type: application/json

Request parameters

  • name: The name of the knowledge base, such as new_milvus.

  • vector_store_config: The knowledge base configuration.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Replace <name> with the name of your knowledge base. 
# Set vector_store_config to the configuration of the knowledge base that you want to update. 
curl -X 'PATCH' <EAS_SERVICE_URL>/api/v1/knowledgebases/<name> \
-H 'Authorization: <EAS_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
      "name":"<name>",
      "vector_store_config":
      {
          "persist_path":"./localdata/knowledgebase/default/.index/.faiss",
          "type":"milvus",
          "is_image_store":true,
          "host":"c-exxx11f4c.milvus.aliyuncs.com",
          "port":19530,
          "user":"root",
          "password":"xxx",
          "database":"default",
          "collection_name":"test",
          "reranker_weights":[0.5,0.5]
      },
      "embedding_config":
      {
          "source":"huggingface",
          "model":"bge-m3",
          "embed_batch_size":10,
          "enable_sparse":false
      }
  }'

The preceding code shows an example of using Milvus for the vector_store_config parameter. For more information about the vector_store_config configurations for other vector databases, see Add a knowledge base.

Response example (click to view details)

{ "msg": "Update knowledgebase 'new_milvus' successfully." }

Delete a knowledge base

Calling method

URL

{EAS_SERVICE_URL}/api/v1/knowledgebases/{name}

Request method

DELETE

Request headers

Authorization: EAS_TOKEN # The token for the EAS call

Request parameters

name: The name of the knowledge base, such as new_milvus.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Replace <name> with the name of your knowledge base. 
curl -X 'DELETE' <EAS_SERVICE_URL>/api/v1/knowledgebases/<name> -H 'Authorization: <EAS_TOKEN>'

Response example (click to view details)

{ "msg": "Delete knowledgebase 'new_milvus' successfully." }

Retrieve from a knowledge base

v0.3.0-v0.3.3

Calling method

URL

{EAS_SERVICE_URL}/api/v1/query/retrieval

Request method

POST

Request headers

  • Authorization: EAS_TOKEN # The token for the EAS call

  • Content-Type: application/json

Request parameters

  • question: The user's query.

  • index_name: The name of the knowledge base. The default value is default.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Set question to the user's query. 
# Set index_name to the name of the knowledge base. 
  curl -X 'POST' '<EAS_SERVICE_URL>/api/v1/query/retrieval' \
  -H 'Authorization: <EAS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
      "question": "What can I do when the x13-auto-arima component reports an error?",
      "index_name": "default"
  }'

Response example (click to view details)

{
  "docs": [
    {
      "text": "2.PAl-Studio/Designer FAQ 2.1. FAQ about algorithm components : \nCharacters that cannot be transcoded are displayed as \"blob.\" Ignore this error, because nodes in the downstream can read and process the data.\nWhat can I do when the x13-auto-arima component reports an error?\nMake sure that up to 1,200 training data samples are imported into the x13-auto-arima component.\nWhat can I do when the Doc2Vec component reports the CallExecutorToParseTaskFail error?",
      "score": 0.83608,
      "metadata": {
        "file_path": "localdata/knowledgebase/default/docs/pai_document.md",
        "file_name": "pai_document.md",
        "file_size": 3794,
        "creation_date": "2025-03-20",
        "last_modified_date": "2025-03-20"
      },
      "image_url": null
    },
    {
      "text": "2.PAl-Studio/Designer FAQ 2.1. FAQ about algorithm components : \nThis topic describes the FAQ about algorit hm components.\nWhat can I do when the format conversion component reports an error? · What can I do when \"blob\" is displayed on the data present ation page of the PAl? · what canI do when the xl3-auto-arima component reports an error? · What can Ido when the Doc2Vec component reports the CallExecutorToParseTaskFail error?\nWhat can I do when the format conversion component reports an error?",
      "score": 0.797132,
      "metadata": {
        "file_path": "localdata/knowledgebase/default/docs/pai_document.md",
        "file_name": "pai_document.md",
        "file_size": 3794,
        "creation_date": "2025-03-20",
        "last_modified_date": "2025-03-20"
      },
      "image_url": null
    },
    {
      "text": "2.PAl-Studio/Designer FAQ 2.1. FAQ about algorithm components\n2.3. Preview Oss files in Machine Learning Studio : \n2.On the details page of the Oss bucket, choose Access Cont rol $>$ Cross-Origin Resource Sharing (CORS). In the Cross-Origin Resource Sharing (CORS) section, click Conf igure.\n3.Click Create Rule. In the Create Rule panel, set the following parameters.",
      "score": 0.714184,
      "metadata": {
        "file_path": "localdata/knowledgebase/default/docs/pai_document.md",
        "file_name": "pai_document.md",
        "file_size": 3794,
        "creation_date": "2025-03-20",
        "last_modified_date": "2025-03-20"
      },
      "image_url": null
    }
  ]
}

v0.3.4

Calling method

URL

{EAS_SERVICE_URL}/api/v1/retrieval

Request method

POST

Request headers

  • Authorization: EAS_TOKEN # The token for the EAS call

  • Content-Type: application/json

Request parameters

  • query: The user's search query.

  • knowledgebase_id: The name of the knowledge base. The default value is default.

  • retrieval_settings: The retrieval parameters. We recommend that you configure these parameters on the WebUI. For more information about the parameters, see the WebUI.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Set query to the user's search query. 
# Set knowledge_id to the name of the knowledge base. 
curl -X 'POST' '<EAS_SERVICE_URL>/api/v1/retrieval' \
  -H 'Authorization: <EAS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
      "query": "What can I do when the x13-auto-arima component reports an error?",
      "knowledgebase_id": "default",
      "retrieval_settings": {"similarity_top_k": 5}
  }'

Other API operations

Get the RAG service configuration

Calling method

URL

{EAS_SERVICE_URL}/api/v1/config

Request method

GET

Request headers

Authorization: EAS_TOKEN # The token for the EAS call

cURL request example (click to view details)

 # Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
 curl -X 'GET' '<EAS_SERVICE_URL>/api/v1/config' -H 'Authorization: <EAS_TOKEN>'

Response example (click to view details)

  {
    "system": {
      "default_web_search": false,
      "query_type": "websearch"
    },
    "data_reader": {
      "concat_csv_rows": false,
      "enable_mandatory_ocr": false,
      "format_sheet_data_to_json": false,
      "sheet_column_filters": null,
      "number_workers": 4
    },
    "node_parser": {
      "type": "Sentence",
      "chunk_size": 500,
      "chunk_overlap": 10,
      "enable_multimodal": true,
      "paragraph_separator": "\n\n\n",
      "sentence_window_size": 3,
      "sentence_chunk_overlap": 200,
      "breakpoint_percentile_threshold": 95,
      "buffer_size": 1
    },
    "index": {
      "vector_store": {
        "persist_path": "./localdata/knowledgebase/default/.index/.faiss",
        "type": "faiss",
        "is_image_store": false
      },
      "enable_multimodal": true,
      "persist_path": "localdata/storage"
    },
    "embedding": {
      "source": "huggingface",
      "model": "bge-m3",
      "embed_batch_size": 10,
      "enable_sparse": false
    },
    "multimodal_embedding": {
      "source": "cnclip",
      "model": "ViT-L-14",
      "embed_batch_size": 10,
      "enable_sparse": false
    },
    "llm": {
      "source": "openai_compatible",
      "temperature": 0.1,
      "system_prompt": null,
      "max_tokens": 4000,
      "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
      "api_key": "sk-xxx",
      "model": "qwen-max"
    },
    "multimodal_llm": {
      "source": "openai_compatible",
      "temperature": 0.1,
      "system_prompt": null,
      "max_tokens": 4000,
      "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
      "api_key": "sk-xxx",
      "model": ""
    },
    "functioncalling_llm": null,
    "agent": {
      "system_prompt": "You are a travel assistant, xxx",
      "python_scripts": "xxx",
      "function_definition": "xxx",
      "api_definition": "xxx"
    },
    "chat_store": {
      "type": "local",
      "persist_path": "localdata/storage"
    },
    "data_analysis": {
      "type": "mysql",
      "nl2sql_prompt": "Given an input question, xxx",
      "synthesizer_prompt": "Given an input question, xxx",
      "database": "my_pets",
      "tables": [],
      "descriptions": {},
      "enable_enhanced_description": false,
      "enable_db_history": true,
      "enable_db_embedding": true,
      "max_col_num": 100,
      "max_val_num": 1000,
      "enable_query_preprocessor": true,
      "enable_db_preretriever": true,
      "enable_db_selector": true,
      "user": "root",
      "password": "xxx",
      "host": "127.0.0.1",
      "port": 3306
    },
    "intent": {
      "descriptions": {
        "rag": "\nThis tool can help you get more specific information from the knowledge base.\n",
        "tool": "\nThis tool can help you get travel information about time, weather, flights, train and hotels.\n"
      }
    },
    "node_enhancement": {
      "tree_depth": 3,
      "max_clusters": 52,
      "proba_threshold": 0.1
    },
    "oss_store": {
      "bucket": "",
      "endpoint": "oss-cn-hangzhou.aliyuncs.com",
      "ak": null,
      "sk": null
    },
    "postprocessor": {
      "reranker_type": "no-reranker",
      "similarity_threshold": 0.5
    },
    "retriever": {
      "vector_store_query_mode": "default",
      "similarity_top_k": 3,
      "image_similarity_top_k": 2,
      "search_image": false,
      "hybrid_fusion_weights": [0.7, 0.3]
    },
    "search": {
      "source": "google",
      "search_count": 10,
      "serpapi_key": "142xxx",
      "search_lang": "zh-CN"
    },
    "synthesizer": {
      "use_multimodal_llm": false,
      "system_role_template": "You are xxx",
      "custom_prompt_template": "Your goal is to provide accurate, useful, and easy-to-understand information. xxx"
    },
    "query_rewrite": {
      "enabled": true,
      "rewrite_prompt_template": "# Role\nYou are a professional information retrieval expert, xxx",
      "llm": {
        "source": "openai_compatible",
        "temperature": 0.1,
        "system_prompt": null,
        "max_tokens": 4000,
        "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
        "api_key": null,
        "model": ""
      }
    },
    "guardrail": {
      "endpoint": null,
      "region": null,
      "access_key_id": null,
      "access_key_secret": null,
      "custom_advice": null
    }
  }

Update the RAG service configuration

Calling method

URL

{EAS_SERVICE_URL}/api/v1/config

Request method

PATCH

Request headers

  • Authorization: EAS_TOKEN # The token for the EAS call

  • Content-Type: application/json

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
    curl -X 'PATCH' '<EAS_SERVICE_URL>/api/v1/config' \
    -H 'Authorization: <EAS_TOKEN>' \
    -H 'Content-Type: application/json' \
    -d '{
        "system": {
          "default_web_search": false,
          "query_type": "websearch"
        },
        "data_reader": {
          "concat_csv_rows": false,
          "enable_mandatory_ocr": false,
          "format_sheet_data_to_json": false,
          "sheet_column_filters": null,
          "number_workers": 4
        },
        "node_parser": {
          "type": "Sentence",
          "chunk_size": 500,
          "chunk_overlap": 10,
          "enable_multimodal": true,
          "paragraph_separator": "\n\n\n",
          "sentence_window_size": 3,
          "sentence_chunk_overlap": 200,
          "breakpoint_percentile_threshold": 95,
          "buffer_size": 1
        },
        ...
    }' # (For more configuration information, see the response example for getting the RAG service configuration.)

Response example (click to view details)

  { "msg": "Update RAG configuration successfully." }

Load CHAT_DB information

Upload an Excel or CSV file for table content query in Chat_DB

Calling method

URL

{EAS_SERVICE_URL}/api/v1/upload_datasheet

Request method

POST

Request headers

  • Authorization: EAS_TOKEN # The token for the EAS call

  • Content-Type: multipart/form-data

Request parameters

file: The Excel or CSV file.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Replace the path after "-F 'file=@" with the file path. 
  curl -X 'POST' <EAS_SERVICE_URL>/api/v1/upload_datasheet \
  -H 'Authorization: <EAS_TOKEN>' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@example_data/titanic_train.csv'

Response example (click to view details)

  {
    "task_id": "3b12cf5fabee4a99a32895d2f693****",
    "destination_path": "./localdata/data_analysis/titanic_train.csv",
    "data_preview": "xxx"
  }

Upload a JSON file to supplement Chat_DB database information with Q&A pairs

Calling method

URL

{EAS_SERVICE_URL}/api/v1/upload_db_history

Request method

POST

Request headers

  • Authorization: EAS_TOKEN # The token for the EAS call

  • Content-Type: multipart/form-data

Request parameters

  • file: The JSON file.

  • db_name: The name of the database.

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
# Replace the path after " -F 'file=@" with the JSON file path. Set db_name to your database name. 
  curl -X 'POST' <EAS_SERVICE_URL>/api/v1/upload_db_history \
  -H 'Authorization: <EAS_TOKEN>' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@example_data/db_query_history.json' \
  -F 'db_name=my_pets'

Response example (click to view details)

  {
    "task_id": "204191f946384a54a48b13ec00fd****",
    "destination_path": "./localdata/data_analysis/text2sql/history/my_pets_db_query_history.json"
  }

Upload a CSV file to supplement Chat_DB database information with column descriptions

Calling method

URL

{EAS_SERVICE_URL}/api/v1/upload_db_description

Request method

POST

Request headers

  • Authorization: EAS_TOKEN # The token for the EAS call

  • Content-Type: multipart/form-data

Request parameters

  • files: The CSV file.

  • db_name: The name of the database.

cURL request example (click to view details)

 # Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively. 
 # Replace the path after "-F 'files=@" with your CSV file path. Set db_name to the database name. 
  curl -X 'POST' <EAS_SERVICE_URL>/api/v1/upload_db_description \
  -H 'Authorization: <EAS_TOKEN>' \
  -H 'Content-Type: multipart/form-data' \
  -F 'files=@example_data/database_description/schools.csv' \
  -F 'db_name=california_schools'

Response example (click to view details)

  {
    "task_id": "f417e436cf8b4c329f7b48a7f3c4****",
    "destination_path": "./localdata/data_analysis/text2sql/input_description"
  }

Load database information

Calling method

URL

{EAS_SERVICE_URL}/api/v1/query/load_db_info

Request method

POST

Request headers

Authorization: EAS_TOKEN # The token for the EAS call

cURL request example (click to view details)

# Replace <EAS_TOKEN> and <EAS_SERVICE_URL> with the service token and endpoint, respectively.
curl -X 'POST' <EAS_SERVICE_URL>/api/v1/query/load_db_info -H 'Authorization: <EAS_TOKEN>'

Response example (click to view details)

  { "task_id": "2389f546af2b6c359d7b19c8b5c3****" }