Skip to content

Chat AI

Conversational AI over the organisation's configured language models, with optional grounding in the user's documents. This is the API behind the Chat AI module.

Model of a conversation

  • A session (/sessions/) is a conversation thread. Every module that has a chat (Chat AI, document chat, database chat…) stores its threads in the same session table, distinguished by type.
  • A message is stored with POST /secure-gpt/store/ (one call for the user's prompt, one for the assistant's reply) and read back with GET /sessions/{id}/fetch/.
  • The assistant's reply is produced by a streaming endpoint (POST /secure-gpt/chat/ and the document-chat variants). These return text/event-stream-style chunked text rather than JSON — see Streaming & WebSockets.

End-to-end encryption

The web app encrypts every stored message on the client with the user's data encryption key (DEK) before calling store/, and marks the row is_encrypted: true. The DEK never leaves the browser in the clear, except transiently over TLS for the LLM call.

API clients that do not hold the user's DEK can store plaintext messages by sending is_encrypted: false (the default). Such rows are readable through the API, and the web app converts them to encrypted rows the next time that user signs in. The reverse is not possible: encrypted messages fetched through the API are opaque ciphertext (base64(nonce ‖ ciphertext ‖ tag), AES-256-GCM) without the DEK.

Endpoints

MethodPathPurpose
POST/microservices/agent/chat/Send a message to the assistant
GET/sessions/List my conversations
POST/sessions/Create a conversation
GET/sessions/{id}/Get a conversation
PUT/sessions/{id}/Rename or re-bind a conversation
DELETE/sessions/{id}/Delete a conversation
GET/sessions/{id}/delete-impact/What deleting a conversation removes
GET/sessions/{id}/fetch/Messages of a conversation
POST/secure-gpt/store/Store a message
GET/secure-gpt/All my Chat AI messages
POST/secure-gpt/generate-title/Generate a title for a conversation
POST/secure-gpt/rewrite/Rewrite text in a tone
POST/secure-gpt/category/Classify a question into a role category
POST/secure-gpt/chat/Stream a model reply (direct, no agent)
POST/semantic-search/single-file-chat/Chat with one document
POST/semantic-search/multi-file-chat/Chat with several documents
POST/semantic-search/all-files-chat/Chat across all my documents
POST/semantic-search/advanced-search/Chat with one document using its summary (advanced)
POST/semantic-search/doc-from-chunks/Full text of a document
POST/semantic-search/chat/Chat with documents by file name (legacy)
POST/semantic-search/store/Store a document-chat message
GET/semantic-search/All my document-chat messages

POST /microservices/agent/chat/

Send a message to the assistant

One turn of a Chat AI conversation. The request is synchronous: it returns when the agent has finished (typically 5–60 s; up to the timeout you pass when the agent uses tools such as web search, document generation or dashboard building).

Conversations are identified by a client-chosen conversation_id (the app uses a UUID per thread). The first authenticated caller to use an id owns it; other users get 403. All conversation state lives on the agent side, keyed by this id, so nothing else needs to be sent to continue a thread.

Progress while the turn runs is available on the WebSocket ws/chat/{conversation_id} (stage events, tool calls, streamed partial answer). See Streaming & WebSockets. The HTTP response remains the authoritative answer, except when the response is 504 or status: queued — the agent keeps working and the final answer is delivered over the socket and, when chat_session_id was given, persisted into the session history.

Attachments. Files from My Data can be attached to the turn with attached_files; send the current selection on every turn (an explicit [] clears it). Extracted-table databases (tables_database_ids) and connected SQL tables (database_tables) work the same way.

Skills. active_skill pins the agent to one skill (a saved procedure — see Workflow assistant → skills); send null to unlock. Unknown skill names return 404.

The server sets username, organization_name, user_id, base_url, media_root and callback_token itself — values you send for those are ignored.

Auth: Session token · In the app: Chat AI (every message)

Query parameters

FieldTypeRequiredDescription
timeoutintegernoSeconds to wait for the agent before answering 504. The app uses 300. Default: 600.

Request body (application/json)

FieldTypeRequiredDescription
conversation_idstringyesClient-chosen thread id (UUID recommended). Stable for the life of the conversation.
messagestringyesThe user's message.
chat_session_idintegernoId of a sessions/ row owned by the caller. Binds dashboards and the persisted answer to that thread.
reasoning_effortstring ("minimal", "low", "medium", "high", "xhigh", "none")noThinking level for this turn. Invalid values fall back to the user's saved default (medium).
active_skillstring, nullablenoSkill name to run in, or null to unlock. Only needed on the first turn or when it changes.
use_skillsbooleannoSet to true alongside active_skill.
attached_filesobject[]noFiles from My Data to ground this turn.
attached_files[].uidstring (uuid)noDocument uid.
attached_files[].namestringnoFile name.
attached_files[].endpointstring ("semantic-search", "database-search")noWhich store the file lives in.
tables_database_idsstring[]noExtracted-table database ids to expose to the agent.
database_tablesobject[]noConnected SQL tables (from My Data → Data sources).
database_tables[].db_idintegernoData source id.
database_tables[].table_idstringnoTable name.
tool_paramsobjectnoPer-tool parameter overrides (advanced). File paths inside are validated against the caller's own media tree.
json
{
  "conversation_id": "0f3c9a1e-5d2b-4c7e-8a9f-6b1d2e3f4a5b",
  "message": "What was Q3 revenue growth year over year?",
  "chat_session_id": 9174,
  "reasoning_effort": "medium",
  "attached_files": [
    {
      "uid": "1b6c1c1e-9d0a-4b6e-9f2a-3c4d5e6f7a8b",
      "name": "Q3-report.pdf",
      "endpoint": "semantic-search"
    }
  ]
}

Response 200 — The agent's reply (proxied verbatim from the agent service; the status code is the agent's).

FieldTypeDescription
statusstringcompletedanswer holds the reply. queued — the turn is queued behind another one; the reply will arrive on the ws/chat/{conversation_id} socket. missing_param, clarification, interrupted — the agent needs input; the question is in message.
answerstringThe reply (Markdown).
messagestringThe agent's question when it needs input.
turn_idstring
queue_positioninteger
mgidstringPresent when the turn produced a dashboard chart (fetch it with GET /microservices/dashboard-data/?mgid=).
dashboard_idstringPresent when the turn published a Studio artifact.
generated_files_urlsstring[]Media URLs of files the turn produced (documents, images). Sign them to download.
json
{
  "status": "completed",
  "turn_id": "7c1f0c1e-2b8f-4a6e-9c0a-1e4b6f2d3a55",
  "answer": "Q3 revenue grew **12.4% year over year**, driven by the enterprise segment (+19%) …\n",
  "generated_files_urls": []
}

Response 400 — Missing conversation_id/message, a file reference outside your media tree, or an invalid chat_session_id.

json
{
  "error": "conversation_id is required"
}

Response 403 — The conversation (or chat_session_id) belongs to another user.

json
{
  "error": "This conversation belongs to another user."
}

Response 404 — The agent service is not registered, or active_skill names an unknown skill.

json
{
  "error": "path is required"
}

Response 409 — A newer turn on the same conversation superseded this one. Drop this response.

Response 502 — The agent service could not be reached.

json
{
  "error": "path is required"
}

Response 504 — The agent did not finish within timeout. The turn is still running; the answer arrives on the socket / in the session history. Do not resend.

json
{
  "error": "super agent /chat timed out"
}

Example

bash
curl -X POST "https://api.example.com/microservices/agent/chat/?timeout=300" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
        "conversation_id": "0f3c9a1e-5d2b-4c7e-8a9f-6b1d2e3f4a5b",
        "message": "Summarise the attached report in five bullets",
        "attached_files": [{"uid": "1b6c1c1e-9d0a-4b6e-9f2a-3c4d5e6f7a8b", "name": "Q3-report.pdf", "endpoint": "semantic-search"}]
      }'

GET /sessions/

List my conversations

Newest activity first is the app's sort; the API returns rows unsorted with last_activity for you to sort on.

Auth: Session token · In the app: Chat sidebar (all modules with a chat)

Query parameters

FieldTypeRequiredDescription
typestringnoOnly threads of this type.
artifact_idstringnoOnly the Studio thread bound to this artifact.

Response 200 — Sessions.

Array of:

FieldTypeDescription
idinteger
userintegerOwner id.
typestringWhich module the thread belongs to. Values in use: chatai_general, chatai_enterprise (Chat AI), dedicated-agent, studio, app, dashboard, semantic_search (document chat), database_search, workflow, template_session.
titlestringShown in the sidebar. The web app stores it encrypted for Chat AI threads.
querystring, nullableFree-form JSON/text the module attaches (e.g. saved chart config).
workflow_idstring (uuid), nullableFor app threads, the workflow the app runs.
version_idinteger, nullableWorkflow version used by an app thread.
artifact_idstring, nullableFor studio threads, the artifact the conversation built.
created_atstring (date-time)
last_activitystring (date-time)Timestamp of the newest message (or created_at).

Example

bash
curl -X GET "https://api.example.com/sessions/?type=chatai_general" \
  -H "Authorization: Token $FINBLADE_TOKEN"

POST /sessions/

Create a conversation

Auth: Session token · In the app: "New chat" in every module

Request body (application/json)

FieldTypeRequiredDescription
typestringyesSee ChatSession.type.
titlestringyes
querystringno
workflow_idstring (uuid)no
version_idintegerno
artifact_idstringno
json
{
  "type": "chatai_general",
  "title": "New chat"
}

Response 201 — Created.

FieldTypeDescription
idinteger
userintegerOwner id.
typestringWhich module the thread belongs to. Values in use: chatai_general, chatai_enterprise (Chat AI), dedicated-agent, studio, app, dashboard, semantic_search (document chat), database_search, workflow, template_session.
titlestringShown in the sidebar. The web app stores it encrypted for Chat AI threads.
querystring, nullableFree-form JSON/text the module attaches (e.g. saved chart config).
workflow_idstring (uuid), nullableFor app threads, the workflow the app runs.
version_idinteger, nullableWorkflow version used by an app thread.
artifact_idstring, nullableFor studio threads, the artifact the conversation built.
created_atstring (date-time)
last_activitystring (date-time)Timestamp of the newest message (or created_at).
json
{
  "id": 9174,
  "user": 42,
  "type": "chatai_general",
  "title": "Q3 revenue questions",
  "query": null,
  "workflow_id": null,
  "version_id": null,
  "artifact_id": null,
  "created_at": "2026-09-21T11:03:15.402Z",
  "last_activity": "2026-09-22T06:48:10.010Z"
}

Response 400 — Validation errors.

json
{
  "title": [
    "This field is required."
  ]
}

Example

bash
curl -X POST "https://api.example.com/sessions/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"type":"chatai_general","title":"New chat"}'

GET /sessions/{id}/

Get a conversation

Auth: Session token

Path parameters

FieldTypeRequiredDescription
idintegeryes

Response 200 — The session.

FieldTypeDescription
idinteger
userintegerOwner id.
typestringWhich module the thread belongs to. Values in use: chatai_general, chatai_enterprise (Chat AI), dedicated-agent, studio, app, dashboard, semantic_search (document chat), database_search, workflow, template_session.
titlestringShown in the sidebar. The web app stores it encrypted for Chat AI threads.
querystring, nullableFree-form JSON/text the module attaches (e.g. saved chart config).
workflow_idstring (uuid), nullableFor app threads, the workflow the app runs.
version_idinteger, nullableWorkflow version used by an app thread.
artifact_idstring, nullableFor studio threads, the artifact the conversation built.
created_atstring (date-time)
last_activitystring (date-time)Timestamp of the newest message (or created_at).
json
{
  "id": 9174,
  "user": 42,
  "type": "chatai_general",
  "title": "Q3 revenue questions",
  "query": null,
  "workflow_id": null,
  "version_id": null,
  "artifact_id": null,
  "created_at": "2026-09-21T11:03:15.402Z",
  "last_activity": "2026-09-22T06:48:10.010Z"
}

Response 404 — Not found or not yours.

json
{
  "detail": "Authentication credentials were not provided."
}

Example

bash
curl -X GET "https://api.example.com/sessions/9174/" \
  -H "Authorization: Token $FINBLADE_TOKEN"

PUT /sessions/{id}/

Rename or re-bind a conversation

Partial update of title, query, workflow_id, version_id, artifact_id.

Auth: Session token · In the app: Rename chat; auto-title after the first reply

Path parameters

FieldTypeRequiredDescription
idintegeryes

Request body (application/json)

FieldTypeRequiredDescription
titlestringno
querystringno
workflow_idstring (uuid)no
version_idintegerno
artifact_idstringno
json
{
  "title": "Q3 revenue questions"
}

Response 200 — The updatable fields after the change.

FieldTypeDescription
sessionobject
session.titlestring
session.querystring, nullable
session.workflow_idstring, nullable
session.version_idinteger, nullable
session.artifact_idstring, nullable
json
{
  "session": {
    "title": "Q3 revenue questions",
    "query": null,
    "workflow_id": null,
    "version_id": null,
    "artifact_id": null
  }
}

Response 404 — Not found or not yours.

json
{
  "detail": "Authentication credentials were not provided."
}

Example

bash
curl -X PUT "https://api.example.com/sessions/9174/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"Q3 revenue questions"}'

DELETE /sessions/{id}/

Delete a conversation

Deletes the thread, its messages, and the dashboards, generated files and chart rows the conversation created. Check the impact first with delete-impact/.

Auth: Session token · In the app: Chat sidebar → Delete

Path parameters

FieldTypeRequiredDescription
idintegeryes

Response 204 — Deleted.

Response 404 — Not found or not yours.

json
{
  "detail": "Authentication credentials were not provided."
}

Example

bash
curl -X DELETE "https://api.example.com/sessions/9174/" \
  -H "Authorization: Token $FINBLADE_TOKEN"

GET /sessions/{id}/delete-impact/

What deleting a conversation removes

Auth: Session token · In the app: Delete-chat confirmation dialog

Path parameters

FieldTypeRequiredDescription
idintegeryes

Response 200 — Impact report.

FieldTypeDescription
sessionobject
session.idinteger
session.titlestring
session.typestring
messagesinteger
artifactsobject
artifacts.countinteger
artifacts.bytesinteger
artifacts.samplestring[]
chartsobject
charts.countinteger
charts.samplestring[]
json
{
  "session": {
    "id": 9174,
    "title": "Q3 revenue questions",
    "type": "chatai_general"
  },
  "messages": 14,
  "artifacts": {
    "count": 1,
    "bytes": 48213,
    "sample": [
      "Q3 revenue dashboard"
    ]
  },
  "charts": {
    "count": 0,
    "sample": []
  }
}

Example

bash
curl -X GET "https://api.example.com/sessions/9174/delete-impact/" \
  -H "Authorization: Token $FINBLADE_TOKEN"

GET /sessions/{id}/fetch/

Messages of a conversation

Returns the thread's messages in insertion order. The row shape depends on the session type: Chat AI / Studio / app / dashboard / dedicated-agent threads return SecureChatMessage rows; semantic_search returns SemanticChatMessage rows; database_search returns rows with images and csv_files; template_session returns the session object itself.

Auth: Session token · In the app: Opening a chat

