POST
/
v1
/
agents
/
{agentId}
/
run
{
  "output": "<string>",
  "session_id": "<string>",
  "metadata": {}
}

Execute an agent with the provided input to generate a response. Optionally maintain conversation context using a session ID.

Path Parameters

agentId
string
required

The unique identifier of the agent

Request Body

input
string
required

The input text for the agent to process

session_id
string

Optional session ID for continuing a conversation

Response

output
string

The agent’s response to the input

session_id
string

The session ID for this conversation

metadata
object

Additional information about the execution including model used, tokens, and tools

curl -X POST https://www.trytruffle.ai/api/v1/agents/agent_123/run \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "How can I help you today?",
    "session_id": "optional_session_123"
  }'
Response
{
    "success": true,
    "data": {
        "output": "I'm here to assist you with any questions or concerns you may have.",
        "session_id": "session_123",
        "metadata": {
            "model": "gpt-4",
            "tool_used": "search",
            "tokens": {
                "prompt": 150,
                "completion": 25,
                "total": 175
            }
        }
    },
    "status": 200
}