Skip to main content
POST
/
ai_chats
JavaScript
import Whop from '@whop/sdk';

const client = new Whop({
  apiKey: process.env['WHOP_API_KEY'], // This is the default and can be omitted
});

const aiChat = await client.aiChats.create({ message_text: 'message_text' });

console.log(aiChat.id);
{
  "id": "aich_xxxxxxxxxxxxx",
  "title": "Weekly Revenue Analysis",
  "message_count": 42,
  "blended_token_usage": "123.45",
  "created_at": "2023-12-01T05:00:00.401Z",
  "updated_at": "2023-12-01T05:00:00.401Z",
  "last_message_at": "2023-12-01T05:00:00.401Z",
  "user": {
    "id": "user_xxxxxxxxxxxxx"
  }
}

Authorizations

Authorization
string
header
required

A company API key, company scoped JWT, app API key, or user OAuth token. You must prepend your key/token with the word 'Bearer', which will look like Bearer ***************************

Body

application/json

Parameters for CreateAiChat

message_text
string
required

The text content of the first message to send to the AI agent.

current_company_id
string | null

The unique identifier of the company to set as context for the AI chat (e.g., "biz_XXXXX").

message_attachments
FileInputWithId · object[] | null

A list of previously uploaded file attachments to include with the first message.

message_source
enum<string> | null

The source of the message.

Available options:
manual,
suggestion,
link
title
string | null

An optional display title for the AI chat thread (e.g., "Help with billing").

Response

A successful response

An AI-powered chat conversation belonging to a user, with optional scheduled automation.

id
string
required

The unique identifier for the ai chat.

Example:

"aich_xxxxxxxxxxxxx"

title
string | null
required

A short descriptive title for this AI chat conversation. Null if no title has been set.

Example:

"Weekly Revenue Analysis"

message_count
integer
required

The total number of messages exchanged in this conversation.

Example:

42

blended_token_usage
string
required

The total number of tokens consumed across all messages in this conversation.

Example:

"123.45"

created_at
string<date-time>
required

The datetime the ai chat was created.

Example:

"2023-12-01T05:00:00.401Z"

updated_at
string<date-time>
required

The datetime the ai chat was last updated.

Example:

"2023-12-01T05:00:00.401Z"

last_message_at
string<date-time> | null
required

The timestamp of the most recent message in this conversation. Null if no messages have been sent yet.

Example:

"2023-12-01T05:00:00.401Z"

user
object
required

The user who owns this AI chat conversation.