Path parameters

FieldTypeRequiredDescription
idintegeryes

Response 200 — Messages.

Array of:

FieldTypeDescription
idinteger
userinteger
sessioninteger, nullable
messagestringPlaintext, or ciphertext when is_encrypted is true.
is_encryptedboolean
from_serverbooleantrue for assistant replies, false for the user's prompts.
tonestring"True" when the message came from the rewrite-by-tone feature.
rewriteboolean
created_atstring (date-time)
json
[
  {
    "id": 5510,
    "user": 42,
    "session": 9174,
    "message": "What was Q3 revenue growth year over year?",
    "is_encrypted": false,
    "from_server": false,
    "tone": "",
    "rewrite": false,
    "created_at": "2026-09-22T06:47:58.120Z"
  },
  {
    "id": 5511,
    "user": 42,
    "session": 9174,
    "message": "Q3 revenue grew **12.4%** year over year…",
    "is_encrypted": false,
    "from_server": true,
    "tone": "",
    "rewrite": false,
    "created_at": "2026-09-22T06:48:10.010Z"
  }
]

Response 404 — Not found or not yours.

json
{
  "detail": "Authentication credentials were not provided."
}

Example

bash
curl -X GET "https://api.example.com/sessions/9174/fetch/" \
  -H "Authorization: Token $FINBLADE_TOKEN"

POST /secure-gpt/store/

Store a message

Appends one message to a Chat AI thread. The app calls it twice per turn: once for the user's prompt (user_message: true) and once for the assistant's reply. Bodies may be sent as JSON or as form fields.

Auth: Session token · In the app: After every message and reply

Request body (application/json)

FieldTypeRequiredDescription
responsestringyesThe message text (ciphertext when is_encrypted).
sessionintegernoSession id. Omit to store an unthreaded message.
user_messagebooleannotrue for the user's own prompt; omit/false for an assistant reply.
is_encryptedbooleannoDefault: false.
tonestringnoAny value marks the message as a tone rewrite.
rewritestringnoAny value marks the message as a rewrite.
json
{
  "session": 9174,
  "response": "What was Q3 revenue growth year over year?",
  "user_message": true
}

Response 200 — Stored. The body is the literal string "stored".

json
"stored"

Example

bash
curl -X POST "https://api.example.com/secure-gpt/store/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"session":9174,"response":"What was Q3 revenue growth year over year?","user_message":true}'

GET /secure-gpt/

All my Chat AI messages

Every stored Chat AI message of the user across sessions. Prefer sessions/{id}/fetch/ for one thread.

Auth: Session token

Response 200 — Messages.

Array of:

FieldTypeDescription
idinteger
userinteger
sessioninteger, nullable
messagestringPlaintext, or ciphertext when is_encrypted is true.
is_encryptedboolean
from_serverbooleantrue for assistant replies, false for the user's prompts.
tonestring"True" when the message came from the rewrite-by-tone feature.
rewriteboolean
created_atstring (date-time)

Example

bash
curl -X GET "https://api.example.com/secure-gpt/" \
  -H "Authorization: Token $FINBLADE_TOKEN"

POST /secure-gpt/generate-title/

Generate a title for a conversation

Asks the user's model for a short title based on the first exchange. The app then saves it with PUT /sessions/{id}/.

Auth: Session token · In the app: Automatic after the first reply

Request body (application/json)

FieldTypeRequiredDescription
contextstringyesJSON-encoded array of the messages to summarise ([{"message": "...", "from_server": false}, …]).
json
{
  "context": "[{\"message\":\"What was Q3 revenue growth year over year?\",\"from_server\":false},{\"message\":\"Q3 revenue grew 12.4%…\",\"from_server\":true}]"
}

Response 200 — Title.

FieldTypeDescription
titlestring
json
{
  "title": "Q3 revenue growth"
}

Example

