HTTP API
A complete reference for AIBuilder's RESTful API. Before proceeding, please ensure you have your AIBuilder API key ready for authentication.
OpenAI-Compatible API#
Create chat completion#
POST /api/v1/chats_openai/{chat_id}/chat/completions
Creates a model response for a given chat conversation.
This API follows the same request and response format as OpenAI's API. It allows you to interact with the model in a manner similar to how you would with OpenAI's API.
Request#
- Method: POST
- URL:
/api/v1/chats_openai/{chat_id}/chat/completions - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"model":string"messages":object list"stream":boolean
Request example#
Request Parameters#
model(Body parameter)string, Required The model used to generate the response. The server will parse this automatically, so you can set it to any value for now.messages(Body parameter)list[object], Required A list of historical chat messages used to generate the response. This must contain at least one message with theuserrole.stream(Body parameter)booleanWhether to receive the response as a stream. Set this tofalseexplicitly if you prefer to receive the entire response in one go instead of as a stream.
Response#
Stream:
Non-stream:
Failure:
DATASET MANAGEMENT#
Create dataset#
POST /api/v1/datasets
Creates a dataset.
Request#
- Method: POST
- URL:
/api/v1/datasets - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"name":string"avatar":string"description":string"embedding_model":string"permission":string"chunk_method":string"parser_config":object
Request example#
Request parameters#
"name": (Body parameter),string, Required
The unique name of the dataset to create. It must adhere to the following requirements:- Permitted characters include:
- English letters (a-z, A-Z)
- Digits (0-9)
- "_" (underscore)
- Must begin with an English letter or underscore.
- Maximum 65,535 characters.
- Case-insensitive.
- Permitted characters include:
"avatar": (Body parameter),string
Base64 encoding of the avatar."description": (Body parameter),string
A brief description of the dataset to create."embedding_model": (Body parameter),string
The name of the embedding model to use. For example:"BAAI/bge-zh-v1.5""permission": (Body parameter),string
Specifies who can access the dataset to create. Available options:"me": (Default) Only you can manage the dataset."team": All team members can manage the dataset.
"chunk_method": (Body parameter),enum<string>
The chunking method of the dataset to create. Available options:"naive": General (default)"manual": Manual"qa": Q&A"table": Table"paper": Paper"book": Book"laws": Laws"presentation": Presentation"picture": Picture"one": One"knowledge_graph": Knowledge Graph
Ensure your LLM is properly configured on the Settings page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!"email": Email
"parser_config": (Body parameter),object
The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected"chunk_method":- If
"chunk_method"is"naive", the"parser_config"object contains the following attributes:"chunk_token_count": Defaults to128."layout_recognize": Defaults totrue."html4excel": Indicates whether to convert Excel documents into HTML format. Defaults tofalse."delimiter": Defaults to"\n!?。;!?"."task_page_size": Defaults to12. For PDF only."raptor": Raptor-specific settings. Defaults to:{"use_raptor": false}.
- If
"chunk_method"is"qa","manuel","paper","book","laws", or"presentation", the"parser_config"object contains the following attribute:"raptor": Raptor-specific settings. Defaults to:{"use_raptor": false}.
- If
"chunk_method"is"table","picture","one", or"email","parser_config"is an empty JSON object. - If
"chunk_method"is"knowledge_graph", the"parser_config"object contains the following attributes:"chunk_token_count": Defaults to128."delimiter": Defaults to"\n!?。;!?"."entity_types": Defaults to["organization","person","location","event","time"]
- If
Response#
Success:
Failure:
Delete datasets#
DELETE /api/v1/datasets
Deletes datasets by ID.
Request#
- Method: DELETE
- URL:
/api/v1/datasets - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'- Body:
"ids":list[string]
Request example#
Request parameters#
"ids": (Body parameter),list[string]
The IDs of the datasets to delete. If it is not specified, all datasets will be deleted.
Response#
Success:
Failure:
Update dataset#
PUT /api/v1/datasets/{dataset_id}
Updates configurations for a specified dataset.
Request#
- Method: PUT
- URL:
/api/v1/datasets/{dataset_id} - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"name":string"embedding_model":string"chunk_method":enum<string>
Request example#
Request parameters#
dataset_id: (Path parameter)
The ID of the dataset to update."name": (Body parameter),string
The revised name of the dataset."embedding_model": (Body parameter),string
The updated embedding model name.- Ensure that
"chunk_count"is0before updating"embedding_model".
- Ensure that
"chunk_method": (Body parameter),enum<string>
The chunking method for the dataset. Available options:"naive": General"manual: Manual"qa": Q&A"table": Table"paper": Paper"book": Book"laws": Laws"presentation": Presentation"picture": Picture"one":One"email": Email"knowledge_graph": Knowledge Graph
Ensure your LLM is properly configured on the Settings page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!
Response#
Success:
Failure:
List datasets#
GET /api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id}
Lists datasets.
Request#
- Method: GET
- URL:
/api/v1/datasets?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} - Headers:
'Authorization: Bearer <YOUR_API_KEY>'
Request example#
Request parameters#
page: (Filter parameter)
Specifies the page on which the datasets will be displayed. Defaults to1.page_size: (Filter parameter)
The number of datasets on each page. Defaults to30.orderby: (Filter parameter)
The field by which datasets should be sorted. Available options:create_time(default)update_time
desc: (Filter parameter)
Indicates whether the retrieved datasets should be sorted in descending order. Defaults totrue.name: (Filter parameter)
The name of the dataset to retrieve.id: (Filter parameter)
The ID of the dataset to retrieve.
Response#
Success:
Failure:
FILE MANAGEMENT WITHIN DATASET#
Upload documents#
POST /api/v1/datasets/{dataset_id}/documents
Uploads documents to a specified dataset.
Request#
- Method: POST
- URL:
/api/v1/datasets/{dataset_id}/documents - Headers:
'Content-Type: multipart/form-data''Authorization: Bearer <YOUR_API_KEY>'
- Form:
'file=@{FILE_PATH}'
Request example#
Request parameters#
dataset_id: (Path parameter)
The ID of the dataset to which the documents will be uploaded.'file': (Body parameter)
A document to upload.
Response#
Success:
Failure:
Update document#
PUT /api/v1/datasets/{dataset_id}/documents/{document_id}
Updates configurations for a specified document.
Request#
- Method: PUT
- URL:
/api/v1/datasets/{dataset_id}/documents/{document_id} - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"name":string"meta_fields":object"chunk_method":string"parser_config":object
Request example#
Request parameters#
dataset_id: (Path parameter)
The ID of the associated dataset.document_id: (Path parameter)
The ID of the document to update."name": (Body parameter),string"meta_fields": (Body parameter),dict[str, Any]The meta fields of the document."chunk_method": (Body parameter),string
The parsing method to apply to the document:"naive": General"manual: Manual"qa": Q&A"table": Table"paper": Paper"book": Book"laws": Laws"presentation": Presentation"picture": Picture"one": One"email": Email
"parser_config": (Body parameter),object
The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected"chunk_method":- If
"chunk_method"is"naive", the"parser_config"object contains the following attributes:"chunk_token_count": Defaults to128."layout_recognize": Defaults totrue."html4excel": Indicates whether to convert Excel documents into HTML format. Defaults tofalse."delimiter": Defaults to"\n!?。;!?"."task_page_size": Defaults to12. For PDF only."raptor": Raptor-specific settings. Defaults to:{"use_raptor": false}.
- If
"chunk_method"is"qa","manuel","paper","book","laws", or"presentation", the"parser_config"object contains the following attribute:"raptor": Raptor-specific settings. Defaults to:{"use_raptor": false}.
- If
"chunk_method"is"table","picture","one", or"email","parser_config"is an empty JSON object. - If
"chunk_method"is"knowledge_graph", the"parser_config"object contains the following attributes:"chunk_token_count": Defaults to128."delimiter": Defaults to"\n!?。;!?"."entity_types": Defaults to["organization","person","location","event","time"]
- If
Response#
Success:
Failure:
Download document#
GET /api/v1/datasets/{dataset_id}/documents/{document_id}
Downloads a document from a specified dataset.
Request#
- Method: GET
- URL:
/api/v1/datasets/{dataset_id}/documents/{document_id} - Headers:
'Authorization: Bearer <YOUR_API_KEY>'
- Output:
'{PATH_TO_THE_FILE}'
Request example#
Request parameters#
dataset_id: (Path parameter)
The associated dataset ID.documents_id: (Path parameter)
The ID of the document to download.
Response#
Success:
Failure:
List documents#
GET /api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name}
Lists documents in a specified dataset.
Request#
- Method: GET
- URL:
/api/v1/datasets/{dataset_id}/documents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&keywords={keywords}&id={document_id}&name={document_name} - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
Request example#
Request parameters#
dataset_id: (Path parameter)
The associated dataset ID.keywords: (Filter parameter),string
The keywords used to match document titles.page: (Filter parameter),integerSpecifies the page on which the documents will be displayed. Defaults to1.page_size: (Filter parameter),integer
The maximum number of documents on each page. Defaults to30.orderby: (Filter parameter),string
The field by which documents should be sorted. Available options:create_time(default)update_time
desc: (Filter parameter),boolean
Indicates whether the retrieved documents should be sorted in descending order. Defaults totrue.id: (Filter parameter),string
The ID of the document to retrieve.
Response#
Success:
Failure:
Delete documents#
DELETE /api/v1/datasets/{dataset_id}/documents
Deletes documents by ID.
Request#
- Method: DELETE
- URL:
/api/v1/datasets/{dataset_id}/documents - Headers:
'Content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"ids":list[string]
Request example#
Request parameters#
dataset_id: (Path parameter)
The associated dataset ID."ids": (Body parameter),list[string]
The IDs of the documents to delete. If it is not specified, all documents in the specified dataset will be deleted.
Response#
Success:
Failure:
Parse documents#
POST /api/v1/datasets/{dataset_id}/chunks
Parses documents in a specified dataset.
Request#
- Method: POST
- URL:
/api/v1/datasets/{dataset_id}/chunks - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"document_ids":list[string]
Request example#
Request parameters#
dataset_id: (Path parameter)
The dataset ID."document_ids": (Body parameter),list[string], Required
The IDs of the documents to parse.
Response#
Success:
Failure:
Stop parsing documents#
DELETE /api/v1/datasets/{dataset_id}/chunks
Stops parsing specified documents.
Request#
- Method: DELETE
- URL:
/api/v1/datasets/{dataset_id}/chunks - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"document_ids":list[string]
Request example#
Request parameters#
dataset_id: (Path parameter)
The associated dataset ID."document_ids": (Body parameter),list[string], Required
The IDs of the documents for which the parsing should be stopped.
Response#
Success:
Failure:
CHUNK MANAGEMENT WITHIN DATASET#
Add chunk#
POST /api/v1/datasets/{dataset_id}/documents/{document_id}/chunks
Adds a chunk to a specified document in a specified dataset.
Request#
- Method: POST
- URL:
/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"content":string"important_keywords":list[string]
Request example#
Request parameters#
dataset_id: (Path parameter)
The associated dataset ID.document_ids: (Path parameter)
The associated document ID."content": (Body parameter),string, Required
The text content of the chunk."important_keywords(Body parameter),list[string]
The key terms or phrases to tag with the chunk."questions"(Body parameter),list[string]If there is a given question, the embedded chunks will be based on them
Response#
Success:
Failure:
List chunks#
GET /api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={id}
Lists chunks in a specified document.
Request#
- Method: GET
- URL:
/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks?keywords={keywords}&page={page}&page_size={page_size}&id={chunk_id} - Headers:
'Authorization: Bearer <YOUR_API_KEY>'
Request example#
Request parameters#
dataset_id: (Path parameter)
The associated dataset ID.document_ids: (Path parameter)
The associated document ID.keywords(Filter parameter),string
The keywords used to match chunk content.page(Filter parameter),integer
Specifies the page on which the chunks will be displayed. Defaults to1.page_size(Filter parameter),integer
The maximum number of chunks on each page. Defaults to1024.id(Filter parameter),string
The ID of the chunk to retrieve.
Response#
Success:
Failure:
Delete chunks#
DELETE /api/v1/datasets/{dataset_id}/documents/{document_id}/chunks
Deletes chunks by ID.
Request#
- Method: DELETE
- URL:
/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"chunk_ids":list[string]
Request example#
Request parameters#
dataset_id: (Path parameter)
The associated dataset ID.document_ids: (Path parameter)
The associated document ID."chunk_ids": (Body parameter),list[string]
The IDs of the chunks to delete. If it is not specified, all chunks of the specified document will be deleted.
Response#
Success:
Failure:
Update chunk#
PUT /api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id}
Updates content or configurations for a specified chunk.
Request#
- Method: PUT
- URL:
/api/v1/datasets/{dataset_id}/documents/{document_id}/chunks/{chunk_id} - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"content":string"important_keywords":list[string]"available":boolean
Request example#
Request parameters#
dataset_id: (Path parameter)
The associated dataset ID.document_ids: (Path parameter)
The associated document ID.chunk_id: (Path parameter)
The ID of the chunk to update."content": (Body parameter),string
The text content of the chunk."important_keywords": (Body parameter),list[string]
A list of key terms or phrases to tag with the chunk."available": (Body parameter)boolean
The chunk's availability status in the dataset. Value options:true: Available (default)false: Unavailable
Response#
Success:
Failure:
Retrieve chunks#
POST /api/v1/retrieval
Retrieves chunks from specified datasets.
Request#
- Method: POST
- URL:
/api/v1/retrieval - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"question":string"dataset_ids":list[string]"document_ids":list[string]"page":integer"page_size":integer"similarity_threshold":float"vector_similarity_weight":float"top_k":integer"rerank_id":string"keyword":boolean"highlight":boolean
Request example#
Request parameter#
"question": (Body parameter),string, Required
The user query or query keywords."dataset_ids": (Body parameter)list[string]
The IDs of the datasets to search. If you do not set this argument, ensure that you set"document_ids"."document_ids": (Body parameter),list[string]
The IDs of the documents to search. Ensure that all selected documents use the same embedding model. Otherwise, an error will occur. If you do not set this argument, ensure that you set"dataset_ids"."page": (Body parameter),integer
Specifies the page on which the chunks will be displayed. Defaults to1."page_size": (Body parameter)
The maximum number of chunks on each page. Defaults to30."similarity_threshold": (Body parameter)
The minimum similarity score. Defaults to0.2."vector_similarity_weight": (Body parameter),float
The weight of vector cosine similarity. Defaults to0.3. If x represents the weight of vector cosine similarity, then (1 - x) is the term similarity weight."top_k": (Body parameter),integer
The number of chunks engaged in vector cosine computation. Defaults to1024."rerank_id": (Body parameter),integer
The ID of the rerank model."keyword": (Body parameter),boolean
Indicates whether to enable keyword-based matching:true: Enable keyword-based matching.false: Disable keyword-based matching (default).
"highlight": (Body parameter),boolean
Specifies whether to enable highlighting of matched terms in the results:true: Enable highlighting of matched terms.false: Disable highlighting of matched terms (default).
Response#
Success:
Failure:
CHAT ASSISTANT MANAGEMENT#
Create chat assistant#
POST /api/v1/chats
Creates a chat assistant.
Request#
- Method: POST
- URL:
/api/v1/chats - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"name":string"avatar":string"dataset_ids":list[string]"llm":object"prompt":object
Request example#
Request parameters#
"name": (Body parameter),string, Required
The name of the chat assistant."avatar": (Body parameter),string
Base64 encoding of the avatar."dataset_ids": (Body parameter),list[string]
The IDs of the associated datasets."llm": (Body parameter),object
The LLM settings for the chat assistant to create. If it is not explicitly set, a JSON object with the following values will be generated as the default. AnllmJSON object contains the following attributes:"model_name",string
The chat model name. If not set, the user's default chat model will be used."temperature":float
Controls the randomness of the model's predictions. A lower temperature results in more conservative responses, while a higher temperature yields more creative and diverse responses. Defaults to0.1."top_p":float
Also known as “nucleus sampling”, this parameter sets a threshold to select a smaller set of words to sample from. It focuses on the most likely words, cutting off the less probable ones. Defaults to0.3"presence_penalty":float
This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to0.2."frequency penalty":float
Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to0.7."max_token":integer
The maximum length of the model's output, measured in the number of tokens (words or pieces of words). Defaults to512. If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses.
"prompt": (Body parameter),object
Instructions for the LLM to follow. If it is not explicitly set, a JSON object with the following values will be generated as the default. ApromptJSON object contains the following attributes:"similarity_threshold":floatAIBuilder employs either a combination of weighted keyword similarity and weighted vector cosine similarity, or a combination of weighted keyword similarity and weighted reranking score during retrieval. This argument sets the threshold for similarities between the user query and chunks. If a similarity score falls below this threshold, the corresponding chunk will be excluded from the results. The default value is0.2."keywords_similarity_weight":floatThis argument sets the weight of keyword similarity in the hybrid similarity score with vector cosine similarity or reranking model similarity. By adjusting this weight, you can control the influence of keyword similarity in relation to other similarity measures. The default value is0.7."top_n":intThis argument specifies the number of top chunks with similarity scores above thesimilarity_thresholdthat are fed to the LLM. The LLM will only access these 'top N' chunks. The default value is8."variables":object[]This argument lists the variables to use in the 'System' field of Chat Configurations. Note that:"knowledge"is a reserved variable, which represents the retrieved chunks.- All the variables in 'System' should be curly bracketed.
- The default value is
[{"key": "knowledge", "optional": true}].
"rerank_model":stringIf it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used.top_k:intRefers to the process of reordering or selecting the top-k items from a list or set based on a specific ranking criterion. Default to 1024."empty_response":stringIf nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank."opener":stringThe opening greeting for the user. Defaults to"Hi! I am your assistant, can I help you?"."show_quote:booleanIndicates whether the source of text should be displayed. Defaults totrue."prompt":stringThe prompt content.
Response#
Success:
Failure:
Update chat assistant#
PUT /api/v1/chats/{chat_id}
Updates configurations for a specified chat assistant.
Request#
- Method: PUT
- URL:
/api/v1/chats/{chat_id} - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"name":string"avatar":string"dataset_ids":list[string]"llm":object"prompt":object
Request example#
Parameters#
chat_id: (Path parameter)
The ID of the chat assistant to update."name": (Body parameter),string, Required
The revised name of the chat assistant."avatar": (Body parameter),string
Base64 encoding of the avatar."dataset_ids": (Body parameter),list[string]
The IDs of the associated datasets."llm": (Body parameter),object
The LLM settings for the chat assistant to create. If it is not explicitly set, a dictionary with the following values will be generated as the default. Anllmobject contains the following attributes:"model_name",string
The chat model name. If not set, the user's default chat model will be used."temperature":float
Controls the randomness of the model's predictions. A lower temperature results in more conservative responses, while a higher temperature yields more creative and diverse responses. Defaults to0.1."top_p":float
Also known as “nucleus sampling”, this parameter sets a threshold to select a smaller set of words to sample from. It focuses on the most likely words, cutting off the less probable ones. Defaults to0.3"presence_penalty":float
This discourages the model from repeating the same information by penalizing words that have already appeared in the conversation. Defaults to0.2."frequency penalty":float
Similar to the presence penalty, this reduces the model’s tendency to repeat the same words frequently. Defaults to0.7."max_token":integer
The maximum length of the model's output, measured in the number of tokens (words or pieces of words). Defaults to512. If disabled, you lift the maximum token limit, allowing the model to determine the number of tokens in its responses.
"prompt": (Body parameter),object
Instructions for the LLM to follow. Apromptobject contains the following attributes:"similarity_threshold":floatAIBuilder employs either a combination of weighted keyword similarity and weighted vector cosine similarity, or a combination of weighted keyword similarity and weighted rerank score during retrieval. This argument sets the threshold for similarities between the user query and chunks. If a similarity score falls below this threshold, the corresponding chunk will be excluded from the results. The default value is0.2."keywords_similarity_weight":floatThis argument sets the weight of keyword similarity in the hybrid similarity score with vector cosine similarity or reranking model similarity. By adjusting this weight, you can control the influence of keyword similarity in relation to other similarity measures. The default value is0.7."top_n":intThis argument specifies the number of top chunks with similarity scores above thesimilarity_thresholdthat are fed to the LLM. The LLM will only access these 'top N' chunks. The default value is8."variables":object[]This argument lists the variables to use in the 'System' field of Chat Configurations. Note that:"knowledge"is a reserved variable, which represents the retrieved chunks.- All the variables in 'System' should be curly bracketed.
- The default value is
[{"key": "knowledge", "optional": true}]
"rerank_model":stringIf it is not specified, vector cosine similarity will be used; otherwise, reranking score will be used."empty_response":stringIf nothing is retrieved in the dataset for the user's question, this will be used as the response. To allow the LLM to improvise when nothing is found, leave this blank."opener":stringThe opening greeting for the user. Defaults to"Hi! I am your assistant, can I help you?"."show_quote:booleanIndicates whether the source of text should be displayed. Defaults totrue."prompt":stringThe prompt content.
Response#
Success:
Failure:
Delete chat assistants#
DELETE /api/v1/chats
Deletes chat assistants by ID.
Request#
- Method: DELETE
- URL:
/api/v1/chats - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"ids":list[string]
Request example#
Request parameters#
"ids": (Body parameter),list[string]
The IDs of the chat assistants to delete. If it is not specified, all chat assistants in the system will be deleted.
Response#
Success:
Failure:
List chat assistants#
GET /api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={chat_name}&id={chat_id}
Lists chat assistants.
Request#
- Method: GET
- URL:
/api/v1/chats?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={dataset_name}&id={dataset_id} - Headers:
'Authorization: Bearer <YOUR_API_KEY>'
Request example#
Request parameters#
page: (Filter parameter),integer
Specifies the page on which the chat assistants will be displayed. Defaults to1.page_size: (Filter parameter),integer
The number of chat assistants on each page. Defaults to30.orderby: (Filter parameter),string
The attribute by which the results are sorted. Available options:create_time(default)update_time
desc: (Filter parameter),boolean
Indicates whether the retrieved chat assistants should be sorted in descending order. Defaults totrue.id: (Filter parameter),string
The ID of the chat assistant to retrieve.name: (Filter parameter),string
The name of the chat assistant to retrieve.
Response#
Success:
Failure:
SESSION MANAGEMENT#
Create session with chat assistant#
POST /api/v1/chats/{chat_id}/sessions
Creates a session with a chat assistant.
Request#
- Method: POST
- URL:
/api/v1/chats/{chat_id}/sessions - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"name":string"user_id":string(optional)
Request example#
Request parameters#
chat_id: (Path parameter)
The ID of the associated chat assistant."name": (Body parameter),string
The name of the chat session to create."user_id": (Body parameter),string
Optional user-defined ID.
Response#
Success:
Failure:
Update chat assistant's session#
PUT /api/v1/chats/{chat_id}/sessions/{session_id}
Updates a session of a specified chat assistant.
Request#
- Method: PUT
- URL:
/api/v1/chats/{chat_id}/sessions/{session_id} - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"name:string"user_id:string(optional)
Request example#
Request Parameter#
chat_id: (Path parameter)
The ID of the associated chat assistant.session_id: (Path parameter)
The ID of the session to update."name": (Body Parameter),string
The revised name of the session."user_id": (Body parameter),string
Optional user-defined ID.
Response#
Success:
Failure:
List chat assistant's sessions#
GET /api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}
Lists sessions associated with a specified chat assistant.
Request#
- Method: GET
- URL:
/api/v1/chats/{chat_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={session_name}&id={session_id}&user_id={user_id} - Headers:
'Authorization: Bearer <YOUR_API_KEY>'
Request example#
Request Parameters#
chat_id: (Path parameter)
The ID of the associated chat assistant.page: (Filter parameter),integer
Specifies the page on which the sessions will be displayed. Defaults to1.page_size: (Filter parameter),integer
The number of sessions on each page. Defaults to30.orderby: (Filter parameter),string
The field by which sessions should be sorted. Available options:create_time(default)update_time
desc: (Filter parameter),boolean
Indicates whether the retrieved sessions should be sorted in descending order. Defaults totrue.name: (Filter parameter)string
The name of the chat session to retrieve.id: (Filter parameter),string
The ID of the chat session to retrieve.user_id: (Filter parameter),string
The optional user-defined ID passed in when creating session.
Response#
Success:
Failure:
Delete chat assistant's sessions#
DELETE /api/v1/chats/{chat_id}/sessions
Deletes sessions of a chat assistant by ID.
Request#
- Method: DELETE
- URL:
/api/v1/chats/{chat_id}/sessions - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"ids":list[string]
Request example#
Request Parameters#
chat_id: (Path parameter)
The ID of the associated chat assistant."ids": (Body Parameter),list[string]
The IDs of the sessions to delete. If it is not specified, all sessions associated with the specified chat assistant will be deleted.
Response#
Success:
Failure:
Converse with chat assistant#
POST /api/v1/chats/{chat_id}/completions
Asks a specified chat assistant a question to start an AI-powered conversation.
NOTE
- In streaming mode, not all responses include a reference, as this depends on the system's judgement.
- In streaming mode, the last message is an empty message:
Request#
- Method: POST
- URL:
/api/v1/chats/{chat_id}/completions - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"question":string"stream":boolean"session_id":string(optional)"user_id:string(optional)
Request example#
Request Parameters#
chat_id: (Path parameter)
The ID of the associated chat assistant."question": (Body Parameter),string, Required
The question to start an AI-powered conversation."stream": (Body Parameter),boolean
Indicates whether to output responses in a streaming way:true: Enable streaming (default).false: Disable streaming.
"session_id": (Body Parameter)
The ID of session. If it is not provided, a new session will be generated."user_id": (Body parameter),string
The optional user-defined ID. Valid only when nosession_idis provided.
Response#
Success without session_id:
Success with session_id:
Failure:
Create session with agent#
POST /api/v1/agents/{agent_id}/sessions
Creates a session with an agent.
Request#
- Method: POST
- URL:
/api/v1/agents/{agent_id}/sessions?user_id={user_id} - Headers:
'content-Type: application/json' or 'multipart/form-data''Authorization: Bearer <YOUR_API_KEY>'
- Body:
- the required parameters:
str - other parameters: The parameters specified in the Begin component.
- the required parameters:
Request example#
If the Begin component in your agent does not take required parameters:
If the Begin component in your agent takes required parameters:
If the Begin component in your agent takes required file parameters:
Request parameters#
agent_id: (Path parameter)
The ID of the associated agent.user_id: (Filter parameter) The optional user-defined ID for parsing docs (especially images) when creating a session while uploading files.
Response#
Success:
Failure:
Converse with agent#
POST /api/v1/agents/{agent_id}/completions
Asks a specified agent a question to start an AI-powered conversation.
NOTE
- In streaming mode, not all responses include a reference, as this depends on the system's judgement.
- In streaming mode, the last message is an empty message:
Request#
- Method: POST
- URL:
/api/v1/agents/{agent_id}/completions - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"question":string"stream":boolean"session_id":string"user_id":string(optional)"sync_dsl":boolean(optional)- other parameters:
string
Request example#
If the Begin component does not take parameters, the following code will create a session.
If the Begin component takes parameters, the following code will create a session.
The following code will execute the completion process
Request Parameters#
agent_id: (Path parameter),string
The ID of the associated agent."question": (Body Parameter),string, Required
The question to start an AI-powered conversation."stream": (Body Parameter),boolean
Indicates whether to output responses in a streaming way:true: Enable streaming (default).false: Disable streaming.
"session_id": (Body Parameter)
The ID of the session. If it is not provided, a new session will be generated."user_id": (Body parameter),string
The optional user-defined ID. Valid only when nosession_idis provided."sync_dsl": (Body parameter),booleanWhether to synchronize the changes to existing sessions when an agent is modified, defaults tofalse.- Other parameters: (Body Parameter)
Parameters specified in the Begin component.
Response#
success without session_id provided and with no parameters specified in the Begin component:
Success without session_id provided and with parameters specified in the Begin component:
Success with parameters specified in the Begin component:
Failure:
List agent sessions#
GET /api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id}&user_id={user_id}&dsl={dsl}
Lists sessions associated with a specified agent.
Request#
- Method: GET
- URL:
/api/v1/agents/{agent_id}/sessions?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&id={session_id} - Headers:
'Authorization: Bearer <YOUR_API_KEY>'
Request example#
Request Parameters#
agent_id: (Path parameter)
The ID of the associated agent.page: (Filter parameter),integer
Specifies the page on which the sessions will be displayed. Defaults to1.page_size: (Filter parameter),integer
The number of sessions on each page. Defaults to30.orderby: (Filter parameter),string
The field by which sessions should be sorted. Available options:create_time(default)update_time
desc: (Filter parameter),boolean
Indicates whether the retrieved sessions should be sorted in descending order. Defaults totrue.id: (Filter parameter),string
The ID of the agent session to retrieve.user_id: (Filter parameter),string
The optional user-defined ID passed in when creating session.dsl: (Filter parameter),boolean
Indicates whether to include the dsl field of the sessions in the response. Defaults totrue.
Response#
Success:
Failure:
Delete agent's sessions#
DELETE /api/v1/agents/{agent_id}/sessions
Deletes sessions of a agent by ID.
Request#
- Method: DELETE
- URL:
/api/v1/agents/{agent_id}/sessions - Headers:
'content-Type: application/json''Authorization: Bearer <YOUR_API_KEY>'
- Body:
"ids":list[string]
Request example#
Request Parameters#
agent_id: (Path parameter)
The ID of the associated agent."ids": (Body Parameter),list[string]
The IDs of the sessions to delete. If it is not specified, all sessions associated with the specified agent will be deleted.
Response#
Success:
Failure:
AGENT MANAGEMENT#
List agents#
GET /api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id}
Lists agents.
Request#
- Method: GET
- URL:
/api/v1/agents?page={page}&page_size={page_size}&orderby={orderby}&desc={desc}&name={agent_name}&id={agent_id} - Headers:
'Authorization: Bearer <YOUR_API_KEY>'
Request example#
Request parameters#
page: (Filter parameter),integer
Specifies the page on which the agents will be displayed. Defaults to1.page_size: (Filter parameter),integer
The number of agents on each page. Defaults to30.orderby: (Filter parameter),string
The attribute by which the results are sorted. Available options:create_time(default)update_time
desc: (Filter parameter),boolean
Indicates whether the retrieved agents should be sorted in descending order. Defaults totrue.id: (Filter parameter),string
The ID of the agent to retrieve.name: (Filter parameter),string
The name of the agent to retrieve.
Response#
Success:
Failure: