curl -X POST "https://agent.api.lyzr.app/v2/chat/" \
     -H "accept: application/json" \
     -H "Content-Type: application/json" \
     -H "x-api-key: your_Lyzr_API_Key_Here" \
     -d '{
           "user_id": "user123",
           "agent_id": "60d0fe4f531xxxxxx",
           "session_id": "session123",
           "message": "Hello, how can I improve my productivity?"
         }'
{
    "response": "To improve productivity, you can focus on time management, set clear goals, and minimize distractions."
}

Endpoint: POST /v2/chat/

This endpoint allows interaction with an agent by sending a chat request. This enables a user to initiate or continue a conversation with the agent by passing relevant session data.

Parameters

user_id
string
required

The unique identifier of the user interacting with the agent.

agent_id
string
required

The unique identifier of the agent handling the chat.

session_id
string
required

The session ID to maintain context across multiple interactions.

message
string
required

The user’s message or query to the agent.

Curl
curl -X POST "https://agent.api.lyzr.app/v2/chat/" \
     -H "accept: application/json" \
     -H "Content-Type: application/json" \
     -H "x-api-key: your_Lyzr_API_Key_Here" \
     -d '{
           "user_id": "user123",
           "agent_id": "60d0fe4f531xxxxxx",
           "session_id": "session123",
           "message": "Hello, how can I improve my productivity?"
         }'
Python
import requests

url = "https://agent.api.lyzr.app/v2/chat/"

data = {
    "user_id": "user123",  # Replace with actual user ID
    "agent_id": "60d0fe4f531xxxxx",  # Replace with actual agent ID
    "session_id": "session123",  # Replace with actual session ID
    "message": "Hello, how can I improve my productivity?"
}

headers = {
    "Content-Type": "application/json",
    "x-api-key": "your_Lyzr_API_Key_Here"
}

response = requests.post(url, headers=headers, json=data)
{
    "response": "To improve productivity, you can focus on time management, set clear goals, and minimize distractions."
}

Response Parameters

response
string

The agent’s reply based on the user’s input message.