Skip to Content

Start Conversation

Ask a question to the specified Agent. You can start a brand-new conversation, or pass the chat_uid of an existing one to continue asking in the same conversation.

The Agent generates the answer using capabilities such as market data and account access. When the Agent needs more information or confirmation from you, the run is interrupted (status is interrupted) — send your answers via Continue Conversation to resume it.

Choose the response mode with the Accept header: text/event-stream streams the run progress and answer via SSE; any other value returns a blocking response with the aggregated final result.

Request

HTTP MethodPOST
HTTP URL/v1/ai/agents/:id/conversations

Path Parameters

NameTypeRequiredDescription
idstringYESUID of the target Agent; must be a published Agent
How to find an Agent's UID

Besides querying the Agents in Workspace endpoint, you can also get it directly from the Longbridge website: open the Agent's chat page — the URL looks like https://longbridge.com/en/ai/agents/chatbot/chat, where chatbot is the Agent's UID.

Request Body

NameTypeRequiredDescription
querystringYESThe user question; must not be empty
chat_uidstringNOIdentifier of an existing conversation. Pass it to continue that conversation; omit to start a new one

Request Example

Response

Response Headers

  • Content-Type: application/json (blocking)
  • Content-Type: text/event-stream (streaming)

Response Example

Run succeeded:

json
{
  "code": 0,
  "message": "success",
  "data": {
    "chat_uid": "ct_9f2c1a5b",
    "message_id": "42",
    "status": "succeeded",
    "answer": "Tesla (TSLA.US) recently...",
    "references": [
      { "index": 1, "title": "...", "url": "..." }
    ],
    "elapsed_time": 3.21
  }
}

Run interrupted (the Agent needs more information from you; the run is paused):

json
{
  "code": 0,
  "message": "success",
  "data": {
    "chat_uid": "ct_9f2c1a5b",
    "message_id": "43",
    "status": "interrupted",
    "answer": "",
    "references": null,
    "elapsed_time": 1.05,
    "interrupt": {
      "node_id": "n_ask_human",
      "tool_call_id": "call_abc123",
      "questions": [
        {
          "question": "Which time range would you like to check?",
          "options": [
            { "description": "Past week" },
            { "description": "Past month" }
          ],
          "multi_select": false
        }
      ],
      "message_id": 43,
      "chat_id": 1001
    }
  }
}

In streaming mode, the server keeps pushing run progress as event: message events; the event field inside data identifies the event type:

event: message
data: {"event":"chat_started","workflow_run_id":"wr_...","data":{"chat_uid":"ct_9f2c1a5b","message_id":42}}

event: message
data: {"event":"message","workflow_run_id":"wr_...","data":{"text":"Tesla"}}

event: message
data: {"event":"workflow_finished","workflow_run_id":"wr_...","data":{"status":"succeeded","elapsed_time":3.21,"outputs":{"answer":"..."}}}

Response Status

StatusDescriptionSchema
200Successconversation_response
400Invalid parameters or risk controlEmpty query, malformed request body, or blocked by content risk control
500Internal errorNone

Schemas

conversation_response

NameTypeRequiredDescription
chat_uidstringtrueConversation identifier, used for follow-up questions and troubleshooting
message_idstringtrueMessage ID of this round (as a string)
statusstringtrueFinal run status: succeeded / interrupted / failed / stopped
answerstringfalseFinal answer text; valid when status is succeeded
referencesobject[]falseSources referenced by the answer; null if none
elapsed_timenumberfalseRun duration in seconds
interruptobjectfalsePresent only when status is interrupted
∟ node_idstringtrueID of the node that triggered the interrupt
∟ tool_call_idstringtrueTool call ID of this inquiry; used as the answer key when continuing
∟ questionsobject[]trueQuestions you need to answer
∟∟ questionstringtrueQuestion text
∟∟ optionsobject[]falseOptions; empty means free-form answer
∟∟∟ descriptionstringfalseOption text
∟∟ multi_selectbooleanfalseWhether multiple options may be selected
∟ message_idint64falseID of the paused message
∟ chat_idint64falseID of the owning conversation
errorobjectfalsePresent only when the run failed
∟ codeint32falseError code
∟ messagestringfalseError message