Generate agent completion
curl --request POST \
--url https://app.dumplingai.com/api/v1/agents/generate-completion \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agentId": "agnt_123",
"messages": [
{
"role": "user",
"content": "Summarize this article"
}
]
}
'import requests
url = "https://app.dumplingai.com/api/v1/agents/generate-completion"
payload = {
"agentId": "agnt_123",
"messages": [
{
"role": "user",
"content": "Summarize this article"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agentId: 'agnt_123',
messages: [{role: 'user', content: 'Summarize this article'}]
})
};
fetch('https://app.dumplingai.com/api/v1/agents/generate-completion', 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.dumplingai.com/api/v1/agents/generate-completion",
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([
'agentId' => 'agnt_123',
'messages' => [
[
'role' => 'user',
'content' => 'Summarize this article'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://app.dumplingai.com/api/v1/agents/generate-completion"
payload := strings.NewReader("{\n \"agentId\": \"agnt_123\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize this article\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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://app.dumplingai.com/api/v1/agents/generate-completion")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"agnt_123\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize this article\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.dumplingai.com/api/v1/agents/generate-completion")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"agnt_123\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize this article\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"text": "<string>",
"stepsTaken": 123,
"steps": [
{
"finishReason": "<string>",
"usage": {
"promptTokens": 123,
"completionTokens": 123,
"totalTokens": 123
},
"text": "<string>",
"toolCalls": [
{
"type": "tool-call",
"toolCallId": "<string>",
"toolName": "<string>",
"args": {}
}
],
"toolResults": [
{
"toolCallId": "<string>",
"toolName": "<string>",
"result": {}
}
]
}
],
"tokenUsage": {
"promptTokens": 123,
"completionTokens": 123,
"totalTokens": 123
},
"creditUsage": 123,
"threadId": "<string>",
"parsedJson": {}
}{
"error": "<string>"
}{
"error": "<string>"
}AI
Generate Agent Completion
Generate a completion from a DumplingAI agent with streaming or sync support.
POST
/
api
/
v1
/
agents
/
generate-completion
Generate agent completion
curl --request POST \
--url https://app.dumplingai.com/api/v1/agents/generate-completion \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agentId": "agnt_123",
"messages": [
{
"role": "user",
"content": "Summarize this article"
}
]
}
'import requests
url = "https://app.dumplingai.com/api/v1/agents/generate-completion"
payload = {
"agentId": "agnt_123",
"messages": [
{
"role": "user",
"content": "Summarize this article"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agentId: 'agnt_123',
messages: [{role: 'user', content: 'Summarize this article'}]
})
};
fetch('https://app.dumplingai.com/api/v1/agents/generate-completion', 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.dumplingai.com/api/v1/agents/generate-completion",
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([
'agentId' => 'agnt_123',
'messages' => [
[
'role' => 'user',
'content' => 'Summarize this article'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://app.dumplingai.com/api/v1/agents/generate-completion"
payload := strings.NewReader("{\n \"agentId\": \"agnt_123\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize this article\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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://app.dumplingai.com/api/v1/agents/generate-completion")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"agnt_123\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize this article\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.dumplingai.com/api/v1/agents/generate-completion")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"agnt_123\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Summarize this article\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"text": "<string>",
"stepsTaken": 123,
"steps": [
{
"finishReason": "<string>",
"usage": {
"promptTokens": 123,
"completionTokens": 123,
"totalTokens": 123
},
"text": "<string>",
"toolCalls": [
{
"type": "tool-call",
"toolCallId": "<string>",
"toolName": "<string>",
"args": {}
}
],
"toolResults": [
{
"toolCallId": "<string>",
"toolName": "<string>",
"result": {}
}
]
}
],
"tokenUsage": {
"promptTokens": 123,
"completionTokens": 123,
"totalTokens": 123
},
"creditUsage": 123,
"threadId": "<string>",
"parsedJson": {}
}{
"error": "<string>"
}{
"error": "<string>"
}Description
This endpoint processes messages for a specific agent, generating a response using one of your AI agents. It can optionally maintain conversation history through threads.Endpoint
POST https://app.dumplingai.com/api/v1/agents/generate-completion
Headers
- Content-Type:
application/json - Authorization: Bearer
<API_KEY>(required)
Request Body
{
"messages": [
{
"role": "string",
"content": "string"
}
],
"agentId": "string",
"parseJson": "boolean",
"threadId": "string"
}
messages: An array of message objects, each containing:role: Either “user” or “assistant”content: The content of the message
agentId: The unique identifier of the agent to use for processingparseJson: Whether to try and parse the JSON in the response into a JSON objectthreadId: (Optional) The ID of an existing thread to continue the conversation
Responses
Success (200 OK)
Returns the generated response, usage information, and thread details.{
"parsedJson": "object",
"text": "string",
"stepsTaken": "number",
"steps": [
{
"text": "string",
"toolCalls": "array",
"toolResults": "array",
"finishReason": "string",
"usage": "object"
}
],
"tokenUsage": {
"promptTokens": "number",
"completionTokens": "number",
"totalTokens": "number"
},
"creditUsage": "number",
"threadId": "string"
}
Error Responses
- 400 Bad Request: If the request is invalid
- 401 Unauthorized: If the API key is invalid or the user doesn’t have access to the specified agent
- 403 Forbidden: If the user doesn’t have enough credits
- 404 Not Found: If the specified agent or thread is not found
Notes
- This endpoint uses 10 credits per 1000 total tokens used.
- The agent must belong to the project owned by the authenticated user.
- If no threadId is provided, a new thread will be created automatically.
- Messages are stored in the thread for conversation history.
Rate Limiting
Rate limiting is applied based on the user’s subscription.Example Request
curl -X POST https://app.dumplingai.com/api/v1/agents/generate-completion \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"messages": [
{
"role": "user",
"content": "Hello, can you help me with a task?"
}
],
"agentId": "agent_123456",
"parseJson": false,
"threadId": "optional_thread_id"
}'
Example Response
{
"parsedJson": null,
"text": "Certainly! I'd be happy to help you with a task. What kind of task do you need assistance with?",
"stepsTaken": 1,
"steps": [
{
"text": "Certainly! I'd be happy to help you with a task. What kind of task do you need assistance with?",
"toolCalls": [],
"toolResults": [],
"finishReason": "stop",
"usage": {
"promptTokens": 20,
"completionTokens": 15,
"totalTokens": 35
}
}
],
"tokenUsage": {
"promptTokens": 20,
"completionTokens": 15,
"totalTokens": 35
},
"creditUsage": 1,
"threadId": "thread_123456"
}
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Parameters required to request an agent completion.
Identifier of the agent to run.
Ordered conversation history sent to the agent.
Show child attributes
Show child attributes
Optional thread identifier for continuing a previous conversation.
When true, attempt to parse the final response as JSON.
Optional identifier describing where the API request originated.
Available options:
API, WEB, MAKE_DOT_COM, ZAPIER, N8N, PLAYGROUND, DEFAULT_AUTOMATION, AGENT_PREVIEW, AGENT_LIVE, AUTOPILOT, STUDIO Response
Agent completion returned.