Skip to main content

Agent Chat API

The Agent Chat API provides a streaming interface to interact with the IME Assistant, our powerful conversational AI agent.

Send a Message

Initiates a conversation or sends a new message in an existing conversation.

POST /api/agent

Request Body

{
"caseId": "case-abc-123",
"messages": [
{
"role": "user",
"content": "What were the key findings in the operative report from Dr. Smith?"
}
],
// Optional: include conversationId to continue an existing chat
"conversationId": "conv_xyz789"
}

Response

The API returns a text/event-stream response. Your client should be prepared to handle a stream of Server-Sent Events (SSE).

Event Types

  • message: A message from the agent to the user.
  • tool_call: The agent is using one of its tools (e.g., search_case_records).
  • tool_output: The result from a tool call.
  • approvals_needed: The stream is paused, and the agent requires your approval to proceed with one or more tool calls. The payload will include the conversationId and a list of approval items.
  • stream_end: The agent has finished its turn.
  • error: An error occurred during processing.

Resuming with Approvals

If you receive an approvals_needed event, the agent is paused. To resume, send a new POST request to /api/agent with the conversationId and your decisions.

Request Body for Approval

{
"caseId": "case-abc-123",
"conversationId": "conv_xyz789",
"decisions": {
// The callId comes from the approval item in the event stream
"call_abc123": "approved",
"call_def456": "rejected"
}
}