FlexyChat
Stream a chat response
The response is text/event-stream. Each frame contains an event field (event type)
and a data field (JSON payload). Consume text_delta events to progressively render
the assistant’s reply.
Event types in order:
stream_start— stream opened, includes model and provider infostep_start— reasoning step startedtext_start— text block startedtext_delta— incremental text chunk; readdata.deltafor the tokentext_complete— text block finishedstep_finish— reasoning step finishedstream_end— stream closed, includesfinish_reasonand tokenusage
Example stream:
event: stream_start
data: {"id":"evt_01KPTDR1BWRTJRY7W56MBCGF0R","timestamp":1776855811,"model":"grok-4-1-fast-non-reasoning","provider":"xai","metadata":null}
event: step_start
data: {"id":"evt_01KPTDR1BWRTJRY7W56MBCGF0S","timestamp":1776855811}
event: text_start
data: {"id":"evt_01KPTDR1BWRTJRY7W56MBCGF0T","timestamp":1776855811,"message_id":"evt_abc"}
event: text_delta
data: {"id":"evt_01KPTDR1BXRXHBK6DFSZ3W32H6","timestamp":1776855811,"delta":"Hello","message_id":"evt_def"}
event: text_delta
data: {"id":"evt_01KPTDR1CXK80DJ647VEF68ATW","timestamp":1776855811,"delta":"!","message_id":"evt_klm"}
event: text_complete
data: {"id":"evt_01KPTDR1Q0Z330AKTGKFXYRQ7G","timestamp":1776855811,"message_id":"evt_xyz"}
event: step_finish
data: {"id":"evt_01KPTDR1Q1PD7FG8F9DS2GCAVJ","timestamp":1776855811}
event: stream_end
data: {"id":"evt_01KPTDR1Q1PD7FG8F9DS2GCAVK","timestamp":1776855811,"finish_reason":"Stop","usage":{"prompt_tokens":12,"completion_tokens":8,"cache_write_input_tokens":null,"cache_read_input_tokens":null,"thought_tokens":null},"citations":null}
Note: Use
curl -N(no-buffer) or an EventSource client to see tokens arrive in real time. Postman buffers SSE until the connection closes.
POST
/
v1
/
flexy-chat
/
stream
Stream a chat response
curl --request POST \
--url https://dev.flextell.ai/api/v1/flexy-chat/stream \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Tenant: <x-tenant>' \
--data '
{
"prompt": "<string>",
"history": [
{
"content": "<string>"
}
]
}
'import requests
url = "https://dev.flextell.ai/api/v1/flexy-chat/stream"
payload = {
"prompt": "<string>",
"history": [{ "content": "<string>" }]
}
headers = {
"X-Tenant": "<x-tenant>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Tenant': '<x-tenant>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({prompt: '<string>', history: [{content: '<string>'}]})
};
fetch('https://dev.flextell.ai/api/v1/flexy-chat/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://dev.flextell.ai/api/v1/flexy-chat/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'history' => [
[
'content' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Tenant: <x-tenant>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://dev.flextell.ai/api/v1/flexy-chat/stream"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"history\": [\n {\n \"content\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Tenant", "<x-tenant>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://dev.flextell.ai/api/v1/flexy-chat/stream")
.header("X-Tenant", "<x-tenant>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"history\": [\n {\n \"content\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dev.flextell.ai/api/v1/flexy-chat/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Tenant"] = '<x-tenant>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"history\": [\n {\n \"content\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"event": "text_delta",
"data": {}
}Authorizations
oauth2bearer
The access token received from the authorization server in the OAuth 2.0 flow.
FlowAuthorization Code
- Authorization URL
- https://dev.flextell.ai/oauth/authorize
- Token URL
- https://dev.flextell.ai/oauth/token
Headers
Tenant identifier. Send the Tenant ID in the X-Tenant header to scope API requests to a specific tenant.
Body
application/json
Response
200 - text/event-stream
SSE stream. Listen for text_delta events and read data.delta to render the response progressively.
⌘I
Stream a chat response
curl --request POST \
--url https://dev.flextell.ai/api/v1/flexy-chat/stream \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Tenant: <x-tenant>' \
--data '
{
"prompt": "<string>",
"history": [
{
"content": "<string>"
}
]
}
'import requests
url = "https://dev.flextell.ai/api/v1/flexy-chat/stream"
payload = {
"prompt": "<string>",
"history": [{ "content": "<string>" }]
}
headers = {
"X-Tenant": "<x-tenant>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Tenant': '<x-tenant>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({prompt: '<string>', history: [{content: '<string>'}]})
};
fetch('https://dev.flextell.ai/api/v1/flexy-chat/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://dev.flextell.ai/api/v1/flexy-chat/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'history' => [
[
'content' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Tenant: <x-tenant>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://dev.flextell.ai/api/v1/flexy-chat/stream"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"history\": [\n {\n \"content\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Tenant", "<x-tenant>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://dev.flextell.ai/api/v1/flexy-chat/stream")
.header("X-Tenant", "<x-tenant>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"history\": [\n {\n \"content\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dev.flextell.ai/api/v1/flexy-chat/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Tenant"] = '<x-tenant>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"history\": [\n {\n \"content\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"event": "text_delta",
"data": {}
}