Chat API

Send messages and receive AI-powered responses programmatically

Send a Chat Message

POST /api/v1/chat
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "message": "Hello, I need help",
  "sessionId": "unique-session-id"
}

Request Parameters

ParameterTypeRequiredDescription
messagestringYesThe user's message
sessionIdstringYesUnique session identifier for conversation context

Response

{
  "response": "Hello! How can I help you today?",
  "sessionId": "unique-session-id",
  "metadata": {
    "tokensUsed": 150,
    "model": "gpt-4o-mini"
  }
}

Example: JavaScript

const response = await fetch('https://aiworkers.vip/api/v1/chat', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    message: 'What are your business hours?',
    sessionId: 'user-session-123'
  })
})

const data = await response.json()
console.log(data.response)

Example: Python

import requests

response = requests.post(
    'https://aiworkers.vip/api/v1/chat',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
    },
    json={
        'message': 'What are your business hours?',
        'sessionId': 'user-session-123'
    }
)

data = response.json()
print(data['response'])