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."
}'
const response = await fetch('https://api.yourapp.com/api/ai/stream-chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
chatId: 'chat_123',
messages: [
{
role: 'user',
content: 'Tell me about AI'
}
],
model: 'gpt-4o',
system: 'You are a helpful AI assistant.'
})
});
// Handle streaming response
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
console.log(chunk);
}
import requests
url = "https://api.yourapp.com/api/ai/stream-chat"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"chatId": "chat_123",
"messages": [
{
"role": "user",
"content": "Tell me about AI"
}
],
"model": "gpt-4o",
"system": "You are a helpful AI assistant."
}
response = requests.post(url, json=payload, headers=headers, stream=True)
# Handle streaming response
for chunk in response.iter_content(chunk_size=None):
if chunk:
print(chunk.decode('utf-8'))
0:"AI"
0:" is"
0:" a"
0:" field"
0:" of"
0:" computer"
0:" science"
...
{
"success": false,
"message": "Unauthorized"
}
AI
Stream Chat
AI SDK compatible chat streaming endpoint
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."
}'
const response = await fetch('https://api.yourapp.com/api/ai/stream-chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
chatId: 'chat_123',
messages: [
{
role: 'user',
content: 'Tell me about AI'
}
],
model: 'gpt-4o',
system: 'You are a helpful AI assistant.'
})
});
// Handle streaming response
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
console.log(chunk);
}
import requests
url = "https://api.yourapp.com/api/ai/stream-chat"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"chatId": "chat_123",
"messages": [
{
"role": "user",
"content": "Tell me about AI"
}
],
"model": "gpt-4o",
"system": "You are a helpful AI assistant."
}
response = requests.post(url, json=payload, headers=headers, stream=True)
# Handle streaming response
for chunk in response.iter_content(chunk_size=None):
if chunk:
print(chunk.decode('utf-8'))
0:"AI"
0:" is"
0:" a"
0:" field"
0:" of"
0:" computer"
0:" science"
...
{
"success": false,
"message": "Unauthorized"
}
Request Body
string
required
Chat session identifier
array
required
string
default:"gpt-4o"
Model identifier
string
Provider name (e.g., OpenAI, Anthropic, Google)
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."
}'
const response = await fetch('https://api.yourapp.com/api/ai/stream-chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
chatId: 'chat_123',
messages: [
{
role: 'user',
content: 'Tell me about AI'
}
],
model: 'gpt-4o',
system: 'You are a helpful AI assistant.'
})
});
// Handle streaming response
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
console.log(chunk);
}
import requests
url = "https://api.yourapp.com/api/ai/stream-chat"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"chatId": "chat_123",
"messages": [
{
"role": "user",
"content": "Tell me about AI"
}
],
"model": "gpt-4o",
"system": "You are a helpful AI assistant."
}
response = requests.post(url, json=payload, headers=headers, stream=True)
# Handle streaming response
for chunk in response.iter_content(chunk_size=None):
if chunk:
print(chunk.decode('utf-8'))
0:"AI"
0:" is"
0:" a"
0:" field"
0:" of"
0:" computer"
0:" science"
...
{
"success": false,
"message": "Unauthorized"
}
⌘I

