Skip to content

The conversation interface is compatible with the OpenAI model interface. For details, please refer to: OpenAI API

Ask
  • Example:
curl
curl --location --request POST 'https://AIgotowork.com/api/v1/chat/completions' \
--header 'Authorization: Bearer fastgpt-xxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "chatId": "asdfadsfasfd2323",
    "stream": false,
    "detail": false,
    "variables": {
        "uid": "asdfadsfasfd2323",
        "name": "joshua"
    },
    "messages": [
        {
            "content": "Who are you?",
            "role": "user"
        }
    ]
}'
  • Param Description:
ParamTypeRequiredDescription
chatIdstringyes* When it is undefined (not passed in), the context function is not used and the context is built entirely from the messages passed in. Your records will not be stored in the database, and you will not be able to view them in the record summary. When it is a non-empty string, it means using the chatId to conduct the conversation, automatically fetching the history records from the database, and using the last content of the messages array as the user question. Please ensure that the chatId is unique and the length is less than 250. It can usually be the dialog ID of your own system.
streambooleannoWhether to return in streaming format, the default is false. When false, a json object containing messages will be returned.
detailbooleannoWhether to return detailed information, the default is false. In stream mode, it will be distinguished by event, and the result of non-stream mode is saved in responseData
variablesobjectnoModule variable, an object, will replace the content of the input box in the module.{{key}}
messagesarrayyesMessage array, each element is an object, including content and role. content is the content, role is the role, and the structure is consistent with the OpenAI API chat mode.
Response
  • Example:
json
{
    "id": "asdfadsfasfd2323",
    "model": "",
    "usage": {
        "prompt_tokens": 1,
        "completion_tokens": 23,
        "total_tokens": 121
    },
    "choices": [
        {
            "message": {
                "role": "assistant",
                "content": "Hello! My name is AIgotowork, it is an AIGC application system based on a private knowledge base"
            },
            "finish_reason": "stop",
            "index": 0
        }
    ]
}