Send a user message and receive an AI-generated response.
Endpoint
text
POST /api/chat
Request Body
Field
Type
Required
Description
text
message
string
Yes
The user's message (max 2,000 chars)
text
session_id
string
Yes
Unique conversation identifier — use a stable ID per user/session (e.g. a UUID you generate on the client)
text
metadata
object
No
Optional context passed to the agent
text
metadata.url
string
No
Current page URL
text
metadata.title
string
No
Current 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.
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."