Skip to main content
POST
/
api
/
v1
/
runtime
/
v1
/
chat
/
stream
LLM Chat Streaming
curl --request POST \
  --url https://api.runflow.ai/api/v1/runtime/v1/chat/stream \
  --header 'Content-Type: application/json' \
  --data '
{
  "projectId": "<string>",
  "model": "gpt-4",
  "messages": [
    {
      "content": "<string>",
      "tool_calls": [
        {}
      ],
      "tool_call_id": "<string>",
      "name": "<string>"
    }
  ],
  "providerName": "OpenAI Production",
  "legacy": true,
  "instructions": "<string>",
  "temperature": 0.7,
  "maxTokens": 1000,
  "topP": 0.9,
  "frequencyPenalty": 0.3,
  "presencePenalty": 0.2,
  "stop": [
    "END",
    "STOP"
  ],
  "seed": 12345,
  "tools": [
    {}
  ],
  "responseFormat": {
    "type": "json_object"
  },
  "thinking": {
    "type": "enabled",
    "budgetTokens": 5000
  },
  "serverTools": [
    {
      "type": "web_search_20250305"
    }
  ]
}
'
import requests

url = "https://api.runflow.ai/api/v1/runtime/v1/chat/stream"

payload = {
"projectId": "<string>",
"model": "gpt-4",
"messages": [
{
"content": "<string>",
"tool_calls": [{}],
"tool_call_id": "<string>",
"name": "<string>"
}
],
"providerName": "OpenAI Production",
"legacy": True,
"instructions": "<string>",
"temperature": 0.7,
"maxTokens": 1000,
"topP": 0.9,
"frequencyPenalty": 0.3,
"presencePenalty": 0.2,
"stop": ["END", "STOP"],
"seed": 12345,
"tools": [{}],
"responseFormat": { "type": "json_object" },
"thinking": {
"type": "enabled",
"budgetTokens": 5000
},
"serverTools": [{ "type": "web_search_20250305" }]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
projectId: '<string>',
model: 'gpt-4',
messages: [
{
content: '<string>',
tool_calls: [{}],
tool_call_id: '<string>',
name: '<string>'
}
],
providerName: 'OpenAI Production',
legacy: true,
instructions: '<string>',
temperature: 0.7,
maxTokens: 1000,
topP: 0.9,
frequencyPenalty: 0.3,
presencePenalty: 0.2,
stop: ['END', 'STOP'],
seed: 12345,
tools: [{}],
responseFormat: {type: 'json_object'},
thinking: {type: 'enabled', budgetTokens: 5000},
serverTools: [{type: 'web_search_20250305'}]
})
};

