---
title: "POST Engage in AI chat"
description: "Sends user messages to an AI model and streams back the AI's response. Requires an active session and organization context."
last_updated: "2026-05-06T07:33:57.762755+00:00"
canonical_url: "https://www.doc0.dev/docs/49c89830-117b-4def-8edc-b5bcc50766e0/api/ai/chatwithai"
---

<APIEndpoint
  method={"POST"}
  path={"/api/chat"}
  summary={"Engage in AI chat"}
  description={"Sends user messages to an AI model and streams back the AI's response. Requires an active session and organization context."}
  deprecated={false}
  baseUrl={""}
/>

## Parameters

<APIParameters parameters={[{"name":"x-organization-id","in":"header","required":false,"description":"The ID of the organization to provide context for the AI chat.","schema":{"type":"string"}}]} />

## Request Body

Messages for the AI chat.

<APIRequestBody
  contentType={"application/json"}
  required={true}
  schema={{"type":"object"}}
/>

## Responses

<APIResponse
  statusCode={"200"}
  description={"Streams the AI's response."}
  contentType={"text/event-stream"}
/>

<APIResponse
  statusCode={"400"}
  description={"Organization context required."}
  contentType={"application/json"}
  schema={{"type":"object"}}
/>

<APIResponse
  statusCode={"401"}
  description={"Unauthorized if no user session or user not a member of the organization."}
  contentType={"application/json"}
  schema={{"type":"object"}}
/>

<APIResponse
  statusCode={"500"}
  description={"Internal server error, e.g., missing OpenAI API key."}
  contentType={"application/json"}
  schema={{"type":"object"}}
/>

## Try It

<APIPlayground
  method={"POST"}
  path={"/api/chat"}
  parameters={[{"name":"x-organization-id","in":"header","required":false,"description":"The ID of the organization to provide context for the AI chat.","schema":{"type":"string"}}]}
  requestBody={{"contentType":"application/json","required":true,"description":"Messages for the AI chat.","schema":{"type":"object"}}}
  baseUrl={""}
/>


## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/49c89830-117b-4def-8edc-b5bcc50766e0/llms.txt) for all pages in this wiki.
