Skip to main content
POST
/
api
/
v1
/
chat
/
stream
Stream chat response
const url = 'https://studyfetchapi.com/api/v1/chat/stream';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
  body: '{"messages":[{"role":"user","content":"Hello"},{"role":"assistant","content":"Hi there!"},{"role":"user","content":[{"type":"text","text":"What is in this image?"},{"type":"image","image_url":{"url":"https://example.com/image.jpg"}}]}],"message":{"text":"<string>","images":[{"url":"<string>","base64":"<string>","mimeType":"<string>","caption":"<string>"}]},"componentId":"<string>","userId":"<string>","groupIds":["<string>"],"sessionId":"<string>","id":"<string>","context":{}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

Authorizations

x-api-key
string
header
required

API Key for authentication

Headers

x-component-id
string

Optional component ID for component-specific chat context

Body

application/json
messages
string[]

Messages array for AI SDK format - list of conversation messages with roles

Example:
[
{ "role": "user", "content": "Hello" },
{
"role": "assistant",
"content": "Hi there!"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image",
"image_url": { "url": "https://example.com/image.jpg" }
}
]
}
]
message
object

Single message for custom format - contains text and optional images

componentId
string

Component ID

userId
string

User ID

groupIds
string[]

Group IDs for access control

sessionId
string

Session ID

id
string

Session ID (AI SDK uses "id")

context
object

Additional context

Response

Successful streaming response (SSE format)

I