bash
curl -X POST "https://api.example.com/secure-gpt/generate-title/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"context":"[{\"message\":\"What was Q3 revenue growth year over year?\",\"from_server\":false},{\"message\":\"Q3 revenue grew 12.4%…\",\"from_server\":true}]"}'

POST /secure-gpt/rewrite/

Rewrite text in a tone

Rewrites content using the user's model. tone is free text such as formal, friendly, shorter or modify.

Auth: Session token · In the app: Message actions → Rewrite

Request body (application/json)

FieldTypeRequiredDescription
contentstringyes
tonestringyes
sessionintegernoOptional; must be the caller's.
json
{
  "content": "pls send the report asap",
  "tone": "formal"
}

Response 200 — Rewritten text.

FieldTypeDescription
responsestring
json
{
  "response": "Could you please send the report at your earliest convenience?"
}

Example

bash
curl -X POST "https://api.example.com/secure-gpt/rewrite/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"pls send the report asap","tone":"formal"}'

POST /secure-gpt/category/

Classify a question into a role category

Used by the enterprise chat mode to decide which role-restricted documents may answer a question. Returns the category name as produced by the classifier.

Auth: Session token

Request body (application/json)

FieldTypeRequiredDescription
questionstringyes
json
{
  "question": "What is our travel reimbursement limit?"
}

Response 200 — Category.

FieldTypeDescription
categorystring
json
{
  "category": "HR"
}

Example

bash
curl -X POST "https://api.example.com/secure-gpt/category/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"question":"What is our travel reimbursement limit?"}'

POST /secure-gpt/chat/

Stream a model reply (direct, no agent)

A plain model completion without the agent's tools, streamed as it is generated. This is the engine behind the enterprise chat mode and older app flows; the Chat AI page itself uses POST /microservices/agent/chat/.

type selects the mode:

  • general — answer from the model only.
  • app — same as general (used by published apps).
  • enterprise — classify the question into a role category, refuse if the user lacks that role, otherwise answer from the organisation's documents tagged with that role. The user's prompt is stored automatically in this mode.

The response body is the answer text streamed in chunks (content type text/event-stream, but not SSE-framed — concatenate the chunks). See Streaming & WebSockets.

Auth: Session token · In the app: Enterprise chat mode

Request body (application/json)

FieldTypeRequiredDescription
questionstringyes
typestring ("general", "app", "enterprise")noDefault: "general".
sessionintegernoSession id (must be the caller's).
chat_historystringnoJSON-encoded array of prior messages [{"message": "...", "from_server": false}, …].
thinkingbooleannoAccepted for compatibility; ignored.
json
{
  "question": "Explain net revenue retention in one paragraph.",
  "type": "general",
  "session": 9174,
  "chat_history": "[]"
}

Response 200 — Streamed answer text.

Content type: text/event-stream

text
Net revenue retention (NRR) measures how much recurring revenue from existing customers…

Response 400question missing.

json
{
  "error": "Question is required"
}

Example

bash
curl -X POST "https://api.example.com/secure-gpt/chat/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"question":"Explain net revenue retention in one paragraph.","type":"general","session":9174,"chat_history":"[]"}'

POST /semantic-search/single-file-chat/

Chat with one document

Retrieval-augmented answer over a single document in the semantic-search store. Streams the answer text. The stream starts with a JSON array of sources ([["Q3-report.pdf", 3, 7], …] — file name, page, chunk), immediately followed by the answer text. Bracket-match the array to split the two.

Bodies may be JSON or multipart form fields (the app sends form fields).

Auth: Session token · In the app: My Data → Chat with a selected document

Request body (application/json)

FieldTypeRequiredDescription
querystringyes
document_namestringyesFile name of the document.
file_uidstring (uuid)noDocument uid.
chat_historyobject[]noPrior turns (a JSON-encoded string is also accepted).
chat_history[].HumanMessagestringnoA user turn.
chat_history[].AIMessagestringnoAn assistant turn.
json
{
  "query": "What are the key risks listed?",
  "document_name": "Q3-report.pdf",
  "file_uid": "1b6c1c1e-9d0a-4b6e-9f2a-3c4d5e6f7a8b",
  "chat_history": []
}

Response 200 — Sources array followed by streamed answer text.

Content type: text/event-stream

text
[["Q3-report.pdf", 12, 3], ["Q3-report.pdf", 13, 1]]The report lists three key risks: …

Response 400 — Missing fields.

json
{
  "detail": "document_name and query are required"
}

Example

bash
curl -X POST "https://api.example.com/semantic-search/single-file-chat/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query":"What are the key risks listed?","document_name":"Q3-report.pdf","file_uid":"1b6c1c1e-9d0a-4b6e-9f2a-3c4d5e6f7a8b","chat_history":[]}'

POST /semantic-search/multi-file-chat/

Chat with several documents

Same contract as single-file chat, over a list of document uids. The stream begins with the sources array, then the answer.

Auth: Session token · In the app: My Data → Chat with several selected documents

Request body (application/json)

FieldTypeRequiredDescription
querystringyes
files_liststring (uuid)[]yesDocument uids (a JSON-encoded string is also accepted). Must be non-empty.
chat_historyobject[]no
chat_history[].HumanMessagestringnoA user turn.
chat_history[].AIMessagestringnoAn assistant turn.
json
{
  "query": "Compare the two proposals' pricing.",
  "files_list": [
    "1b6c1c1e-9d0a-4b6e-9f2a-3c4d5e6f7a8b",
    "2c7d2d2f-0e1b-4c7f-8a3b-4d5e6f7a8b9c"
  ]
}

Response 200 — Sources array followed by streamed answer text.

Content type: text/event-stream

Response 400files_list missing, empty, or not a JSON array.

json
{
  "detail": "Authentication credentials were not provided."
}

Example

bash
curl -X POST "https://api.example.com/semantic-search/multi-file-chat/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query":"Compare the two proposals' pricing.","files_list":["1b6c1c1e-9d0a-4b6e-9f2a-3c4d5e6f7a8b","2c7d2d2f-0e1b-4c7f-8a3b-4d5e6f7a8b9c"]}'

