Run agent
curl --request POST \
--url https://app.teamai.com/api/v1/agents/{agentId}/runs \
--header 'Content-Type: application/json' \
--header 'x-teamai-api-key: <api-key>' \
--data '
{
"message": "<string>",
"chatId": "<string>",
"projectId": "<string>",
"variables": {},
"systemVariables": {
"user": {
"id": "<string>",
"name": "<string>",
"email": "<string>"
}
},
"temperature": 1,
"model": "<string>"
}
'import requests
url = "https://app.teamai.com/api/v1/agents/{agentId}/runs"
payload = {
"message": "<string>",
"chatId": "<string>",
"projectId": "<string>",
"variables": {},
"systemVariables": { "user": {
"id": "<string>",
"name": "<string>",
"email": "<string>"
} },
"temperature": 1,
"model": "<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({
message: '<string>',
chatId: '<string>',
projectId: '<string>',
variables: {},
systemVariables: {user: {id: '<string>', name: '<string>', email: '<string>'}},
temperature: 1,
model: '<string>'
})
};
fetch('https://app.teamai.com/api/v1/agents/{agentId}/runs', 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/agents/{agentId}/runs",
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([
'message' => '<string>',
'chatId' => '<string>',
'projectId' => '<string>',
'variables' => [
],
'systemVariables' => [
'user' => [
'id' => '<string>',
'name' => '<string>',
'email' => '<string>'
]
],
'temperature' => 1,
'model' => '<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/agents/{agentId}/runs"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n },\n \"temperature\": 1,\n \"model\": \"<string>\"\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/agents/{agentId}/runs")
.header("x-teamai-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n },\n \"temperature\": 1,\n \"model\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.teamai.com/api/v1/agents/{agentId}/runs")
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 \"message\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n },\n \"temperature\": 1,\n \"model\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"status": "completed",
"agentId": "<string>",
"agentName": "<string>",
"agentResponse": "<string>",
"chatId": "<string>",
"input": "<string>",
"executionTime": 123,
"createdAt": "2023-11-07T05:31:56Z",
"completedAt": "2023-11-07T05:31:56Z"
}
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}{
"code": "bad_request",
"message": "<string>",
"details": {}
}Agents
Run agent
Executes an agent with a single text message and waits for the response. Creates a chat (or continues an existing one) and records an agent run. Simpler alternative to POST /chat for single-message integrations.
POST
/
agents
/
{agentId}
/
runs
Run agent
curl --request POST \
--url https://app.teamai.com/api/v1/agents/{agentId}/runs \
--header 'Content-Type: application/json' \
--header 'x-teamai-api-key: <api-key>' \
--data '
{
"message": "<string>",
"chatId": "<string>",
"projectId": "<string>",
"variables": {},
"systemVariables": {
"user": {
"id": "<string>",
"name": "<string>",
"email": "<string>"
}
},
"temperature": 1,
"model": "<string>"
}
'import requests
url = "https://app.teamai.com/api/v1/agents/{agentId}/runs"
payload = {
"message": "<string>",
"chatId": "<string>",
"projectId": "<string>",
"variables": {},
"systemVariables": { "user": {
"id": "<string>",
"name": "<string>",
"email": "<string>"
} },
"temperature": 1,
"model": "<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({
message: '<string>',
chatId: '<string>',
projectId: '<string>',
variables: {},
systemVariables: {user: {id: '<string>', name: '<string>', email: '<string>'}},
temperature: 1,
model: '<string>'
})
};
fetch('https://app.teamai.com/api/v1/agents/{agentId}/runs', 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/agents/{agentId}/runs",
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([
'message' => '<string>',
'chatId' => '<string>',
'projectId' => '<string>',
'variables' => [
],
'systemVariables' => [
'user' => [
'id' => '<string>',
'name' => '<string>',
'email' => '<string>'
]
],
'temperature' => 1,
'model' => '<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/agents/{agentId}/runs"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n },\n \"temperature\": 1,\n \"model\": \"<string>\"\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/agents/{agentId}/runs")
.header("x-teamai-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n },\n \"temperature\": 1,\n \"model\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.teamai.com/api/v1/agents/{agentId}/runs")
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 \"message\": \"<string>\",\n \"chatId\": \"<string>\",\n \"projectId\": \"<string>\",\n \"variables\": {},\n \"systemVariables\": {\n \"user\": {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"email\": \"<string>\"\n }\n },\n \"temperature\": 1,\n \"model\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"status": "completed",
"agentId": "<string>",
"agentName": "<string>",
"agentResponse": "<string>",
"chatId": "<string>",
"input": "<string>",
"executionTime": 123,
"createdAt": "2023-11-07T05:31:56Z",
"completedAt": "2023-11-07T05:31:56Z"
}
}{
"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).
Path Parameters
Agent to run.
Body
application/json
Response
Completed agent run.
Show child attributes
Show child attributes
Was this page helpful?
⌘I