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
- 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 processing
parseJson
: Whether to try and parse the JSON in the response into a JSON object
threadId
: (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 1 credit 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"
}
Responses are generated using AI and may contain mistakes.