POST /semantic-search/all-files-chat/

Chat across all my documents

Retrieval over the user's whole indexed corpus. The stream begins with a JSON array of the source file paths, a || delimiter, then the answer: ["/media/Acme/semantic-search/jane/Q3-report.pdf"]||The report….

Auth: Session token · In the app: My Data → Chat → "All files"

Request body (application/json)

FieldTypeRequiredDescription
querystringyes
chat_historyobject[]no
chat_history[].HumanMessagestringnoA user turn.
chat_history[].AIMessagestringnoAn assistant turn.
deep_searchbooleannoAccepted for compatibility. Default: false.
limitintegernoAccepted for compatibility (number of chunks).
json
{
  "query": "Which contracts renew in December?"
}

Response 200 — Source paths, \|\|, then streamed answer text.

Content type: text/event-stream

text
["/media/Acme/semantic-search/jane/MSA-Globex.pdf"]||Two contracts renew in December: …

Response 400query missing.

json
{
  "error": "Query is required."
}

Example

bash
curl -X POST "https://api.example.com/semantic-search/all-files-chat/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query":"Which contracts renew in December?"}'

POST /semantic-search/advanced-search/

Chat with one document using its summary (advanced)

Variant of single-file chat that also feeds the document's stored summary to the model and filters retrieval by a similarity threshold. Streams the answer text.

Auth: Session token

Request body (application/json)

FieldTypeRequiredDescription
querystringyes
file_uuidstring (uuid)yes
thresholdnumberyesMinimum similarity score for a chunk to be used (0–1).
languagestring ("english", "arabic")noWhich stored summary to use.
chat_historyobject[]no
chat_history[].HumanMessagestringnoA user turn.
chat_history[].AIMessagestringnoAn assistant turn.
json
{
  "query": "Summarise the payment terms.",
  "file_uuid": "1b6c1c1e-9d0a-4b6e-9f2a-3c4d5e6f7a8b",
  "threshold": 0.6,
  "language": "english"
}

