Skip to main content
POST
/
api
/
ai
/
stream-chat
curl --request POST \
  --url https://api.yourapp.com/api/ai/stream-chat \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "chatId": "chat_123",
    "messages": [
      {
        "role": "user",
        "content": "Tell me about AI"
      }
    ],
    "model": "gpt-4o",
    "system": "You are a helpful AI assistant."
  }'
0:"AI"
0:" is"
0:" a"
0:" field"
0:" of"
0:" computer"
0:" science"
...

Request Body

chatId
string
required
Chat session identifier
messages
array
required
Array of message objects
model
string
default:"gpt-4o"
Model identifier
provider
string
Provider name (e.g., OpenAI, Anthropic, Google)
system
string
System prompt for the conversation

Response

The endpoint returns a streaming response compatible with the AI SDK. The response is streamed as Server-Sent Events (SSE).
curl --request POST \
  --url https://api.yourapp.com/api/ai/stream-chat \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "chatId": "chat_123",
    "messages": [
      {
        "role": "user",
        "content": "Tell me about AI"
      }
    ],
    "model": "gpt-4o",
    "system": "You are a helpful AI assistant."
  }'
0:"AI"
0:" is"
0:" a"
0:" field"
0:" of"
0:" computer"
0:" science"
...