curl --request POST \
--url https://app.teamai.com/api/v1/chat \
--header 'Content-Type: application/json' \
--header 'x-teamai-api-key: <api-key>' \
--data '
{
"messages": [
{
"id": "<string>",
"parts": [
{}
]
}
],
"agentId": "<string>",
"chatId": "<string>",
"projectId": "<string>",
"stream": false,
"temperature": 0.7,
"model": "<string>",
"variables": {},
"systemVariables": {
"user": {
"id": "<string>",
"name": "<string>",
"email": "<string>"
}
}
}
'import requests
url = "https://app.teamai.com/api/v1/chat"
payload = {
"messages": [
{
"id": "<string>",
"parts": [{}]
}
],
"agentId": "<string>",
"chatId": "<string>",
"projectId": "<string>",
"stream": False,
"temperature": 0.7,
"model": "<string>",
"variables": {},
"systemVariables": { "user": {
"id": "<string>",
"name": "<string>",
"email": "<string>"
} }
}
headers = {
"x-teamai-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-teamai-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{id: '<string>', parts: [{}]}],
agentId: '<string>',
chatId: '<string>',
projectId: '<string>',
stream: false,
temperature: 0.7,
model: '<string>',
variables: {},
systemVariables: {user: {id: '<string>', name: '<string>', email: '<string>'}}
})
};
fetch('https://app.teamai.com/api/v1/chat', 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://app.teamai.com/api/v1/chat",
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([
'messages' => [
[
'id' => '<string>',
'parts' => [
[
]
]
]
],
'agentId' => '<string>',
'chatId' => '<string>',
'projectId' => '<string>',
'stream' => false,
'temperature' => 0.7,
'model' => '<string>',
'variables' => [
],
'systemVariables' => [
'user' => [
'id' => '<string>',
'name' => '<string>',
'email' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-teamai-api-key: <api-key>"
],
]);
$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://app.teamai.com/api/v1/chat"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"id\": \"<string>\",\n \"parts\": [\n {}\n ]\n }\n ],\n \"agentId\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"stream\": false,\n \"temperature\": 0.7,\n \"model\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-teamai-api-key", "<api-key>")
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://app.teamai.com/api/v1/chat")
.header("x-teamai-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"id\": \"<string>\",\n \"parts\": [\n {}\n ]\n }\n ],\n \"agentId\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"stream\": false,\n \"temperature\": 0.7,\n \"model\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.teamai.com/api/v1/chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-teamai-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"id\": \"<string>\",\n \"parts\": [\n {}\n ]\n }\n ],\n \"agentId\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"stream\": false,\n \"temperature\": 0.7,\n \"model\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"text": "<string>",
"messageId": "<string>",
"chatId": "<string>",
"warnings": [
{}
]
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}Create chat completion
Runs a chat completion against a workspace agent and persists the conversation. Creates a new chat when chatId is omitted. Returns JSON by default, or a Server-Sent Events stream of AI SDK UI-message chunks when stream is true. Agents with multi-agent orchestration enabled require stream: false.
curl --request POST \
--url https://app.teamai.com/api/v1/chat \
--header 'Content-Type: application/json' \
--header 'x-teamai-api-key: <api-key>' \
--data '
{
"messages": [
{
"id": "<string>",
"parts": [
{}
]
}
],
"agentId": "<string>",
"chatId": "<string>",
"projectId": "<string>",
"stream": false,
"temperature": 0.7,
"model": "<string>",
"variables": {},
"systemVariables": {
"user": {
"id": "<string>",
"name": "<string>",
"email": "<string>"
}
}
}
'import requests
url = "https://app.teamai.com/api/v1/chat"
payload = {
"messages": [
{
"id": "<string>",
"parts": [{}]
}
],
"agentId": "<string>",
"chatId": "<string>",
"projectId": "<string>",
"stream": False,
"temperature": 0.7,
"model": "<string>",
"variables": {},
"systemVariables": { "user": {
"id": "<string>",
"name": "<string>",
"email": "<string>"
} }
}
headers = {
"x-teamai-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-teamai-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{id: '<string>', parts: [{}]}],
agentId: '<string>',
chatId: '<string>',
projectId: '<string>',
stream: false,
temperature: 0.7,
model: '<string>',
variables: {},
systemVariables: {user: {id: '<string>', name: '<string>', email: '<string>'}}
})
};
fetch('https://app.teamai.com/api/v1/chat', 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://app.teamai.com/api/v1/chat",
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([
'messages' => [
[
'id' => '<string>',
'parts' => [
[
]
]
]
],
'agentId' => '<string>',
'chatId' => '<string>',
'projectId' => '<string>',
'stream' => false,
'temperature' => 0.7,
'model' => '<string>',
'variables' => [
],
'systemVariables' => [
'user' => [
'id' => '<string>',
'name' => '<string>',
'email' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-teamai-api-key: <api-key>"
],
]);
$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://app.teamai.com/api/v1/chat"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"id\": \"<string>\",\n \"parts\": [\n {}\n ]\n }\n ],\n \"agentId\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"stream\": false,\n \"temperature\": 0.7,\n \"model\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-teamai-api-key", "<api-key>")
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://app.teamai.com/api/v1/chat")
.header("x-teamai-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"id\": \"<string>\",\n \"parts\": [\n {}\n ]\n }\n ],\n \"agentId\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"stream\": false,\n \"temperature\": 0.7,\n \"model\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.teamai.com/api/v1/chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-teamai-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"id\": \"<string>\",\n \"parts\": [\n {}\n ]\n }\n ],\n \"agentId\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"stream\": false,\n \"temperature\": 0.7,\n \"model\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"text": "<string>",
"messageId": "<string>",
"chatId": "<string>",
"warnings": [
{}
]
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}Authorizations
Secret API key created in Workspace Settings → API Keys (workspace keys) or Organization Admin → API Keys (organization keys).
Body
Conversation messages in AI SDK UI-message format. Must contain at least one message with role user.
Show child attributes
Show child attributes
Agent to run. Must belong to the API key's workspace.
Existing chat to continue. Omit to create a new chat titled from the first user message. Providing an unknown ID returns 404.
Project whose instructions, memory, and files are injected into the conversation context.
Return a Server-Sent Events stream instead of JSON.
Model identifier. Falls back to the workspace default model when the requested model is not enabled for the workspace.
Prompt template variables.
Show child attributes
Show child attributes
Response
Completion result. Note this endpoint returns the payload directly, without the data envelope used by other endpoints. When stream: true, the response is text/event-stream instead.
Was this page helpful?