Generate an AI response (beta)

このページは 日本語 ではまだ利用できません。デフォルトの言語 (English) で表示しています。

Generate an AI response (beta)

POSThttps://api.cekat.ai/api/ai_response/beta

Runs one of your AI agents on a chat history you provide and returns its reply, without sending anything to a contact. Use it to test an AI agent or to generate replies for your own channel.

The history must end with a message from the user. Each reply reports the AI credits it used. This endpoint is in beta and may change.

Authorization

api_keystringheaderrequired

Your Cekat API key, from Settings → Developers & API in the Cekat dashboard.

Authorizationstringheader

Alternative to api_key: send the same key as Bearer YOUR_API_KEY.

Body application/jsonrequired

ai_agent_idstring<uuid>required
messagesobject[]required

The chat history, oldest first. The last message must be from the user.

Show child attributes
rolestring
Available options: user, assistant
messagestring
created_atstring<date-time>
chat_dataobject

Data the AI agent collected earlier in this chat. Send back the chat_data from the previous response to continue the same chat.

Response

200
400
401
429
502

The AI agent's reply.

successboolean
messagesobject[]

The reply, plus system notes when the AI agent ran tools.

Show child attributes
rolestring
Available options: assistant, system
contentstring
credits_usednumber

AI credits used for this reply.

chat_dataobject

ai_agent_id is missing, messages is not an array, or there is no user message.

successboolean
messagestring
statusCodeinteger
errorobject
Show child attributes
messagestring
correlationIdstring

Request ID. Include it when contacting Cekat support.

The API key is missing or invalid.

successboolean
messagestring
statusCodeinteger
errorobject
Show child attributes
messagestring
correlationIdstring

Request ID. Include it when contacting Cekat support.

Rate limit exceeded. Wait and retry.

messagestring

The AI service is unavailable. Retry later.

successboolean
messagestring
statusCodeinteger
errorobject
Show child attributes
messagestring
correlationIdstring

Request ID. Include it when contacting Cekat support.

POST/api/ai_response/beta
cURL
JavaScript
Python
PHP
curl --request POST \
  --url 'https://api.cekat.ai/api/ai_response/beta' \
  --header 'api_key: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "ai_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "messages": [
    {
      "role": "user",
      "message": "<string>",
      "created_at": "2026-01-15T09:30:00Z"
    }
  ]
}'
const response = await fetch('https://api.cekat.ai/api/ai_response/beta', {
  method: 'POST',
  headers: { 'api_key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "ai_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "messages": [
      {
        "role": "user",
        "message": "<string>",
        "created_at": "2026-01-15T09:30:00Z"
      }
    ]
  })
});

const data = await response.json();
console.log(data);
import requests

url = "https://api.cekat.ai/api/ai_response/beta"
headers = {"api_key": "YOUR_API_KEY"}
payload = {
    "ai_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "messages": [
        {
            "role": "user",
            "message": "<string>",
            "created_at": "2026-01-15T09:30:00Z"
        }
    ]
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://api.cekat.ai/api/ai_response/beta',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => ['api_key: YOUR_API_KEY', 'Content-Type: application/json'],
  CURLOPT_POSTFIELDS => json_encode([
    'ai_agent_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
    'messages' => [[
      'role' => 'user',
      'message' => '<string>',
      'created_at' => '2026-01-15T09:30:00Z'
    ]]
  ]),
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
200
400
401
429
502
{
  "success": true,
  "messages": [
    {
      "role": "assistant",
      "content": "<string>",
      "credits_used": 10000
    }
  ],
  "chat_data": {}
}
{
  "success": true,
  "message": "<string>",
  "statusCode": 1,
  "error": {
    "message": "<string>"
  },
  "correlationId": "<string>"
}
{
  "success": true,
  "message": "<string>",
  "statusCode": 1,
  "error": {
    "message": "<string>"
  },
  "correlationId": "<string>"
}
{
  "message": "<string>"
}
{
  "success": true,
  "message": "<string>",
  "statusCode": 1,
  "error": {
    "message": "<string>"
  },
  "correlationId": "<string>"
}