Skip to main content
The chat endpoint uses Server-Sent Events (SSE) for streaming. Responses are not standard JSON — they arrive as a stream of events.

Chat Modes

ModeDescription
askQuery and analyze without making changes
agentAI makes direct edits to schematic or PCB
planMulti-step planning with approval workflow

Stream Chat

POST /chat/stream

Request Body

FieldTypeRequiredDescription
messagestringYesThe user’s message
session_idstringYesConversation session ID
modestringNoask, agent, or plan
app_typestringNoschematic or pcb
project_pathstringNoPath to the project
schematic_contentstringNoCurrent schematic file content
pcb_contentstringNoCurrent PCB file content

SSE Event Types

EventDescription
textAI response text chunk
tool_callAI requesting a tool execution
tool_resultResult from a tool execution
questionAI asking for clarification
planMulti-step plan for approval
statusStatus update message
errorError message
doneStream complete

Example

curl -N -X POST "https://api.buildwithtrace.com/api/v2/chat/stream" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Add a 10uF decoupling capacitor to U1",
    "session_id": "session-uuid",
    "mode": "agent",
    "app_type": "schematic"
  }'

Submit Tool Result

POST /tools/result After the AI requests a tool execution (e.g., modifying a file locally), submit the result back:
curl -X POST "https://api.buildwithtrace.com/api/v2/tools/result" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "tool_call_id": "call_id",
    "result": "Tool execution output"
  }'

Task Status

GET /task/{task_id}/status Check the status of an async task:
curl -X GET "https://api.buildwithtrace.com/api/v2/task/TASK_ID/status" \
  -H "Authorization: Bearer YOUR_TOKEN"

Error Responses

StatusDescription
402Quota exceeded
403Plan doesn’t support this mode
429Rate limited