Send messages and receive AI responses

Chat Endpoint

Send a user message and receive an AI-generated response.

Endpoint

text
POST /api/chat

Request Body

FieldTypeRequiredDescription
text
message
stringYesThe user's message (max 2,000 chars)
text
session_id
stringYesUnique conversation identifier — use a stable ID per user/session (e.g. a UUID you generate on the client)
text
metadata
objectNoOptional context passed to the agent
text
metadata.url
stringNoCurrent page URL
text
metadata.title
stringNoCurrent page title

Example Request

json
{
  "message": "Hello! I need help with my order.",
  "session_id": "user-abc-123"
}

Response

200 OK

json
{
  "reply": "I'd be happy to help you with your order! Could you please provide your order number?",
  "session_id": "user-abc-123"
}
[!TIP] The
text
reply
field often contains Markdown (bold, code blocks, etc.). We recommend using a library like marked or react-markdown to render these correctly in your application.

Error Responses

See Error Handling for details.

Full Example

cURL

bash
curl -X POST https://ai.vindex.ai/api/chat \
  -H "Content-Type: application/json" \
  -H "X-API-Key: amgai_your-channel-key-here" \
  -d '{
    "message": "What is the capital of France?",
    "session_id": "test-001"
  }'

JavaScript

javascript
const response = await fetch('https://ai.vindex.ai/api/chat', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'amgai_your-channel-key-here'
  },
  body: JSON.stringify({
    message: 'What is the capital of France?',
    session_id: 'test-001'
  })
});

const data = await response.json();
console.log(data.reply); // "The capital of France is Paris."

Python

python
import requests

response = requests.post(
    'https://ai.vindex.ai/api/chat',
    headers={
        'Content-Type': 'application/json',
        'X-API-Key': 'amgai_your-channel-key-here'
    },
    json={
        'message': 'What is the capital of France?',
        'session_id': 'test-001'
    }
)

print(response.json()['reply'])  # "The capital of France is Paris."