Skip to main content

Create chat completions

This article provides an example of calling the Create chat completions API.


This API is only available to whitelisted users. Click here to apply


Assuming you have an AI agent and you want to chat with it.

Follow these steps:

  1. Get your API Token. (How to get it)

  2. Get your AI agent ID. (Open the setting panel of the AI agent, you can see the Bot ID on the top)

  3. Open the terminal on your computer and execute the following code to send an API request to the server (assuming the Bot ID is ai_zxLeHGV3ac32YYC):

    curl -X POST \
    "" \
    -H "Authorization: Bearer {Your API Token}" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "gpt-3.5-turbo",
    "messages": [
    "role": "system",
    "content": "You are a helpful assistant."
    "role": "user",
    "content": "Hello!"
  4. The server will return the following JSON data

    For the meaning of each parameter in the response, please check the API Reference

    "id": "aitable_ai_CkZH2zQokhry31j_1693452659",
    "conversation id": "CS-0253eb8d-d6c6-4543-88d4-fcb555f52982",
    "actions": null,
    "object": "chat.completion",
    "created": 1693452659,
    "choices": [{
    "index": 0,
    "message": {
    "role": "assistant",
    "content": "\n\nHello there, how may I assist you today",
    "finish_reason": "stop"
    "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21,
    "total cost": 7.900000000000001e-05,
    "result": "I am an AI, specifically a language model developed by OpenAI."