Chat API

Integrate AI-powered chat capabilities into your applications using our Chat API endpoints.

Authentication

All API requests require authentication using your API key. You can find your API key in your account settings .

Chat API

POST https://filebrain.pro/api/chat/v1/

Request Parameters

Parameter Type Required Description
project_id string Yes Your project identifier
api_key string Yes Your secret API key
query string Yes The user's question or message
session_id string No Unique identifier for maintaining conversation context
prompt string No Custom prompt to override the default project prompt
tags array No List of tags for filtering knowledge base content
human_assist boolean No Flag to request human assistance

Request Example

{
  "project_id": "c3da8368c929732212329e868bcd3393",
  "api_key": "",
  "query": "This is my user question",
  "session_id": "optional_unique_user_token",
  "prompt": "optional_custom_prompt",
  "tags": ["optional", "tags", "list"],
  "human_assist": false
}

Response Format

{
  "status": "success",
  "message": {
    "question": "user_question",
    "answer": "response_to_the_question",
    "source": ["Optional_array_of_sources"]
  },
  "execution_time": 0.5,
  "call_cost": 1,
  "total_tokens": 150
}

Human Assist Response

{
  "status": "success",
  "message": {
    "question": "user_question",
    "answer": "Human assistance requested",
    "source": []
  },
  "execution_time": 0,
  "call_cost": 0,
  "total_tokens": 0
}

Code Examples

import requests

API_URL = "https://filebrain.pro/api/chat/v1/"
headers = {"Content-Type": "application/json"}

payload = {
    "project_id": "YOUR-PROJECT-ID",
    "api_key": "YOUR-API-KEY",
    "query": "Hello, FileBrain!",
    "session_id": "unique_session_id",
    "prompt": "optional_custom_prompt",
    "tags": ["tag1", "tag2"],
    "human_assist": False
}

response = requests.post(API_URL, json=payload, headers=headers)

if response.status_code == 200:
    data = response.json()
    if data.get("status") == "success":
        answer = data["message"]["answer"]
        print(answer)
    else:
        print("Error:", data.get("message", "Unknown error"))
else:
    print("Failed to reach the server.")
const API_URL = 'https://filebrain.pro/api/chat/v1/';

const payload = {
    project_id: 'YOUR-PROJECT-ID',
    api_key: 'YOUR-API-KEY',
    query: 'Hello, FileBrain!',
    session_id: 'unique_session_id',
    prompt: 'optional_custom_prompt',
    tags: ['tag1', 'tag2'],
    human_assist: false
};

async function chatWithFileBrain() {
    try {
        const response = await fetch(API_URL, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify(payload)
        });

        const data = await response.json();
        
        if (data.status === 'success') {
            console.log(data.message.answer);
        } else {
            console.error('Error:', data.message);
        }
    } catch (error) {
        console.error('Failed to reach the server:', error);
    }
}
curl -X POST https://filebrain.pro/api/chat/v1/ \
    -H "Content-Type: application/json" \
    -d '{
        "project_id": "YOUR-PROJECT-ID",
        "api_key": "YOUR-API-KEY",
        "query": "Hello, FileBrain!",
        "session_id": "unique_session_id",
        "prompt": "optional_custom_prompt",
        "tags": ["tag1", "tag2"],
        "human_assist": false
    }'