Response 200 — Streamed answer text.

Content type: text/event-stream

Response 400 — Missing fields.

json
{
  "detail": "Authentication credentials were not provided."
}

Example

bash
curl -X POST "https://api.example.com/semantic-search/advanced-search/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query":"Summarise the payment terms.","file_uuid":"1b6c1c1e-9d0a-4b6e-9f2a-3c4d5e6f7a8b","threshold":0.6,"language":"english"}'

POST /semantic-search/doc-from-chunks/

Full text of a document

Reassembles the document's text from its indexed chunks (Markdown). Handy for feeding a whole document to another tool.

Auth: Session token · In the app: Document viewer → text view

Request body (application/json)

FieldTypeRequiredDescription
file_idstring (uuid)yes
json
{
  "file_id": "1b6c1c1e-9d0a-4b6e-9f2a-3c4d5e6f7a8b"
}

Response 200 — The text.

FieldTypeDescription
document_contentstring
json
{
  "document_content": "# Q3 Report\n\nRevenue grew 12.4% …"
}

Response 400file_id missing.

json
{
  "error": "path is required"
}

Response 404 — Not your document, or the file is missing on disk.

json
{
  "error": "File does not exist."
}

Response 503 — The chunk store is temporarily unavailable — retry.

json
{
  "error": "path is required"
}

Example

bash
curl -X POST "https://api.example.com/semantic-search/doc-from-chunks/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"file_id":"1b6c1c1e-9d0a-4b6e-9f2a-3c4d5e6f7a8b"}'

POST /semantic-search/chat/

Chat with documents by file name (legacy)

Older in-process document chat: selects documents by file name rather than uid, stores the user's prompt itself, and streams grouped sources followed by the answer. Kept for the legacy Semantic Search page; new integrations should use single-file-chat/ / multi-file-chat/.

Auth: Session token

Request body (application/json)

FieldTypeRequiredDescription
questionstringyes
filenamestringyesComma-separated file names.
sessionintegerno
retrieverstringnoRetriever type selector (app-specific).

Response 200 — Grouped sources, then streamed answer text.

Content type: text/event-stream

Example

bash
curl -X POST "https://api.example.com/semantic-search/chat/" \
  -H "Authorization: Token $FINBLADE_TOKEN"

POST /semantic-search/store/

Store a document-chat message

Counterpart of secure-gpt/store/ for document-chat threads (semantic_search sessions); additionally records the sources the answer cited.

Auth: Session token · In the app: My Data chat, after every message and reply

Request body (application/json)

FieldTypeRequiredDescription
responsestringyes
sourcesstringyesJSON-encoded array of sources (as streamed). Use "[]" for a user prompt.
sessionintegerno
user_messagebooleanno
is_encryptedbooleannoDefault: false.
json
{
  "session": 9201,
  "response": "What are the key risks listed?",
  "sources": "[]",
  "user_message": true
}

Response 200 — Stored ("stored").

json
"stored"

Example

bash
curl -X POST "https://api.example.com/semantic-search/store/" \
  -H "Authorization: Token $FINBLADE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"session":9201,"response":"What are the key risks listed?","sources":"[]","user_message":true}'

GET /semantic-search/

All my document-chat messages

Auth: Session token

Response 200 — Messages.

Array of:

FieldTypeDescription
idinteger
userinteger
sessioninteger, nullable
from_serverboolean
messagestring
is_encryptedboolean
sourcesany[]Source citations as stored by the client (see the chat endpoints).
created_atstring (date-time)

Example

bash
curl -X GET "https://api.example.com/semantic-search/" \
  -H "Authorization: Token $FINBLADE_TOKEN"

Finblade documentation