---
title: "Chat With Agent"
method: POST
path: "/agent/chat"
tags: ["agent"]
---

# Chat With Agent

`POST /agent/chat`

## Request

- Base URL: `https://api.alpha-grid.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.alpha-grid.ai/agent/chat`
- Auth: HTTP bearer

Chat endpoint using ReAct agent for autonomous source selection.

The agent autonomously selects appropriate tools (PubMed, Scopus, clinical trials, etc.)
based on the user's query and patient context. No manual connector selection.

Supports per-session conversation memory:
- If session_id provided, loads prior conversation history
- Saves user message and agent response after invocation
- Returns session_id for frontend to continue conversation

Returns:
    AgentsetChatResponse with agent's response, evidence sources, and session_id.

## Request body

- AgentsetChatRequest: Chat request model for /chat endpoint. The agent autonomously selects sources and tools. Manual connector selection is removed. Supports per-session conversation memory.
  - `messages` AgentsetMessage[], required
    - `role` string, required
    - `content` string, required
  - `patient_context` unknown
  - `session_id` string, nullable
  - `patient_id` integer, nullable
  - `custom_system_prompt` string, nullable

## Response `200`

Successful Response

- AgentsetChatResponse: Response from the /chat endpoint with agent transparency. Includes: - content: Final response text from agent - agent_steps: Sequential steps showing agent's reasoning process - evidence_sources: Sources/evidence used by agent - session_id: For continuing conversation - status: Response status
  - `content` string, required: The agent's response to the user
  - `agent_steps` AgentStep[], nullable: Sequential steps in agent's reasoning process for transparency
    - `step_num` integer, required: Sequential step number (1-indexed)
    - `action_type` 'thinking' | 'tool_call' | 'result', required: Type of action: thinking (inference), tool_call (execution), or result (outcome)
    - `tool_name` string, nullable: Name of tool used (only for tool_call and result types)
    - `tool_query` string, nullable: Tool arguments/parameters as JSON string (only for tool_call type)
    - `result_summary` string, nullable: Summary of tool result, truncated to ~200 chars (only for result type)
    - `thinking_text` string, nullable: Inferred thinking or reasoning (only for thinking type)
    - `timestamp` string, nullable: ISO 8601 timestamp for when step was executed
    - `duration_ms` integer, nullable: Duration of this step in milliseconds (time until next step)
  - `sources` object[], nullable: Search result sources
  - `evidence_sources` object[], nullable: Evidence sources extracted from tool calls
  - `session_id` string, nullable: Session ID for continuing conversation
  - `status` string: Response status: success, error, etc.
  - `usage_info` object, nullable: Token usage and cost information for this request

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/alpha-grid/apis/alphagrid-backend-dev.md) - [All operations](https://skmtc.dev/alpha-grid/apis/alphagrid-backend-dev/llms.txt) - [OpenAPI document](https://skmtc.dev/alpha-grid/apis/alphagrid-backend-dev/revisions/13bab0bdd466?raw)
