Skip to main content

Endpoint

POST /api/v1/chat/stream

Overview

Interact with AI health assistants by sending messages and receiving intelligent, streaming responses. The API supports two agent types: DeepAgent (LangChain-based, for complex tasks) and BaselineAgent (native Gemini, for simple conversations).
The chat API uses Server-Sent Events (SSE) for streaming responses and supports file uploads, MCP tool calls, and multi-language conversations.

Request Parameters

question
string
required
The user’s message or question
agent
string
required
Agent type to use: deep (DeepAgent) or baseline (BaselineAgent)
user_id
string
required
Unique identifier for the authenticated user
query_user_id
string
User ID to query data for (defaults to user_id). Used for help-ask feature.
session_id
string
Session ID to maintain conversation context. Auto-generated if not provided.
provider
string
LLM provider override: google, openai, openrouter. Uses agent’s default if not specified.
enable_mcp
integer
default:"1"
Enable MCP tools (1 = enabled, 0 = disabled)
file_list
array
Array of file objects to include in the conversation
prompt_name
string
Name of custom prompt template to use
language
string
default:"en"
Language for responses: en, zh, etc.
timezone
string
default:"America/Los_Angeles"
User’s timezone for time-based queries
token
string
JWT authentication token
curl -X POST http://localhost:18080/api/v1/chat/stream \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "question": "How many steps did I take yesterday?",
    "agent": "deep",
    "user_id": "user_123",
    "session_id": "session_abc",
    "language": "en"
  }'

Response Format

The API returns Server-Sent Events (SSE) with JSON chunks. Each chunk has a type and content:
data: {"type": "reply", "content": "Based on your Garmin data"}
data: {"type": "reply", "content": ", you took"}
data: {"type": "reply", "content": " 10,543 steps yesterday"}

Chunk Types

TypeDescription
replyAI response content token
thinkingReasoning/thinking token (for models with reasoning)
queryTitleName of tool being called
queryArgumentsArguments for tool call
queryDetailResults from tool execution
costStatisticsToken usage and cost information
endStream completion signal
errorError message
The chat service automatically persists conversation history and integrates with MCP tools to access health data, perform calculations, and more.

Agent Types

LangChain-based agent for complex tasks:
  • File processing (PDFs, images, audio)
  • Multi-step planning and reasoning
  • Advanced MCP tool orchestration
  • Memory and context management
Use "agent": "deep" in your request.