Chats

TypeScript SDK reference for the chats resource

Warning

The SDKs are in research preview. Their interfaces may change between minor versions until 1.0.

Access this resource from client.chats.

createForAnalysis

POST /v1/chats

const result = await client.chats.createForAnalysis(versionId);

Arguments:

versionIdstringbodyrequired

Returns: Chat

show properties (7)hide properties (7)
idstringrequired
created_atstringrequired
code_idstringrequired
version_idstring | nullrequired
titlestring | nullrequired
chat_typeChatTyperequired
total_messagesnumberrequired

createForCode

POST /v1/chats

const result = await client.chats.createForCode(codeId);

Arguments:

codeIdstringbodyrequired

Returns: Chat

show properties (7)hide properties (7)
idstringrequired
created_atstringrequired
code_idstringrequired
version_idstring | nullrequired
titlestring | nullrequired
chat_typeChatTyperequired
total_messagesnumberrequired

list

GET /v1/chats

Chats in the project.

const result = await client.chats.list();

Arguments:

queryChatListParamsquery
pagenumber
page_sizenumber
code_idstring
version_idstring
chat_typeChatType
order_by"created_at" | "updated_at"
order"desc" | "asc"

Return type by call:

  • withPagination: true → PaginatedResource<Chat>
  • withPagination: false → Pagination<Chat>
show properties (6)hide properties (6)
resultsChat[]required
show properties (7)hide properties (7)
idstringrequired
created_atstringrequired
code_idstringrequired
version_idstring | nullrequired
titlestring | nullrequired
chat_typeChatTyperequired
total_messagesnumberrequired
pagenumberrequired
page_sizenumberrequired
morebooleanrequired

Whether more pages follow.

total_observationsnumberrequired

Total results across all pages.

total_pagesnumberrequired

get

GET /v1/chats/{chat_id}

const result = await client.chats.get(chatId);

Arguments:

chatIdstringpathrequired

Returns: Chat

show properties (7)hide properties (7)
idstringrequired
created_atstringrequired
code_idstringrequired
version_idstring | nullrequired
titlestring | nullrequired
chat_typeChatTyperequired
total_messagesnumberrequired

messages

GET /v1/chats/{chat_id}/messages

const result = await client.chats.messages(chatId);

Arguments:

chatIdstringpathrequired

Returns: ResultsResponse<ChatMessage>

show properties (1)hide properties (1)
resultsChatMessage[]required
show properties (8)hide properties (8)
idstringrequired
created_atstringrequired
chat_idstringrequired
chat_roleChatMessageRolerequired
messagestringrequired
refsInlineRef[]required
show properties (6)hide properties (6)
idstringrequired
typestringrequired
sourcestringrequired
ref_indnumberrequired
namestring | nullrequired
is_stalebooleanrequired
has_proposalbooleanrequired
proposal_status"pending" | "approved" | "rejected" | nullrequired

sync

POST /v1/chats/{chat_id}/sync

Send a message and wait for the full reply.

const result = await client.chats.sync(chatId, body);

Arguments:

chatIdstringpathrequired
bodyChatCreateMessageBodybodyrequired
messagestringrequired
is_retryboolean
approval_idstring
is_approvedboolean

Returns: ChatMessage

show properties (8)hide properties (8)
idstringrequired
created_atstringrequired
chat_idstringrequired
chat_roleChatMessageRolerequired
messagestringrequired
refsInlineRef[]required
show properties (6)hide properties (6)
idstringrequired
typestringrequired
sourcestringrequired
ref_indnumberrequired
namestring | nullrequired
is_stalebooleanrequired
has_proposalbooleanrequired
proposal_status"pending" | "approved" | "rejected" | nullrequired

sessionToken

POST /v1/chats/{chat_id}/session-token

A single-use token for one chat stream. Generate it server-side.

const result = await client.chats.sessionToken(chatId);

Arguments:

chatIdstringpathrequired

Returns: string

stream

POST /v1/chats/{chat_id}/stream

Use session_token() for initial request

Send a message and stream the reply.

for await (const item of client.chats.stream(chatId, sessionToken, body)) {
	// ...
}

Arguments:

chatIdstringpathrequired
sessionTokenstringbodyrequired
bodyChatCreateStreamMessageBodybodyrequired
messagestringrequired
is_retryboolean
approval_idstring
is_approvedboolean
tokenstringrequired

Returns: AsyncGenerator<ChatMessageStream>

Scoped access

client.chats.with(chatId) returns these methods with chatId already bound.

On this page