---
title: "Generate streaming AI chat response"
method: POST
path: "/api/{org_id}/ai/chat_stream"
tags: ["AI"]
---

# Generate streaming AI chat response

`POST /api/{org_id}/ai/chat_stream`

## Request

- Base URL: `https://api.openobserve.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.openobserve.ai/api/{org_id}/ai/chat_stream`
- Auth: API key in header `Authorization`
- TypeScript: <https://skmtc.dev/openobserve/apis/openobserve-api-http/docs/api/:org_id/ai/chat_stream/post.ts> (a function with typed inputs; its response is checked against the schema)

Generates an AI response with real-time streaming for improved user experience. This endpoint redirects to the o2-sre-agent service for processing.

## Path parameters

- `org_id` string, required

## Request body

- object: AI chat request for conversational interactions with the OpenObserve AI assistant. # Example ```json { "messages": [{"role": "user", "content": "Find errors in the last hour"}], "context": { "start_time": 1768406781751488, "end_time": 1768496804185872, "stream_name": "default", "stream_type": "logs" } } ```
  - `confirm_timeout_secs` integer, nullable: Seconds the agent waits for a tool approval before denying it (capped at 600).
  - `context` object: Contextual information for the AI assistant. Should include: - `start_time`: Start of the time range in microseconds (required for search queries) - `end_time`: End of the time range in microseconds (required for search queries) - `stream_name`: Current stream being viewed (optional) - `stream_type`: Type of stream - logs, metrics, traces (optional) The frontend should pass the user's currently selected time range and stream context to enable the AI assistant to search within the relevant data scope.
  - `images` ImageAttachment[], nullable: Optional image attachments for multimodal queries (max 2MB each, PNG/JPEG only)
    - `data` string, required: Base64-encoded image data (max ~2 MB)
    - `filename` string, nullable: Optional filename
    - `mime_type` string, required: MIME type (image/png or image/jpeg)
  - `messages` object[], required: Chat messages in the conversation.
  - `model` string: Optional model name override.
  - `provider` string: Optional provider name override.

## Response `200`

Server-sent event stream

## Other responses

- `400`: Bad Request
- `402`: Subscription or additional credits required
- `409`: O2 AI session owner unavailable
- `412`: Paid overage consent required
- `429`: Upstream AI rate limit exceeded
- `500`: Internal Server Error
- `502`: Upstream AI service unavailable
- `503`: Usage authorization unavailable

---

[API](https://skmtc.dev/openobserve/apis/openobserve-api-http.md) - [All operations](https://skmtc.dev/openobserve/apis/openobserve-api-http/llms.txt) - [OpenAPI document](https://skmtc.dev/openobserve/apis/openobserve-api-http/revisions/0529b8a10252?raw)
