Skip to main content
POST
/
ai
/
assistants
/
{assistant_id}
/
chat
JavaScript
import Telnyx from 'telnyx';

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

const response = await client.ai.assistants.chat('assistant_id', {
  content: 'Tell me a joke about cats',
  conversation_id: '42b20469-1215-4a9a-8964-c36f66b406f4',
});

console.log(response.content);
import os
from telnyx import Telnyx

client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.ai.assistants.chat(
assistant_id="assistant_id",
content="Tell me a joke about cats",
conversation_id="42b20469-1215-4a9a-8964-c36f66b406f4",
)
print(response.content)
package main

import (
"context"
"fmt"

"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)

func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.AI.Assistants.Chat(
context.TODO(),
"assistant_id",
telnyx.AIAssistantChatParams{
Content: "Tell me a joke about cats",
ConversationID: "42b20469-1215-4a9a-8964-c36f66b406f4",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Content)
}
package com.telnyx.sdk.example;

import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.ai.assistants.AssistantChatParams;
import com.telnyx.sdk.models.ai.assistants.AssistantChatResponse;

public final class Main {
private Main() {}

public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();

AssistantChatParams params = AssistantChatParams.builder()
.assistantId("assistant_id")
.content("Tell me a joke about cats")
.conversationId("42b20469-1215-4a9a-8964-c36f66b406f4")
.build();
AssistantChatResponse response = client.ai().assistants().chat(params);
}
}
require "telnyx"

telnyx = Telnyx::Client.new(api_key: "My API Key")

response = telnyx.ai.assistants.chat(
"assistant_id",
content: "Tell me a joke about cats",
conversation_id: "42b20469-1215-4a9a-8964-c36f66b406f4"
)

puts(response)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');

try {
$response = $client->ai->assistants->chat(
'assistant_id',
content: 'Tell me a joke about cats',
conversationID: '42b20469-1215-4a9a-8964-c36f66b406f4',
name: 'Charlie',
);

var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}
telnyx ai:assistants chat \
--api-key 'My API Key' \
--assistant-id assistant_id \
--content 'Tell me a joke about cats' \
--conversation-id 42b20469-1215-4a9a-8964-c36f66b406f4
curl --request POST \
--url https://api.telnyx.com/v2/ai/assistants/{assistant_id}/chat \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": "Tell me a joke about cats",
"conversation_id": "42b20469-1215-4a9a-8964-c36f66b406f4",
"name": "Charlie"
}
'
{
  "content": "Why did the cat sit on the computer? Because it wanted to keep an eye on the mouse!"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

assistant_id
string
required

Unique identifier of the assistant.

Body

application/json
content
string
required

The message content sent by the client to the assistant

Example:

"Tell me a joke about cats"

conversation_id
string
required

A unique identifier for the conversation thread, used to maintain context

Example:

"42b20469-1215-4a9a-8964-c36f66b406f4"

name
string

The optional display name of the user sending the message

Example:

"Charlie"

Response

Successful Response

content
string
required

The assistant's generated response based on the input message and context.

Example:

"Why did the cat sit on the computer? Because it wanted to keep an eye on the mouse!"