API

Prediction API

  • POST /api/v1/prediction/{your-chatflowid}

Request Body

Key
Description
Type
Required

question

User's question

string

Yes

overrideConfig

Override existing flow configuration

object

No

history

Provide list of history messages to the flow. Only works when using Short Term Memory

array

No

You can use the chatflow as API and connect to frontend applications.

You also have the flexibility to override input configuration with overrideConfig property.

import requests

API_URL = "http://localhost:3000/api/v1/prediction/<chatlfowid>"

def query(payload):
    response = requests.post(API_URL, json=payload)
    return response.json()
    
output = query({
    "question": "Hey, how are you?",
    "overrideConfig": {
        "returnSourceDocuments": true
    },
    "history": [
        {
            "message": "Hello, how can I assist you?",
            "type": "apiMessage"
        },
        {
            "type": "userMessage",
            "message": "Hello I am Bob"
        },
        {
            "type": "apiMessage",
            "message": "Hello Bob! how can I assist you?"
        }
    ]
})

Vector Upsert API

  • POST /api/v1/vector/upsert/{your-chatflowid}

Request Body

Key
Description
Type
Required

overrideConfig

Override existing flow configuration

object

No

stopNodeId

Node ID of the vector store. When you have multiple vector stores in a flow, you might not want to upsert all of them. Specifying stopNodeId will ensure only that specific vector store node is upserted.

array

No

Document Loaders with Upload

Some document loaders in Flowise allow user to upload files:

If the flow contains Document Loaders with Upload File functionality, the API looks slightly different. Instead of passing body as JSON, form-data is being used. This allows you to upload any files to the API.

It is user's responsibility to make sure the file type is compatible with the expected file type from document loader. For example, if a Text File Loader is being used, you should only upload file with .txt extension.

import requests

API_URL = "http://localhost:3000/api/v1/vector/upsert/<chatlfowid>"

# use form data to upload files
form_data = {
    "files": ('state_of_the_union.txt', open('state_of_the_union.txt', 'rb'))
}

body_data = {
    "returnSourceDocuments": True
}

def query(form_data):
    response = requests.post(API_URL, files=form_data, data=body_data)
    print(response)
    return response.json()

output = query(form_data)
print(output)

Document Loaders without Upload

For other Document Loaders nodes without Upload File functionality, the API body is in JSON format similar to Prediction API.

Message API

  • GET /api/v1/chatmessage/{your-chatflowid}

  • DELETE /api/v1/chatmessage/{your-chatflowid}

Query Parameters

Param
Type
Value

sessionId

string

sort

enum

ASC or DESC

startDate

string

endDate

string

Tutorials

  • How to use LangFlux API

  • How to use LangFlux API and connect to Bubble

Last updated

Was this helpful?