fetch('https://api.runflow.ai/api/v1/runtime/v1/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://api.runflow.ai/api/v1/runtime/v1/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([
'projectId' => '<string>',
'model' => 'gpt-4',
'messages' => [
[
'content' => '<string>',
'tool_calls' => [
[

]
],
'tool_call_id' => '<string>',
'name' => '<string>'
]
],
'providerName' => 'OpenAI Production',
'legacy' => true,
'instructions' => '<string>',
'temperature' => 0.7,
'maxTokens' => 1000,
'topP' => 0.9,
'frequencyPenalty' => 0.3,
'presencePenalty' => 0.2,
'stop' => [
'END',
'STOP'
],
'seed' => 12345,
'tools' => [
[

]
],
'responseFormat' => [
'type' => 'json_object'
],
'thinking' => [
'type' => 'enabled',
'budgetTokens' => 5000
],
'serverTools' => [
[
'type' => 'web_search_20250305'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$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://api.runflow.ai/api/v1/runtime/v1/chat/stream"

payload := strings.NewReader("{\n \"projectId\": \"<string>\",\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"tool_calls\": [\n {}\n ],\n \"tool_call_id\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"providerName\": \"OpenAI Production\",\n \"legacy\": true,\n \"instructions\": \"<string>\",\n \"temperature\": 0.7,\n \"maxTokens\": 1000,\n \"topP\": 0.9,\n \"frequencyPenalty\": 0.3,\n \"presencePenalty\": 0.2,\n \"stop\": [\n \"END\",\n \"STOP\"\n ],\n \"seed\": 12345,\n \"tools\": [\n {}\n ],\n \"responseFormat\": {\n \"type\": \"json_object\"\n },\n \"thinking\": {\n \"type\": \"enabled\",\n \"budgetTokens\": 5000\n },\n \"serverTools\": [\n {\n \"type\": \"web_search_20250305\"\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

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://api.runflow.ai/api/v1/runtime/v1/chat/stream")
.header("Content-Type", "application/json")
.body("{\n \"projectId\": \"<string>\",\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"tool_calls\": [\n {}\n ],\n \"tool_call_id\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"providerName\": \"OpenAI Production\",\n \"legacy\": true,\n \"instructions\": \"<string>\",\n \"temperature\": 0.7,\n \"maxTokens\": 1000,\n \"topP\": 0.9,\n \"frequencyPenalty\": 0.3,\n \"presencePenalty\": 0.2,\n \"stop\": [\n \"END\",\n \"STOP\"\n ],\n \"seed\": 12345,\n \"tools\": [\n {}\n ],\n \"responseFormat\": {\n \"type\": \"json_object\"\n },\n \"thinking\": {\n \"type\": \"enabled\",\n \"budgetTokens\": 5000\n },\n \"serverTools\": [\n {\n \"type\": \"web_search_20250305\"\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.runflow.ai/api/v1/runtime/v1/chat/stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"projectId\": \"<string>\",\n \"model\": \"gpt-4\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"tool_calls\": [\n {}\n ],\n \"tool_call_id\": \"<string>\",\n \"name\": \"<string>\"\n }\n ],\n \"providerName\": \"OpenAI Production\",\n \"legacy\": true,\n \"instructions\": \"<string>\",\n \"temperature\": 0.7,\n \"maxTokens\": 1000,\n \"topP\": 0.9,\n \"frequencyPenalty\": 0.3,\n \"presencePenalty\": 0.2,\n \"stop\": [\n \"END\",\n \"STOP\"\n ],\n \"seed\": 12345,\n \"tools\": [\n {}\n ],\n \"responseFormat\": {\n \"type\": \"json_object\"\n },\n \"thinking\": {\n \"type\": \"enabled\",\n \"budgetTokens\": 5000\n },\n \"serverTools\": [\n {\n \"type\": \"web_search_20250305\"\n }\n ]\n}"

response = http.request(request)
puts response.read_body

Body

application/json
projectId
string
required

Project ID

provider
enum<string>
required

LLM provider

Available options:
openai,
anthropic,
bedrock,
groq,
gemini,
xai,
custom
model
string
required

Model name

Example:

"gpt-4"

messages
object[]
required

Messages

providerName
string

Provider name (configured in LLM Providers)

Example:

"OpenAI Production"

legacy
boolean

Use legacy Chat Completions API when true

Example:

true

instructions
string

System instructions

temperature
number

Temperature

Required range: 0 <= x <= 2
Example:

0.7

maxTokens
number

Max tokens

Example:

1000

topP
number

Top P (nucleus sampling)

Required range: 0 <= x <= 1
Example:

0.9

frequencyPenalty
number

Frequency penalty

Required range: -2 <= x <= 2
Example:

0.3

presencePenalty
number

Presence penalty

Required range: -2 <= x <= 2
Example:

0.2

stop
string[]

Stop sequences

Example:
["END", "STOP"]
seed
number

Seed for reproducible outputs

Example:

12345

tools
object[]

Tools available for the model to call

responseFormat
object

Response format for structured output

Example:
{ "type": "json_object" }
thinking
object

Enable extended thinking/reasoning for supported models

Example:
{ "type": "enabled", "budgetTokens": 5000 }
serverTools
string[]

Server-side tools (provider-specific). Anthropic: web_search, code_execution

Example:
[{ "type": "web_search_20250305" }]

Response

text/plain stream of chunks. Terminates when the LLM completes.