Deploy API: AGUI Server
curl --request POST \
--url http://127.0.0.1:8765/agui \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"threadId": "<string>",
"runId": "<string>",
"state.messages": [
{}
]
}
'import requests
url = "http://127.0.0.1:8765/agui"
payload = {
"threadId": "<string>",
"runId": "<string>",
"state.messages": [{}]
}
headers = {
"X-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-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({threadId: '<string>', runId: '<string>', 'state.messages': [{}]})
};
fetch('http://127.0.0.1:8765/agui', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8765",
CURLOPT_URL => "http://127.0.0.1:8765/agui",
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([
'threadId' => '<string>',
'runId' => '<string>',
'state.messages' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-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 := "http://127.0.0.1:8765/agui"
payload := strings.NewReader("{\n \"threadId\": \"<string>\",\n \"runId\": \"<string>\",\n \"state.messages\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-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("http://127.0.0.1:8765/agui")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"threadId\": \"<string>\",\n \"runId\": \"<string>\",\n \"state.messages\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://127.0.0.1:8765/agui")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"threadId\": \"<string>\",\n \"runId\": \"<string>\",\n \"state.messages\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_bodyAPI Endpoints
Deploy API: AGUI Server
AG-UI protocol endpoints for CopilotKit integration
POST
/
agui
Deploy API: AGUI Server
curl --request POST \
--url http://127.0.0.1:8765/agui \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"threadId": "<string>",
"runId": "<string>",
"state.messages": [
{}
]
}
'import requests
url = "http://127.0.0.1:8765/agui"
payload = {
"threadId": "<string>",
"runId": "<string>",
"state.messages": [{}]
}
headers = {
"X-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-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({threadId: '<string>', runId: '<string>', 'state.messages': [{}]})
};
fetch('http://127.0.0.1:8765/agui', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8765",
CURLOPT_URL => "http://127.0.0.1:8765/agui",
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([
'threadId' => '<string>',
'runId' => '<string>',
'state.messages' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-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 := "http://127.0.0.1:8765/agui"
payload := strings.NewReader("{\n \"threadId\": \"<string>\",\n \"runId\": \"<string>\",\n \"state.messages\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-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("http://127.0.0.1:8765/agui")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"threadId\": \"<string>\",\n \"runId\": \"<string>\",\n \"state.messages\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://127.0.0.1:8765/agui")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"threadId\": \"<string>\",\n \"runId\": \"<string>\",\n \"state.messages\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_bodyAGUI API
AG-UI protocol endpoints for agents deployed viaAGUI(agent).get_router(). Compatible with CopilotKit.
Base URL + Playground
# Start AGUI server
from praisonaiagents import Agent
from praisonaiagents.agui import AGUI
import uvicorn
agent = Agent(instructions="You are a helpful assistant")
app = AGUI(agent).get_router()
uvicorn.run(app, host="0.0.0.0", port=8000)
http://localhost:8000
Endpoints
POST /agui
Run agent with Server-Sent Events streaming.Thread identifier
Run identifier
Conversation messages array
curl -X POST http://localhost:8000/agui \
-H "Content-Type: application/json" \
-d '{
"threadId": "thread-123",
"runId": "run-456",
"state": {
"messages": [
{"id": "msg-1", "role": "user", "content": "Hello!"}
]
}
}'
import requests
import json
response = requests.post(
"http://localhost:8000/agui",
json={
"threadId": "thread-123",
"runId": "run-456",
"state": {
"messages": [{"id": "msg-1", "role": "user", "content": "Hello!"}]
}
},
stream=True
)
for line in response.iter_lines():
if line:
line = line.decode('utf-8')
if line.startswith('data: '):
event = json.loads(line[6:])
print(f"Event: {event['type']}")
if event['type'] == 'text_message_content':
print(f" Delta: {event['delta']}")
const response = await fetch("http://localhost:8000/agui", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
threadId: "thread-123",
runId: "run-456",
state: {
messages: [{ id: "msg-1", role: "user", content: "Hello!" }]
}
})
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
for (const line of text.split('\n')) {
if (line.startsWith('data: ')) {
const event = JSON.parse(line.slice(6));
console.log('Event:', event.type);
}
}
}
event: run_started
data: {"type": "run_started", "threadId": "thread-123", "runId": "run-456"}
event: text_message_start
data: {"type": "text_message_start", "messageId": "msg-2"}
event: text_message_content
data: {"type": "text_message_content", "messageId": "msg-2", "delta": "Hello"}
event: text_message_content
data: {"type": "text_message_content", "messageId": "msg-2", "delta": "! How can I help?"}
event: text_message_end
data: {"type": "text_message_end", "messageId": "msg-2"}
event: run_finished
data: {"type": "run_finished", "threadId": "thread-123", "runId": "run-456"}
GET /status
Check agent availability.No parameters required.
curl http://localhost:8000/status
import requests
response = requests.get("http://localhost:8000/status")
print(response.json())
{
"status": "available"
}
Event Types
| Event | Description |
|---|---|
run_started | Agent run has started |
run_finished | Agent run completed |
run_error | Error occurred during run |
text_message_start | New text message started |
text_message_content | Text content delta |
text_message_end | Text message completed |
tool_call_start | Tool call started |
tool_call_args | Tool call arguments |
tool_call_end | Tool call completed |
Message Format
Input Message:{
"id": "msg-1",
"role": "user",
"content": "Hello!"
}
| Field | Type | Description |
|---|---|---|
id | string | Message ID |
role | string | ”user” or “assistant” |
content | string | Message content |
Error Events
event: run_error
data: {"type": "run_error", "threadId": "thread-123", "runId": "run-456", "error": "Error message"}
CopilotKit Integration
import { CopilotKit } from "@copilotkit/react-core";
function App() {
return (
<CopilotKit runtimeUrl="http://localhost:8000/agui">
<YourApp />
</CopilotKit>
);
}
Related
- AGUI Server - Deploy agents as AGUI server
- A2A API - A2A protocol endpoints
- Agents API - HTTP REST endpoints
⌘I

