├── example.ts ├── example.cjs ├── postinstall_info.js ├── package.json └── README.md /example.ts: -------------------------------------------------------------------------------- 1 | import {CAINode} from "./index.js" 2 | 3 | const Char_AI = new CAINode() 4 | await Char_AI.login("Your Character.AI Token"); 5 | console.log("it works!") 6 | await Char_AI.logout(); 7 | -------------------------------------------------------------------------------- /example.cjs: -------------------------------------------------------------------------------- 1 | (async function() { 2 | const Char_AI = (await import("./index.js")).CAINode(); 3 | await Char_AI.login("Your Character AI Token"); 4 | console.log("Login successfully"); 5 | await Char_AI.logout(); 6 | })(); 7 | -------------------------------------------------------------------------------- /postinstall_info.js: -------------------------------------------------------------------------------- 1 | console.log(`CAINode is now using ESM (ECMAScript Module). 2 | 3 | To use this library, Please read the Documentation first at here: https://github.com/KevinAdhaikal/CAINode?tab=readme-ov-file#getting-started 4 | To give an idea or report a bug, you can go here: https://github.com/KevinAdhaikal/CAINode/issues 5 | 6 | Thank you.`) -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cainode", 3 | "version": "1.2.3", 4 | "description": "A lightweight unofficial Character.AI API using Node JS", 5 | "main": "index.js", 6 | "type": "module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "postinstall": "node postinstall_info.js", 10 | "posti": "node postinstall_info.js" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/kevinadhaikal/cainode.git" 15 | }, 16 | "keywords": [ 17 | "character", 18 | "ai", 19 | "character-ai", 20 | "api", 21 | "character-ai-unofficial-api", 22 | "characterai-nodejs", 23 | "cainode" 24 | ], 25 | "dependencies": { 26 | "@types/bun": "^1.3.2", 27 | "ws": "^8.17.1" 28 | }, 29 | "optionalDependencies": { 30 | "@livekit/rtc-node": "^0.11.1", 31 | "ws": "^8.17.1" 32 | }, 33 | "author": "KevinAdhaikal", 34 | "license": "ISC", 35 | "bugs": { 36 | "url": "https://github.com/kevinadhaikal/cainode/issues" 37 | }, 38 | "homepage": "https://github.com/kevinadhaikal/cainode#readme" 39 | } 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CAINode 2 | **The Lightweight Unofficial Character.AI API for Node.js / Deno / Bun** 3 | 4 | Access Character.AI via pure JavaScript – **no Puppeteer**, **no browser automation**, just WebSocket + HTTPS. 5 | Built for developers who want to **chat with Character.AI programmatically** using modern JavaScript runtimes (Node, Deno, Bun). 6 | 7 | > ⭐️ Easy-to-use API | 🔥 Lightweight & Fast | 💬 Supports Streaming & History | 🧠 Designed for Bots, CLI & Automation 8 | 9 | --- 10 | 11 | [![NPM Version](https://img.shields.io/npm/v/cainode?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/cainode) 12 | [![GitHub Stars](https://img.shields.io/github/stars/kevinadhaikal/cainode?style=for-the-badge&logo=github)](https://github.com/kevinadhaikal/cainode) 13 | [![GitHub Repo Size](https://img.shields.io/github/repo-size/kevinadhaikal/cainode?style=for-the-badge&logo=github)](https://github.com/kevinadhaikal/cainode) 14 | [![Last Commit](https://img.shields.io/github/last-commit/kevinadhaikal/cainode?style=for-the-badge&logo=git)](https://github.com/kevinadhaikal/cainode) 15 | [![Commit Activity](https://img.shields.io/github/commit-activity/t/kevinadhaikal/cainode?style=for-the-badge&logo=github)](https://github.com/kevinadhaikal/cainode) 16 | 17 | --- 18 | 19 | ## 🚀 Features 20 | CAINode supports nearly **all Character.AI features** – designed for both simple and advanced use cases: 21 | 22 | ### ⚙️ Core Features 23 | - ✅ **Lightweight** – No Puppeteer, no headless browser. Uses native WebSocket + Fetch 24 | - ✅ **Cross-runtime** – Works with **Node.js**, **Deno**, and **Bun** 25 | - ✅ **Fully Async** – Promise-based, easy integration 26 | - ✅ **Streaming Chat Support** – Typing-style responses, streamed token by token 27 | 28 | ### 💬 Chat Support 29 | - 🧠 **Single Chat** – Chat with any character 30 | - 👥 **Group Chat** – Chat with multiple characters in one conversation 31 | - 📝 **Chat History** – Fetch previous messages with metadata 32 | - 🎤 **Voice Call Support** – Full support for voice interactions with characters 33 | 34 | ### 🧩 Character & User Control 35 | - 🔍 **Search Characters** – Explore, get trending, featured, or searched characters 36 | - 👤 **User Profiles** – Fetch profile data, persona, and more 37 | - 🧠 **Persona Management** – Edit and apply custom persona to your characters 38 | 39 | ### 🖼️ Media & Generation 40 | - 🖼️ **Image Generation** – Send prompts, receive image replies 41 | - 🎨 **Image Uploading Support** – Upload image to use in messages 42 | 43 | --- 44 | 45 | ### 💥 Bonus 46 | - ⚡ **Blazingly Fast** – Low latency communication via WebSocket 47 | - 📚 **Typed (with JSDoc)** – Great autocomplete in editors like VSCode 48 | 49 | # Table of contents 50 | - [Getting Started](#getting-started) 51 | - [Install](#install) - How to Install CAINode Library. 52 | - [Example Usage](#example-usage) - Example Usage to using CAINode Library. 53 | - [Main Function List](#main-function-list) 54 | - [login](#login) - Start client initialization with login. 55 | - [generate_token_auto](#generate_token_auto) - Generate your Character.AI Token by email. and you will get the token by just pressing the button when you receive the email. 56 | - [ping](#ping) - Pings the Character AI server's health check endpoint. 57 | - [logout](#logout) - Logout from the Character.AI. 58 | - [User Function List](#user-function-list) 59 | - [user.info](#userinfo) - Get current information account. 60 | - [user.change_info](#userchange_info) - Change current information account. 61 | - [user.settings](#usersettings) - Get current settings information account. 62 | - [user.refresh_settings](#userrefresh_settings) - Refresh current user settings. 63 | - [user.update_settings](#userupdate_settings) - Update user settings by your own settings. 64 | - [user.public_info](#userpublic_info) - Get user public information account. 65 | - [user.public_info_array](#userpublic_info_array) - Get user public information account. same like `public_info()`, but this function have less information. 66 | - [user.public_following_list](#userpublic_following_list) - Get public user following list. 67 | - [user.public_followers_list](#userpublic_followers_list) - Get public user followers list. 68 | - [user.following_check](#userfollowing_check) - Check are you following this user account or not. 69 | - [user.following_list_name](#userfollowing_list_name) - Get account following name list. 70 | - [user.followers_list_name](#userfollowers_list_name) - Get account followers name list. 71 | - [user.follow](#userfollow) - Follow user account. 72 | - [user.unfollow](#userunfollow) - Unfollow user account. 73 | - [user.liked_character_list](#userliked_character_list) - Get a list of characters that the account likes. 74 | - [user.add_muted_words](#useradd_muted_words) - Add muted words. 75 | - [user.remove_muted_words](#userremove_muted_words) - Remove muted words. 76 | - [user.clear_muted_words](#userclear_muted_words) - Clear muted words. 77 | - [Image Function List](#image-function-list) 78 | - [image.generate_avatar](#imagegenerate_avatar) - Generate avatar image using prompt. 79 | - [image.generate_image](#imagegenerate_image) - Generate image using prompt. 80 | - [Search Function List](#search-function-list) 81 | - [search.list_tags](#searchlist_tags) - Get list of tags. 82 | - [search.users](#searchusers) - Search users by name. 83 | - [search.scenes](#searchscenes) - Search scenes by query. 84 | - [search.characters](#searchcharacters) - Search for a characters by name. 85 | - [search.voices](#searchvoices) - Search for a voices by name. 86 | - [search.popular](#searchpopular) - Get popular search. 87 | - [search.trending](#searchtrending) - Get trending search. 88 | - [search.autocomplete](#searchautocomplete) - Get autocomplete search. 89 | - [search.languages](#searchlanguages) - Get languages list. 90 | - [Persona Function List](#persona-function-list) 91 | - [persona.create](#personacreate) - Create your personality for your character. 92 | - [persona.set_default](#personaset_default) - Set your default personality specifically. 93 | - [persona.list](#personalist) - Get all your personality data. 94 | - [persona.info](#personainfo) - Get your personality information. 95 | - [persona.update](#personaupdate) - Update your personality specifically. 96 | - [persona.delete](#personadelete) - Delete your personality spesifically. 97 | - [persona.set_character](#personaset_character) - Set a custom personality for your character specifically. 98 | - [Explore Function List](#explore-function-list) 99 | - [explore.featured](#explorefeatured) - Get a list of characters displayed by the Character.AI server. 100 | - [explore.for_you](#explorefor_you) - Get a list of characters recommended by the Character.AI server. 101 | - [explore.simillar_char](#exploresimillar_char) - Get a list of simillar character from ID character. 102 | - [explore.character_categories](#explorecharacter_categories) - Get a list of characters from the character category exploration. 103 | - [explore.featured_voices](#explorefeatured_voices) - Get a list of featured voices. 104 | - [Character Function list](#character-function-list) 105 | - [character.votes](#charactervotes) - Get character vote information. 106 | - [character.votes_array](#charactervotes_array) - Get character vote information in array. 107 | - [character.vote](#charactervote) - Used for vote the character. 108 | - [character.info](#characterinfo) - Get detailed information about characters. 109 | - [character.recent_list](#characterrecent_list) - Get a list of recent chat activity. 110 | - [character.connect](#characterconnect) - Connect client to character chat. 111 | - [character.disconnect](#characterdisconnect) - Disconnecting client from character chat. 112 | - [character.send_message](#charactersend_message) - Send message to character. 113 | - [character.generate_turn](#charactergenerate_turn) - Generating message response from character. 114 | - [character.generate_turn_candidate](#charactergenerate_turn_candidate) - Regenerate character message. 115 | - [character.create_new_conversation](#charactercreate_new_conversation) - it will create a new conversation and your current conversation will save on the history. 116 | - [character.delete_message](#characterdelete_message) - Delete character message. 117 | - [character.edit_message](#characteredit_message) - Edit the character message. 118 | - [character.replay_tts](#characterreplay_tts) - Generate text messages from character to voice audio. 119 | - [character.current_voice](#charactercurrent_voice) - Get character current voice info. 120 | - [character.get_category](#characterget_category) - Get category used of the character. 121 | - [character.about](#characterabout) - Get detailed information of the character about. 122 | - [character.info_detailed](#characterinfo_detailed) - Get detailed of the character. but, it will give you a FULL detailed of the Character, including character definition. 123 | - [Group Chat Function List](#group-chat-function-list) 124 | - [group_chat.list](#group_chatlist) - Get all list available group chat in account. 125 | - [group_chat.connect](#group_chatconnect) - Connecting to group chat by the Room ID. 126 | - [group_chat.disconnect](#group_chatdisconnect) - Disconnect from group chat. 127 | - [group_chat.create](#group_chatcreate) - Create group chat. 128 | - [group_chat.delete](#group_chatdelete) - Delete group chat. 129 | - [group_chat.rename](#group_chatrename) - Rename group chat. 130 | - [group_chat.join_group_invite](#group_chatjoin_group_invite) - Joining group chat using invite code. 131 | - [group_chat.char_add](#group_chatchar_add) - Add a character with Character ID to the group chat. 132 | - [group_chat.char_remove](#group_chatchar_remove) - Remove a character with Character ID from the group chat. 133 | - [group_chat.send_message](#group_chatsend_message) - Send message to group chat. 134 | - [group_chat.generate_turn](#group_chatgenerate_turn) - Generating message response character from group chat. 135 | - [group_chat.generate_turn_candidate](#group_chatgenerate_turn_candidate) - Regenerate character message. 136 | - [group_chat.reset_conversation](#group_chatreset_conversation) - Reset conversation in group chat. 137 | - [group_chat.delete_message](#group_chatdelete_message) - Delete user/character message. 138 | - [group_chat.edit_message](#group_chatedit_message) - Edit user/character message. 139 | - [group_chat.select_turn](#group_chatselect_turn) - Select the turn of character chat by yourself. 140 | - [Chat Function List](#chat-function-list) 141 | - [chat.history_chat_turns](#chathistory_chat_turns) - Get a history chat from group or single chat. 142 | - [chat.conversation_info](#chatconversation_info) - Get converastion information. 143 | - [chat.history_conversation_list](#chathistory_conversation_list) - Get list of your history conversation from character. This function is for Single character only. 144 | - [chat.set_conversation_chat](#chatset_conversation_chat) - Set conversation chat, and bring the history chat into current chat. This function is for Single character only. 145 | - [chat.pin_message](#chatpin_message) - Pin message. This function is for Single character only. 146 | - [chat.list_pinned_message](#chatlist_pinned_message) - Get list pinned message from chat. This function works only for single character chat. 147 | - [chat.archive_conversation](#chatarchive_conversation) - Archive your conversation. This function works only for single character chat. 148 | - [chat.duplicate_conversation](#chatduplicate_conversation) - Duplicate your conversation. This function works only for single character chat. 149 | - [chat.rename_conversation](#chatrename_conversation) - Rename your conversation title. This function works only for single character chat. 150 | - [chat.conversation_facts](#chatconversation_facts) - i dont know what is this. but maybe this is for getting the facts of your conversation, i guess...? 151 | - [Voice Function List](#voice-function-list) 152 | - [voice.user_created_list](#voiceuser_created_list) - Get list of user created voice information. 153 | - [voice.info](#voiceinfo) - Get a voice information. 154 | - [voice.connect](#voiceconnect) - Connect to voice character chat, and this function works only for single character chat. 155 | - [Livekit Function List](#livekit-function-list) - (when you're connected to the character voice) 156 | - [voice.connect().is_character_speaking](#voiceconnectis_character_speaking) - Check is Character is speaking or not. 157 | - [voice.connect().on event](#voiceconnecton-event) - List and Description of Livekit onevent. 158 | - [voice.connect().input_write](#voiceconnectinput_write) - Send audio PCM raw data to the Livekit Server. 159 | - [voice.connect().is_speech](#voiceconnectis_speech) - this function checking is the PCM buffer frame is silence or not. 160 | - [voice.connect().interrupt_call](#voiceconnectinterrupt_call) - Interrupt while character talking. 161 | - [voice.connect().disconnect](#voiceconnectdisconnect) - Disconnect from voice character. 162 | - [Notification Function List](#notification-function-list) 163 | - [notification.history](#notificationhistory) - Get all of the history notification. 164 | - [notivication.history_v2](#notificationhistory_v2) - Get all of the history notification (Version 2) 165 | - [Issues](#issues) 166 | 167 | # Getting Started 168 | ## Install 169 | To install CAINode, you can simply do 170 | - using NPM (Node Package Manager)

171 | ``` 172 | npm install -g cainode 173 | ``` 174 | - Using Deno

175 | ```ts 176 | import CAINode from "npm:cainode@latest"; 177 | ``` 178 | - Using Bun.JS

179 | ``` 180 | bun install cainode 181 | ``` 182 | [Back to the Table of contents](#table-of-contents) 183 | ## Example usage 184 | - CommonJS

185 | ```js 186 | (async function() { 187 | const client = new (await import("cainode")).CAINode(); 188 | await client.login("Your token"); 189 | console.log("Logged in!"); 190 | await client.logout(); 191 | })() 192 | ``` 193 | - TypeScript/ESM

194 | ```ts 195 | import {CAINode} from "cainode" 196 | // import {CAINode} from "npm:cainode@latest"; for Deno 197 | 198 | const client = new CAINode(); 199 | 200 | await client.login("Your token"); 201 | console.log("Logged in!"); 202 | await client.logout(); 203 | ``` 204 | [Back to the Table of contents](#table-of-contents) 205 | 206 | # Main Function List 207 | - ## login() 208 | Start client initialization with login, make sure your token is valid so that the login session can run properly. 209 | 210 | To get Character.AI Session Token, You can use [generate_token()](#generate_token) function. 211 | 212 | ```js 213 | await client.login("YOUR_CHARACTER_AI_TOKEN"); 214 | ``` 215 | | Param | Require | Type | Description | 216 | | --- | --- | --- | --- | 217 | | Token | `true` | `string` | Your Character.AI token used for client login. | 218 | 219 | [Back to the Table of contents](#table-of-contents) 220 | 221 | - ## generate_token_auto() 222 | Generate your Character.AI Token by email. and you will get the token by just pressing the button when you receive the email. 223 | 224 | Parameter Info 225 | - 1st parameter `email`: Target email you want to generate the token. 226 | - 2nd parameter: Timeout per 2 seconds (default 30, so it means = 60 seconds or 1 minute)
227 | You can disable the Timeout by set the parameter into 0. 228 | 229 | Example: 230 | 231 | - Without Timer 232 | ```js 233 | console.log(await library_name.generate_token_auto("your@email.com", 0)) 234 | ``` 235 | - With Timer 236 | ```js 237 | console.log(await library_name.generate_token_auto("your@email.com", 60)) 238 | ``` 239 | - With callback 240 | ```js 241 | console.log(await library_name.generate_token_auto("your@email.com", 30, function() {console.log("Please check your email")}, function() {console.log("timeout!")})) 242 | ``` 243 | 244 | | Param | Require | Type | Description | 245 | | --- | --- | --- | --- | 246 | | email | `true` | `string` | Your email to send a verification link. | 247 | | timeout_per_2s | `false` | `number` | Max waiting for verification. (default = 30) | 248 | | mail_sent_cb | `false` | `Function` | Callback when the mail was sent to the target. | 249 | | timeout_cb | `false` | `Function` | Callback when the timeout was reached. | 250 | 251 | [Back to the Table of contents](#table-of-contents) 252 | 253 | - ## ping() 254 | Pings the Character AI server's health check endpoint. 255 | 256 | ```js 257 | await client.ping(); 258 | ``` 259 | | Param | Require | Type | Description | 260 | | --- | --- | --- | --- | 261 | | none | `false` | `null` | - | 262 | 263 | [Back to the Table of contents](#table-of-contents) 264 | 265 | - ## logout() 266 | Logout from the client. 267 | 268 | ```js 269 | await client.logout(); 270 | ``` 271 | | Param | Require | Type | Description | 272 | | --- | --- | --- | --- | 273 | | none | `false` | `null` | - | 274 | 275 | [Back to the Table of contents](#table-of-contents) 276 | 277 | # User Function List 278 | > This class contains variables and methods about the User requirement. For example: Get current information account, Change account, etc about user needs. 279 | - ## user.info 280 | Get current information account. 281 | 282 | Example 283 | ```js 284 | console.log(client.user.info); 285 | ``` 286 | | Param | Require | Type | Description | 287 | | --- | --- | --- | --- | 288 | | none | `false` | `null` | - | 289 | 290 | [Back to the Table of contents](#table-of-contents) 291 | 292 | - ## user.public_info() 293 | Get user public information account. 294 | 295 | ```js 296 | await client.user.public_info(); 297 | ``` 298 | | Param | Require | Type | Description | 299 | | --- | --- | --- | --- | 300 | | username | `false` | `string` | Target Character.AI username account. (default = null, and it will target to your own account.) | 301 | 302 | [Back to the Table of contents](#table-of-contents) 303 | 304 | 305 | - ## user.public_info_array() 306 | Get user public information account. same like `public_info()`, but this function have less information. 307 | 308 | This function allow to fetch more than one usernames. Using array. 309 | 310 | ```js 311 | await client.user.public_info_array(); 312 | ``` 313 | | Param | Require | Type | Description | 314 | | --- | --- | --- | --- | 315 | | usernames | `true` | `Array or string` | Target Character.AI username account. can be single (string) or multiple (array). | 316 | 317 | [Back to the Table of contents](#table-of-contents) 318 | 319 | 320 | - ## user.change_info() 321 | Change current information account. 322 | 323 | ```js 324 | await client.user.change_info(); 325 | ``` 326 | | Param | Require | Type | Description | 327 | | --- | --- | --- | --- | 328 | | username | `false` | `string` | Change your old username to new username. | 329 | | name | `false` | `string` | Change your old name to new name. | 330 | | avatar_rel_path | `false` | `string` | Change your old `avatar_rel_path` link to new `avatar_rel_path` link.

Warning: `avatar_rel_path` image link must be generated/uploaded to Character.AI server. | 331 | | bio | `false` | `string` | Change your old bio to new bio. | 332 | 333 | [Back to the Table of contents](#table-of-contents) 334 | 335 | 336 | - ## user.settings() 337 | Get account settings information data. 338 | 339 | ```js 340 | console.log(client.user.settings) 341 | ``` 342 | 343 | | Param | Require | Type | Description | 344 | | --- | --- | --- | --- | 345 | | none | `false` | `null` | - | 346 | 347 | [Back to the Table of contents](#table-of-contents) 348 | 349 | 350 | - ## user.refresh_settings() 351 | Refresh settings. also it will returns the current of the settings. 352 | no need to do `library_name.user.settings` after call this function. 353 | You can do console.log() instead. 354 | 355 | ```js 356 | await library_name.user.refresh_settings() 357 | ``` 358 | 359 | | Param | Require | Type | Description | 360 | | --- | --- | --- | --- | 361 | | none | `false` | `null` | - | 362 | 363 | [Back to the Table of contents](#table-of-contents) 364 | 365 | 366 | - ## user.update_settings() 367 | Update user settings by your own settings manually. 368 | 369 | ```js 370 | await library_name.user.update_settings() 371 | ``` 372 | 373 | | Param | Require | Type | Description | 374 | | --- | --- | --- | --- | 375 | | settings_object | `true` | `Object` | User Settings. | 376 | 377 | [Back to the Table of contents](#table-of-contents) 378 | 379 | 380 | - ## user.public_following_list() 381 | Get public user following list. 382 | 383 | ```js 384 | await client.user.public_following_list(); 385 | ``` 386 | | Param | Require | Type | Description | 387 | | --- | --- | --- | --- | 388 | | username | `true` | `string` | Target Character.AI username account. | 389 | | page_param | `false` | `number` | Page parameter. | 390 | 391 | [Back to the Table of contents](#table-of-contents) 392 | 393 | 394 | - ## user.public_followers_list() 395 | Get public user followers list. 396 | 397 | ```js 398 | await client.user.public_followers_list(); 399 | ``` 400 | | Param | Require | Type | Description | 401 | | --- | --- | --- | --- | 402 | | username | `true` | `string` | Target Character.AI username account. | 403 | | page_param | `false` | `number` | Page parameter. | 404 | 405 | [Back to the Table of contents](#table-of-contents) 406 | 407 | 408 | - ## user.following_check() 409 | Check are you following this user account or not. 410 | 411 | ```js 412 | await client.user.following_check("Username"); 413 | ``` 414 | | Param | Require | Type | Description | 415 | | --- | --- | --- | --- | 416 | | username | `true` | `string` | Target Character.AI username account. | 417 | 418 | [Back to the Table of contents](#table-of-contents) 419 | 420 | 421 | - ## user.following_list_name() 422 | Get account following name list. 423 | 424 | ```js 425 | await client.user.following_list_name(); 426 | ``` 427 | | Param | Require | Type | Description | 428 | | --- | --- | --- | --- | 429 | | none | `false` | `null` | - | 430 | 431 | [Back to the Table of contents](#table-of-contents) 432 | 433 | 434 | - ## user.followers_list_name() 435 | Get account followers name list. 436 | 437 | ```js 438 | await client.user.followers_list_name(); 439 | ``` 440 | | Param | Require | Type | Description | 441 | | --- | --- | --- | --- | 442 | | none | `false` | `null` | - | 443 | 444 | [Back to the Table of contents](#table-of-contents) 445 | 446 | 447 | - ## user.follow() 448 | Follow user account. 449 | 450 | ```js 451 | await client.user.follow(); 452 | ``` 453 | | Param | Require | Type | Description | 454 | | --- | --- | --- | --- | 455 | | username | `true` | `string` | Target Character.AI username account. | 456 | 457 | [Back to the Table of contents](#table-of-contents) 458 | 459 | - ## user.unfollow() 460 | Unfollow user account. 461 | 462 | ```js 463 | await client.user.unfollow(); 464 | ``` 465 | | Param | Require | Type | Description | 466 | | --- | --- | --- | --- | 467 | | username | `true` | `string` | Target Character.AI username account. | 468 | 469 | [Back to the Table of contents](#table-of-contents) 470 | 471 | - ## user.liked_character_list() 472 | Get a list of characters that the account likes. 473 | 474 | ```js 475 | await client.user.liked_character_list(); 476 | ``` 477 | | Param | Require | Type | Description | 478 | | --- | --- | --- | --- | 479 | | none | `false` | `null` | - | 480 | 481 | [Back to the Table of contents](#table-of-contents) 482 | 483 | 484 | - ## user.add_muted_words() 485 | Add muted words. 486 | 487 | Example 488 | - Array 489 | ```js 490 | await library_name.user.add_muted_words(["hello", "world"]) 491 | ``` 492 | - String 493 | ```js 494 | await library_name.user.add_muted_words("hello world") 495 | ``` 496 | 497 | | Param | Require | Type | Description | 498 | | --- | --- | --- | --- | 499 | | words | `true` | `string[] | string` | Words that you want to add to the muted words. | 500 | 501 | [Back to the Table of contents](#table-of-contents) 502 | 503 | 504 | - ## user.remove_muted_words() 505 | Remove muted words. 506 | 507 | Example 508 | - Array 509 | ```js 510 | await library_name.user.remove_muted_words(["hello", "world"]) 511 | ``` 512 | - String 513 | ```js 514 | await library_name.user.remove_muted_words("hello world") 515 | ``` 516 | 517 | | Param | Require | Type | Description | 518 | | --- | --- | --- | --- | 519 | | words | `true` | `string[] | string` | Words that you want to remove from the muted words. | 520 | 521 | [Back to the Table of contents](#table-of-contents) 522 | 523 | 524 | - ## user.clear_muted_words() 525 | Clear muted words. 526 | 527 | ```js 528 | await library_name.user.clear_muted_words() 529 | ``` 530 | 531 | | Param | Require | Type | Description | 532 | | --- | --- | --- | --- | 533 | | none | `false` | `null` | - | 534 | 535 | [Back to the Table of contents](#table-of-contents) 536 | 537 | 538 | # Image Function List 539 | - ## image.generate_avatar() 540 | Generate avatar image using prompt. 541 | 542 | ```js 543 | await client.image.generate_avatar(prompt_name); 544 | ``` 545 | | Param | Require | Type | Description | 546 | | --- | --- | --- | --- | 547 | | prompt_name | `true` | `string` | Prompt used for generating avatar image. | 548 | 549 | [Back to the Table of contents](#table-of-contents) 550 | 551 | - ## image.generate_image() 552 | Generate image using prompt. 553 | 554 | ```js 555 | await client.image.generate_image(prompt_name); 556 | ``` 557 | | Param | Require | Type | Description | 558 | | --- | --- | --- | --- | 559 | | prompt_name | `true` | `string` | Prompt used for generating AI image. | 560 | 561 | [Back to the Table of contents](#table-of-contents) 562 | 563 | # Search Function List 564 | > This class contains functions about the Search on Character.AI Server. 565 | 566 | - ## search.list_tags() 567 | Get list of tags. 568 | 569 | ```js 570 | await client.search.list_tags(); 571 | ``` 572 | | Param | Require | Type | Description | 573 | | --- | --- | --- | --- | 574 | | none | `false` | `null` | - | 575 | 576 | [Back to the Table of contents](#table-of-contents) 577 | 578 | 579 | - ## search.users() 580 | Search users by name. 581 | 582 | ```js 583 | await library_name.search.users("Name user", "popular"); // sorted by popular 584 | ``` 585 | | Param | Require | Type | Description | 586 | | --- | --- | --- | --- | 587 | | name | `true` | `string` | Name user to search | 588 | | sorted_by | `true` | `string` | Search sorted by? | 589 | 590 | [Back to the Table of contents](#table-of-contents) 591 | 592 | 593 | - ## search.scenes() 594 | Search scenes by query. 595 | 596 | ```js 597 | await library_name.search.scenes("Query"); 598 | ``` 599 | | Param | Require | Type | Description | 600 | | --- | --- | --- | --- | 601 | | query | `true` | `string` | Search scenes by Query | 602 | 603 | 604 | [Back to the Table of contents](#table-of-contents) 605 | 606 | 607 | - ## search.characters() 608 | Search for a character by name or query. 609 | 610 | ```js 611 | await library_name.search.characters("Character Name") 612 | ``` 613 | | Param | Require | Type | Description | 614 | | --- | --- | --- | --- | 615 | | name | `true` | `string` | Search queries to find characters. | 616 | | sorted_by | `true` | `string` | Search sorted by? | 617 | 618 | [Back to the Table of contents](#table-of-contents) 619 | 620 | 621 | - ## search.voices() 622 | Search for a voices by name. 623 | 624 | ```js 625 | await library_name.search.voices("Name voice") 626 | ``` 627 | | Param | Require | Type | Description | 628 | | --- | --- | --- | --- | 629 | | name | `true` | `string` | Search queries to find voices. | 630 | 631 | [Back to the Table of contents](#table-of-contents) 632 | 633 | 634 | - ## search.popular() 635 | Get popular search. 636 | 637 | ```js 638 | await library_name.search.popular() 639 | ``` 640 | | Param | Require | Type | Description | 641 | | --- | --- | --- | --- | 642 | | none | `false` | `null` | - | 643 | 644 | [Back to the Table of contents](#table-of-contents) 645 | 646 | 647 | - ## search.trending() 648 | Get trending search. 649 | 650 | ```js 651 | await library_name.search.trending() 652 | ``` 653 | | Param | Require | Type | Description | 654 | | --- | --- | --- | --- | 655 | | none | `false` | `null` | - | 656 | 657 | [Back to the Table of contents](#table-of-contents) 658 | 659 | 660 | - ## search.autocomplete() 661 | Get autocomplete search. 662 | 663 | ```js 664 | await library_name.search.autocomplete("Search") 665 | ``` 666 | | Param | Require | Type | Description | 667 | | --- | --- | --- | --- | 668 | | query | `true` | `string` | Get autocomplete search by Query | 669 | 670 | [Back to the Table of contents](#table-of-contents) 671 | 672 | 673 | - ## search.languages() 674 | Get languages list. 675 | 676 | ```js 677 | await library_name.search.languages("") 678 | ``` 679 | | Param | Require | Type | Description | 680 | | --- | --- | --- | --- | 681 | | none | `false` | `null` | - | 682 | 683 | [Back to the Table of contents](#table-of-contents) 684 | 685 | 686 | # Persona Function List 687 | > This class contains variables and methods about the Persona requirement. For example: Create/Edit/Delete Persona, Set persona, Get information about persona. 688 | 689 | 690 | - ## persona.create() 691 | Create your personality for your character. 692 | 693 | ```js 694 | await client.persona.create(name, description); 695 | ``` 696 | | Param | Require | Type | Description | 697 | | --- | --- | --- | --- | 698 | | name | `true` | `string` | Your persona name | 699 | | description | `true` | `string` | Description of your personality, this section is used to describe yourself so that your AI character knows who you are. | 700 | 701 | [Back to the Table of contents](#table-of-contents) 702 | 703 | - ## persona.set_default() 704 | Set your default personality specifically. 705 | 706 | ```js 707 | await client.persona.set_default(external_persona_id); 708 | ``` 709 | | Param | Require | Type | Description | 710 | | --- | --- | --- | --- | 711 | | external_persona_id | `true` | `string` | External personality id that you have. | 712 | 713 | [Back to the Table of contents](#table-of-contents) 714 | 715 | - ## persona.list() 716 | Get all your personality data. 717 | 718 | ```js 719 | await client.persona.list(); 720 | ``` 721 | | Param | Require | Type | Description | 722 | | --- | --- | --- | --- | 723 | | none | `false` | `null` | - | 724 | 725 | [Back to the Table of contents](#table-of-contents) 726 | 727 | 728 | - ## persona.info() 729 | Get your personality information. 730 | 731 | ```js 732 | await client.persona.info(external_persona_id); 733 | ``` 734 | | Param | Require | Type | Description | 735 | | --- | --- | --- | --- | 736 | | external_persona_id | `true` | `string` | External personality id that you have. | 737 | 738 | [Back to the Table of contents](#table-of-contents) 739 | 740 | 741 | - ## persona.update() 742 | Update your personality specifically. 743 | 744 | ```js 745 | await client.persona.update(external_persona_id, name, description); 746 | ``` 747 | | Param | Require | Type | Description | 748 | | --- | --- | --- | --- | 749 | | external_persona_id | `true` | `string` | External personality id that you have. | 750 | | name | `true` | `string` | Your new personality name. | 751 | | description | `true` | `string` | Your new personality detail. | 752 | 753 | [Back to the Table of contents](#table-of-contents) 754 | 755 | 756 | - ## persona.delete() 757 | Used for deleting your personality spesifically. 758 | 759 | ```js 760 | await client.persona.delete(external_persona_id); 761 | ``` 762 | | Param | Require | Type | Description | 763 | | --- | --- | --- | --- | 764 | | external_persona_id | `true` | `string` | External personality id that you have. | 765 | 766 | [Back to the Table of contents](#table-of-contents) 767 | 768 | - ## persona.set_character() 769 | Set a custom personality for your character specifically. 770 | 771 | ```js 772 | await client.persona.set_character(character_id, external_persona_id); 773 | ``` 774 | | Param | Require | Type | Description | 775 | | --- | --- | --- | --- | 776 | | character_id | `true` | `string` | A character id that you want to set a custom personality. | 777 | | external_persona_id | `true` | `string` | Your personality id that you use to let AI characters know who you are. | 778 | 779 | [Back to the Table of contents](#table-of-contents) 780 | 781 | # Explore Function List 782 | > This class contains functions about the Explore requirement. Example: Featured Character, For you Recommended Character, and etc about Explore. 783 | - ## explore.featured() 784 | Get the list of characters displayed by the character.ai server. 785 | 786 | ```js 787 | await client.explore.featured(); 788 | ``` 789 | | Param | Require | Type | Description | 790 | | --- | --- | --- | --- | 791 | | none | `false` | `null` | - | 792 | 793 | [Back to the Table of contents](#table-of-contents) 794 | 795 | - ## explore.for_you() 796 | Get a list of characters recommended by the character.ai server. 797 | 798 | ```js 799 | await client.explore.for_you(); 800 | ``` 801 | | Param | Require | Type | Description | 802 | | --- | --- | --- | --- | 803 | | none | `false` | `null` | - | 804 | 805 | [Back to the Table of contents](#table-of-contents) 806 | 807 | - ## explore.simillar_char() 808 | Get the list simillar character from ID character. 809 | 810 | ```js 811 | await client.explore.simillar_char(char_id); 812 | ``` 813 | 814 | | Param | Require | Type | Description | 815 | | --- | --- | --- | --- | 816 | | char_id | `true` | `string` | Character ID. | 817 | 818 | [Back to the Table of contents](#table-of-contents) 819 | 820 | - ## explore.character_categories() 821 | Get the list of characters from the character category exploration. 822 | 823 | ```js 824 | await client.explore.character_categories(); 825 | ``` 826 | | Param | Require | Type | Description | 827 | | --- | --- | --- | --- | 828 | | none | `false` | `null` | - | 829 | 830 | [Back to the Table of contents](#table-of-contents) 831 | - ## explore.featured_voices() 832 | Get a list of featured voices. 833 | 834 | ```js 835 | await client.explore.featured_voices(); 836 | ``` 837 | 838 | | Param | Require | Type | Description | 839 | | --- | --- | --- | --- | 840 | | none | `false` | `null` | - | 841 | 842 | [Back to the Table of contents](#table-of-contents) 843 | 844 | # Character Function List 845 | > This class contains functions about the Character requirement (Single Character, not Group Chat). Example: Sending message to Character, votes character, and etc about Character. 846 | 847 | - ## character.votes() 848 | Get character vote information. 849 | 850 | ```js 851 | await client.character.votes(character_id); 852 | ``` 853 | | Param | Require | Type | Description | 854 | | --- | --- | --- | --- | 855 | | character_id | `true` | `string` | The character id you are aiming for. | 856 | 857 | [Back to the Table of contents](#table-of-contents) 858 | 859 | 860 | - ## character.votes_array() 861 | Get character vote information in array. 862 | 863 | ```js 864 | await client.character.votes_array(character_id); 865 | ``` 866 | | Param | Require | Type | Description | 867 | | --- | --- | --- | --- | 868 | | character_id | `true` | `string` | The character id you are aiming for. | 869 | 870 | [Back to the Table of contents](#table-of-contents) 871 | 872 | 873 | - ## character.vote() 874 | Used for vote the character. 875 | 876 | ```js 877 | await client.character.vote(character_id, vote); 878 | ``` 879 | | Param | Require | Type | Description | 880 | | --- | --- | --- | --- | 881 | | character_id | `true` | `string` | The character id you are aiming for. | 882 | | vote | `true` | `boolean` | Character vote options, `true = like`, `false = dislike`, and `null = cancel` | 883 | 884 | [Back to the Table of contents](#table-of-contents) 885 | 886 | 887 | - ## character.info() 888 | Get detailed information about characters. 889 | 890 | ```js 891 | await client.character.info(character_id); 892 | ``` 893 | | Param | Require | Type | Description | 894 | | --- | --- | --- | --- | 895 | | character_id | `true` | `string` | Your character id. | 896 | 897 | [Back to the Table of contents](#table-of-contents) 898 | 899 | 900 | - ## character.recent_list() 901 | Get a list of recent chat activity 902 | 903 | ```js 904 | await client.character.recent_list(); 905 | ``` 906 | | Param | Require | Type | Description | 907 | | --- | --- | --- | --- | 908 | | none | `false` | `null` | - | 909 | 910 | [Back to the Table of contents](#table-of-contents) 911 | 912 | 913 | - ## character.connect() 914 | Connect client to character chat 915 | 916 | ```js 917 | await client.character.connect(character_id); 918 | ``` 919 | | Param | Require | Type | Description | 920 | | --- | --- | --- | --- | 921 | | character_id | `true` | `string` | Your character id. | 922 | 923 | [Back to the Table of contents](#table-of-contents) 924 | 925 | 926 | - ## character.disconnect() 927 | Disconnecting client from character chat 928 | 929 | ```js 930 | await client.character.disconnect(); 931 | ``` 932 | | Param | Require | Type | Description | 933 | | --- | --- | --- | --- | 934 | | none | `false` | `null` | - | 935 | 936 | [Back to the Table of contents](#table-of-contents) 937 | 938 | 939 | - ## character.send_message() 940 | Send message to character. 941 | 942 | - Example (Default and if you're using `character.connect()` to connect to the Single Character.) 943 | - Without manual turn 944 | ```js 945 | await library_name.character.send_message("Your Message", false, "URL Link (you can empty it if you don't want to send it)") 946 | ``` 947 | - With manual turn 948 | ```js 949 | await library_name.character.send_message("Your Message", true, "URL Link (you can empty it if you don't want to send it)") 950 | ``` 951 | 952 | - Example (Manual input Character ID and Chat ID) 953 | - Wtihout manual turn 954 | ```js 955 | await library_name.character.send_message("Your Message", false, "URL Link (you can empty it if you don't want to send it)", { 956 | char_id: "Input your Character ID here.", 957 | chat_id: "Input your Chat ID here." 958 | }) 959 | ``` 960 | - With manual turn 961 | ```js 962 | await library_name.character.send_message("Your Message", true, "URL Link (you can empty it if you don't want to send it)", { 963 | char_id: "Input your Character ID here.", 964 | chat_id: "Input your Chat ID here." 965 | }) 966 | ``` 967 | | Param | Require | Type | Description | 968 | | --- | --- | --- | --- | 969 | | message | `true` | `string` | Message content. | 970 | | manual_turn | `false` | `boolean` | If the value of `manual_turn` is set to `true` then the message that the client receives must be generated with `character.generate_turn()` so that the message is obtained by the client. | 971 | | image_url | `false` | `string` | The image content that the character will see, must be a url and not a file type or a file with a type other than image. | 972 | | manual_opt | `false` | `{chat_id: string, char_id: string, timeout_ms: number}` | Manual options. (Must fill if you're not already connected into the Single Character. applies only `char_id` and `chat_id` only.) 973 | 974 | [Back to the Table of contents](#table-of-contents) 975 | 976 | - ## character.generate_turn() 977 | Generating message response from character. 978 | 979 | ```js 980 | await client.character.generate_turn(); 981 | ``` 982 | | Param | Require | Type | Description | 983 | | --- | --- | --- | --- | 984 | | manual_opt | `false` | `{chat_id: string, char_id: string, timeout_ms: number}` | Manual options. (Must fill if you're not already connected into the Single Character. applies only `char_id` and `chat_id` only.) 985 | 986 | [Back to the Table of contents](#table-of-contents) 987 | 988 | - ## character.generate_turn_candidate() 989 | Regenerate character message. 990 | 991 | ```js 992 | await client.character.generate_turn_candidate(turn_id); 993 | ``` 994 | | Param | Require | Type | Description | 995 | | --- | --- | --- | --- | 996 | | turn_id | `true` | `string` | `turn_id` or `message_id` from the character. | 997 | | manual_opt | `false` | `{chat_id: string, char_id: string, timeout_ms: number}` | Manual options. (Must fill if you're not already connected into the Single Character. applies only `char_id` and `chat_id` only.) 998 | 999 | [Back to the Table of contents](#table-of-contents) 1000 | 1001 | - ## character.create_new_conversation() 1002 | it will create a new conversation and your current conversation will save on the history. 1003 | 1004 | - With greeting 1005 | ```js 1006 | await client.character.create_new_conversation(); 1007 | ``` 1008 | - Without greeting 1009 | ```js 1010 | await client.character.create_new_conversation(false); 1011 | ``` 1012 | 1013 | | Param | Require | Type | Description | 1014 | | --- | --- | --- | --- | 1015 | | with_greeting | `false` | `boolean` | The character will send you a greeting when you create a new conversation. (Default = true) | 1016 | | manual_opt | `false` | `{char_id: string}` | Manual Option. (Must fill if you're not already connected into the Single Character.) 1017 | 1018 | [Back to the Table of contents](#table-of-contents) 1019 | 1020 | - ## character.delete_message() 1021 | Delete character message. 1022 | 1023 | ```js 1024 | await client.character.delete_message(turn_id); 1025 | ``` 1026 | | Param | Require | Type | Description | 1027 | | --- | --- | --- | --- | 1028 | | turn_id | `true` | `string` | `turn_id` or `message_id` from the character. | 1029 | | manual_opt | `false` | `{char_id: string, chat_id: string}` | Manual Options (Must fill if you're not already connected into the Single Character.) 1030 | 1031 | [Back to the Table of contents](#table-of-contents) 1032 | 1033 | 1034 | - ## character.edit_message() 1035 | Edit the character message. 1036 | 1037 | ```js 1038 | await client.character.edit_message(candidate_id, turn_id, new_message); 1039 | ``` 1040 | | Param | Require | Type | Description | 1041 | | --- | --- | --- | --- | 1042 | | candidate_id | `true` | `string` | 1043 | | turn_id | `true` | `string` | `turn_id` or `message_id` from the character. | 1044 | | new_message | `true` | `string` | New character message | 1045 | | manual_opt | `false` | `{char_id: string, chat_id: string}` | Manual Options (Must fill if you're not already connected into the Single Character.) 1046 | 1047 | [Back to the Table of contents](#table-of-contents) 1048 | 1049 | - ## character.replay_tts() 1050 | Generate text messages from character to voice audio. 1051 | 1052 | - if you have Voice ID 1053 | ```js 1054 | await client.character.replay_tts("Turn ID", "Candidate ID", "fill the Voice Character ID here") 1055 | ``` 1056 | - if you don't have Voice ID and want to use Voice Query instead 1057 | ```js 1058 | await client.character.replay_tts("Turn ID", "Candidate ID", "Sonic the Hedgehog", true) 1059 | ``` 1060 | 1061 | | Param | Require | Type | Description | 1062 | | --- | --- | --- | --- | 1063 | | turn_id | `true` | `string` | `turn_id` from the character. | 1064 | | candidate_id | `true` | `string` | `candidate_id` from the character. | 1065 | | voice_id_or_query | `true` | `string` | Input Voice character ID or you can use Voice Query. | 1066 | | using_query | `false` | `boolean` | Using Query (if You're using Voice Query, then set this parameter to `true`.) | 1067 | | manual_opt | `false` | `{chat_id: string}` | Manual Options (Must fill if you're not already connected into the Single Character.) 1068 | 1069 | [Back to the Table of contents](#table-of-contents) 1070 | 1071 | - ## character.current_voice() 1072 | Get character current voice info. 1073 | 1074 | - Auto (you must already connected with character) 1075 | ```js 1076 | await client.character.current_voice() 1077 | ``` 1078 | - Manual 1079 | ```js 1080 | await client.character.current_voice("Character ID") 1081 | ``` 1082 | | Param | Require | Type | Description | 1083 | | --- | --- | --- | --- | 1084 | | character_id | `false` | `string` | Target of Character ID. (Must fill if you're not already connected into the Single Character.) | 1085 | 1086 | [Back to the Table of contents](#table-of-contents) 1087 | 1088 | 1089 | - ## character.get_category() 1090 | Get category used of the character. 1091 | 1092 | ```js 1093 | await client.character.get_category() 1094 | ``` 1095 | | Param | Require | Type | Description | 1096 | | --- | --- | --- | --- | 1097 | | character_id | `true` | `string` | Target of Character ID. | 1098 | 1099 | [Back to the Table of contents](#table-of-contents) 1100 | 1101 | 1102 | - ## character.about() 1103 | Get detailed information of the character about. 1104 | > REMEMBER: Specific Character only. if the character have an "about" feature, then you can use this function. 1105 | > Otherwise, it return noindex: true, or it means it empty. 1106 | 1107 | ```js 1108 | await client.character.about() 1109 | ``` 1110 | | Param | Require | Type | Description | 1111 | | --- | --- | --- | --- | 1112 | | short_hash | `true` | `string` | Target of Character short hash. | 1113 | 1114 | [Back to the Table of contents](#table-of-contents) 1115 | 1116 | 1117 | - ## character.info_detailed() 1118 | Get detailed of the character. but, it will give you a FULL detailed of the Character, including character definition. 1119 | > REMEMBER: If the character defined turned to public, then you can use this function. 1120 | > Otherwise, it return an empty character data and the status says "do not have permission to view this Character". 1121 | 1122 | ```js 1123 | await client.character.info_detailed() 1124 | ``` 1125 | | Param | Require | Type | Description | 1126 | | --- | --- | --- | --- | 1127 | | external_id | `true` | `string` | Target of Character ID. | 1128 | 1129 | [Back to the Table of contents](#table-of-contents) 1130 | 1131 | 1132 | # Group Chat Function List 1133 | - ## group_chat.list() 1134 | Get all list available group chat in account. 1135 | 1136 | ```js 1137 | await client.group_chat.list(); 1138 | ``` 1139 | | Param | Require | Type | Description | 1140 | | --- | --- | --- | --- | 1141 | | none | `false` | `null` | - | 1142 | 1143 | [Back to the Table of contents](#table-of-contents) 1144 | 1145 | 1146 | - ## group_chat.connect() 1147 | Connecting to group chat by the `room_id`, btw you can't connect the group chat before you create it. 1148 | 1149 | ```js 1150 | await client.group_chat.connect(room_id); 1151 | ``` 1152 | | Param | Require | Type | Description | 1153 | | --- | --- | --- | --- | 1154 | | room_id | `true` | `string` | Your group chat id. | 1155 | 1156 | [Back to the Table of contents](#table-of-contents) 1157 | 1158 | 1159 | - ## group_chat.disconnect() 1160 | Disconnecting from group chat by the `room_id`. 1161 | 1162 | ```js 1163 | await client.group_chat.disconnect(room_id); 1164 | ``` 1165 | | Param | Require | Type | Description | 1166 | | --- | --- | --- | --- | 1167 | | room_id | `true` | `string` | Your group chat id. | 1168 | 1169 | [Back to the Table of contents](#table-of-contents) 1170 | 1171 | 1172 | - ## group_chat.create() 1173 | Create a custom room chat. 1174 | 1175 | ```js 1176 | await client.group_chat.create(title_room, character_id); 1177 | ``` 1178 | | Param | Require | Type | Description | 1179 | | --- | --- | --- | --- | 1180 | | title_room | `true` | `string` | Your custom title room name. | 1181 | | character_id | `true` | `string` | Your character id will be added to the group chat. | 1182 | 1183 | [Back to the Table of contents](#table-of-contents) 1184 | 1185 | 1186 | - ## group_chat.delete() 1187 | Delete group chat. 1188 | 1189 | ```js 1190 | await client.group_chat.delete(room_id); 1191 | ``` 1192 | | Param | Require | Type | Description | 1193 | | --- | --- | --- | --- | 1194 | | room_id | `true` | `string` | Your group chat id. | 1195 | 1196 | [Back to the Table of contents](#table-of-contents) 1197 | 1198 | 1199 | - ## group_chat.rename() 1200 | Rename group chat. 1201 | 1202 | ```js 1203 | await client.group_chat.rename(new_name, room_id); 1204 | ``` 1205 | | Param | Require | Type | Description | 1206 | | --- | --- | --- | --- | 1207 | | new_name | `true` | `string` | New name for your group chat. | 1208 | | room_id | `true` | `string` | Your group chat id. | 1209 | 1210 | [Back to the Table of contents](#table-of-contents) 1211 | 1212 | - ## group_chat.join_group_invite() 1213 | Joining group chat using invite code. 1214 | 1215 | ```js 1216 | await client.group_chat.join_group_invite(invite_code); 1217 | ``` 1218 | | Param | Require | Type | Description | 1219 | | --- | --- | --- | --- | 1220 | | invite_code | `true` | `string` | The group chat miinvite code. | 1221 | 1222 | [Back to the Table of contents](#table-of-contents) 1223 | 1224 | - ## group_chat.char_add() 1225 | Add a character with `character_id` to the group chat. 1226 | 1227 | ```js 1228 | await client.group_chat.char_add(character_id); 1229 | ``` 1230 | | Param | Require | Type | Description | 1231 | | --- | --- | --- | --- | 1232 | | character_id | `true` | `string` | Character id to be added to the group chat. | 1233 | 1234 | [Back to the Table of contents](#table-of-contents) 1235 | 1236 | - ## group_chat.char_remove() 1237 | Remove a character with `character_id` from the group chat. 1238 | 1239 | ```js 1240 | await client.group_chat.char_remove(character_id); 1241 | ``` 1242 | | Param | Require | Type | Description | 1243 | | --- | --- | --- | --- | 1244 | | character_id | `true` | `string` | Character id to be removed from the group chat. | 1245 | 1246 | [Back to the Table of contents](#table-of-contents) 1247 | 1248 | - ## group_chat.send_message() 1249 | Send message to character in group chat. 1250 | 1251 | ```js 1252 | await client.group_chat.send_message(message, image_url); 1253 | ``` 1254 | | Param | Require | Type | Description | 1255 | | --- | --- | --- | --- | 1256 | | message | `true` | `string` | Message content. | 1257 | | image_url | `false` | `string` | The image content that the character will see, must be a url and not a file type or a file with a type other than image. | 1258 | 1259 | [Back to the Table of contents](#table-of-contents) 1260 | 1261 | - ## group_chat.generate_turn() 1262 | Generating message response character from group chat. 1263 | 1264 | ```js 1265 | await client.group_chat.generate_turn(); 1266 | ``` 1267 | | Param | Require | Type | Description | 1268 | | --- | --- | --- | --- | 1269 | | none | `false` | `null` | - | 1270 | 1271 | [Back to the Table of contents](#table-of-contents) 1272 | 1273 | - ## group_chat.generate_turn_candidate() 1274 | Regenerate character message. 1275 | 1276 | ```js 1277 | await client.group_chat.generate_turn_candidate(turn_id); 1278 | ``` 1279 | | Param | Require | Type | Description | 1280 | | --- | --- | --- | --- | 1281 | | turn_id | `true` | `string` | `turn_id` or `message_id` from the character. | 1282 | 1283 | [Back to the Table of contents](#table-of-contents) 1284 | 1285 | - ## group_chat.reset_conversation() 1286 | Reset conversation in group chat. 1287 | 1288 | ```js 1289 | await client.group_chat.reset_conversation(); 1290 | ``` 1291 | | Param | Require | Type | Description | 1292 | | --- | --- | --- | --- | 1293 | | none | `false` | `null` | - | 1294 | 1295 | [Back to the Table of contents](#table-of-contents) 1296 | 1297 | - ## group_chat.delete_message() 1298 | Delete character message. 1299 | 1300 | ```js 1301 | await client.group_chat.delete_message(turn_id); 1302 | ``` 1303 | | Param | Require | Type | Description | 1304 | | --- | --- | --- | --- | 1305 | | turn_id | `true` | `string` | `turn_id` or `message_id` from the character. | 1306 | 1307 | [Back to the Table of contents](#table-of-contents) 1308 | 1309 | - ## group_chat.edit_message() 1310 | Edit character message in group chat. 1311 | 1312 | ```js 1313 | await client.group_chat.edit_message(candidate_id, turn_id, new_message); 1314 | ``` 1315 | | Param | Require | Type | Description | 1316 | | --- | --- | --- | --- | 1317 | | candidate_id | `true` | `string` | 1318 | | turn_id | `true` | `string` | `turn_id` or `message_id` from the character. | 1319 | | new_message | `true` | `string` | New character message | 1320 | 1321 | [Back to the Table of contents](#table-of-contents) 1322 | 1323 | - ## group_chat.select_turn() 1324 | Select the turn of character chat by yourself. 1325 | 1326 | ```js 1327 | await client.group_chat.select_turn(turn_id); 1328 | ``` 1329 | | Param | Require | Type | Description | 1330 | | --- | --- | --- | --- | 1331 | | turn_id | `true` | `string` | `turn_id` or `message_id` from the character. | 1332 | 1333 | [Back to the Table of contents](#table-of-contents) 1334 | 1335 | # Chat Function List 1336 | - ## chat.history_chat_turns() 1337 | Get a history chat from group or single chat. 1338 | 1339 | ```js 1340 | await client.chat.history_chat_turns(chat_id); 1341 | ``` 1342 | | Param | Require | Type | Description | 1343 | | --- | --- | --- | --- | 1344 | | chat_id | `true` | `string` | Group chat or single chat ID. | 1345 | 1346 | [Back to the Table of contents](#table-of-contents) 1347 | 1348 | - ## chat.conversation_info() 1349 | Get converastion information. 1350 | 1351 | ```js 1352 | await client.chat.conversation_info(chat_id); 1353 | ``` 1354 | 1355 | | Param | Require | Type | Description | 1356 | | --- | --- | --- | --- | 1357 | | chat_id | `true` | `string` | Group chat ID or single chat ID. | 1358 | 1359 | [Back to the Table of contents](#table-of-contents) 1360 | 1361 | - ## chat.history_conversation_list() 1362 | Get list of your history conversation from character. This function is for Single character only. 1363 | 1364 | - Auto (Already connected to the Single character chat) 1365 | ```js 1366 | await client.chat.history_conversation_list() 1367 | ``` 1368 | - Manual 1369 | ```js 1370 | await client.chat.history_conversation_list("Character ID") 1371 | ``` 1372 | 1373 | | Param | Require | Type | Description | 1374 | | --- | --- | --- | --- | 1375 | | character_id | `false` | `string` | Target of Character ID. | 1376 | 1377 | [Back to the Table of contents](#table-of-contents) 1378 | 1379 | - ## chat.set_conversation_chat() 1380 | Set conversation chat, and bring the history chat into current chat. This function is for Single character only. 1381 | 1382 | ```js 1383 | await client.chat.set_conversation_chat(chat_id) 1384 | ``` 1385 | 1386 | | Param | Require | Type | Description | 1387 | | --- | --- | --- | --- | 1388 | | chat_id | `true` | `string` | single chat ID. | 1389 | 1390 | [Back to the Table of contents](#table-of-contents) 1391 | 1392 | - ## chat.pin_message() 1393 | Pin message. This function is for Single character only. 1394 | 1395 | - Auto (if your're already connected to the single character) 1396 | ```js 1397 | await client.chat.pin_message("Turn ID") 1398 | ``` 1399 | - Manual 1400 | ```js 1401 | await client.chat.pin_message("Turn ID", true, "Chat ID") 1402 | ``` 1403 | 1404 | | Param | Require | Type | Description | 1405 | | --- | --- | --- | --- | 1406 | | turn_id | `true` | `string` | Turn ID Message. | 1407 | | pinned | `false` | `boolean` | Set the message pinned or not. (set `true` if you want to pin the message, set `false` if you want to unpin the message.) | 1408 | | chat_id | `false` | `string` | Chat ID Message. (Set the Chat ID if you not connected to the Single character.) | 1409 | 1410 | [Back to the Table of contents](#table-of-contents) 1411 | 1412 | - ## chat.list_pinned_message() 1413 | Get list pinned message from chat. This function works only for single character chat. 1414 | 1415 | ```js 1416 | await client.chat.list_pinned_message("Chat ID") 1417 | ``` 1418 | 1419 | | Param | Require | Type | Description | 1420 | | --- | --- | --- | --- | 1421 | | chat_id | `true` | `string` | Chat ID Message. | 1422 | 1423 | [Back to the Table of contents](#table-of-contents) 1424 | 1425 | - ## chat.archive_conversation() 1426 | Archive your conversation. This function works only for single character chat. 1427 | 1428 | - If you want archive the conversation 1429 | ```js 1430 | await client.chat.archive_conversation("Chat ID", true) 1431 | ``` 1432 | - If you want unarchive the conversation 1433 | ```js 1434 | await client.chat.archive_conversation("Chat ID", false) 1435 | ``` 1436 | 1437 | | Param | Require | Type | Description | 1438 | | --- | --- | --- | --- | 1439 | | chat_id | `true` | `string` | Chat ID message that you want to archive. | 1440 | | set_archive | `false` | `boolean` | Set Archive (to archive the Conversation, you can set it to `true`. If you want to unarchive the Converastion, you can set it to `false`.) | 1441 | 1442 | [Back to the Table of contents](#table-of-contents) 1443 | 1444 | - ## chat.duplicate_conversation() 1445 | Duplicate your conversation. This function works only for single character chat. 1446 | 1447 | ```js 1448 | await client.chat.duplicate_conversation("Chat ID", "Turn ID") 1449 | ``` 1450 | 1451 | | Param | Require | Type | Description | 1452 | | --- | --- | --- | --- | 1453 | | chat_id | `true` | `string` | Chat ID message that you want to duplicate. | 1454 | | turn_id | `true` | `string` | Turn ID message that you want to duplicate. | 1455 | 1456 | [Back to the Table of contents](#table-of-contents) 1457 | 1458 | - ## chat.rename_conversation() 1459 | Rename your conversation title. This function works only for single character chat. 1460 | 1461 | ```js 1462 | await client.chat.rename_conversation("Chat ID", "Custom Name") 1463 | ``` 1464 | 1465 | | Param | Require | Type | Description | 1466 | | --- | --- | --- | --- | 1467 | | chat_id | `true` | `string` | Chat ID message that you want to rename. | 1468 | | name | `true` | `string` | Name that you want to rename. | 1469 | 1470 | [Back to the Table of contents](#table-of-contents) 1471 | 1472 | 1473 | - ## chat.conversation_facts() 1474 | i dont know what is this. but maybe this is for getting the facts of your conversation, i guess...?
1475 | if you know this thing, please lemme know or you can do pull request if you want to. 1476 | 1477 | ```js 1478 | await client.chat.conversation_facts("Chat ID") 1479 | ``` 1480 | 1481 | | Param | Require | Type | Description | 1482 | | --- | --- | --- | --- | 1483 | | chat_id | `true` | `string` | Chat ID message that you want to get a conversation facts. | 1484 | 1485 | [Back to the Table of contents](#table-of-contents) 1486 | 1487 | # Voice Function List 1488 | - ## voice.user_created_list() 1489 | Get list of user created voice information. 1490 | 1491 | - Get your own created voice list 1492 | ```js 1493 | await client.voice.user_list() 1494 | ``` 1495 | - Get user created voice list 1496 | ```js 1497 | await client.voice.user_list("username") 1498 | ``` 1499 | 1500 | | Param | Require | Type | Description | 1501 | | --- | --- | --- | --- | 1502 | | username | `false` | `string` | A username that wants you to check the created voice list. | 1503 | 1504 | [Back to the Table of contents](#table-of-contents) 1505 | 1506 | - ## voice.info() 1507 | Get a voice information. 1508 | 1509 | ```js 1510 | await client.voice.info("Voice ID") 1511 | ``` 1512 | 1513 | | Param | Require | Type | Description | 1514 | | --- | --- | --- | --- | 1515 | | voice_id | `true` | `string` | A Voice ID that wants you to check the voice information. | 1516 | 1517 | [Back to the Table of contents](#table-of-contents) 1518 | 1519 | - ## voice.connect() 1520 | WARNING: This feature only supports Single character chat, not Group chat. 1521 | 1522 | Connect to voice character chat, and this function works only for single character chat. 1523 | 1524 | - Using Query 1525 | ```js 1526 | await client.voice.connect("Query", true) 1527 | ``` 1528 | - Using Voice ID 1529 | ```js 1530 | await client.voice.connec("Voice ID") 1531 | ``` 1532 | 1533 | Example to use 1534 | - Without microphone 1535 | ```js 1536 | const Speaker = require("speaker"); // import Speaker from "speaker" 1537 | const speaker = new Speaker({ 1538 | channels: 1, // 1 channel 1539 | bitDepth: 16, // 16-bit samples 1540 | sampleRate: 48000 // 48,000 Hz sample rate 1541 | }); 1542 | 1543 | await client.character.connect("Character ID"); 1544 | let test = await client.voice.connect("Sonic The Hedgehog", true); 1545 | 1546 | console.log("Character voice ready!"); 1547 | 1548 | test.on("frameReceived", ev => { 1549 | speaker.write(Buffer.from(ev.value.data.buffer)); // PCM buffer write into speaker and you'll hear the sound. 1550 | }); 1551 | 1552 | await client.character.generate_turn(); // Test is voice character is working or not. 1553 | ``` 1554 | 1555 | - With microphone (Voice call) 1556 | ```js 1557 | const Speaker = require("speaker"); // import Speaker from "speaker" 1558 | const { spawn } = require('child_process'); // import { spawn } from "child_process". 1559 | //for microphone, I'll using sox. so Ineed child_process 1560 | 1561 | const speaker = new Speaker({ 1562 | channels: 1, // 1 channel 1563 | bitDepth: 16, // 16-bit samples 1564 | sampleRate: 48000 // 48,000 Hz sample rate 1565 | }); 1566 | 1567 | const recordMic = spawn('sox', [ 1568 | '-q', 1569 | '-t', 'waveaudio', '-d', // Input windows audio (add '-d' if you want set default) 1570 | '-r', '48000', // Sample rate: 48 kHz 1571 | '-e', 'signed-integer', // Encoding: signed PCM 1572 | '-b', '16', // Bit depth: 16-bit 1573 | '-c', '1', // Channel: 1 (mono) 1574 | '-t', 'raw', // Output format: raw PCM 1575 | '-' // stdout 1576 | ]); 1577 | 1578 | let test = await client.voice.connect("Sonic The Hedgehog", true, true); 1579 | 1580 | console.log("Voice call ready!"); 1581 | 1582 | test.on("frameReceived", ev => { 1583 | speaker.write(Buffer.from(ev.value.data.buffer)); // PCM buffer write into speaker and you'll hear the sound. 1584 | }); 1585 | 1586 | recordMic.stdout.on("data", data => { 1587 | if (test.is_speech(data)) test.input_write(data); // Mic PCM Buffer output send it to Livekit server. 1588 | }); 1589 | ``` 1590 | | Param | Require | Type | Description | 1591 | | --- | --- | --- | --- | 1592 | | voice_query_or_id | `true` | `string` | Target Voice query or Voice ID. | 1593 | | using_voice_query | `false` | `boolean` | Using Voice Query (set it to true if `voice_query_or_id` using Voice Query) | 1594 | | using_mic | `false` | `boolean` | Using Microphone (You can talk to the Character using Microphone. Livekit needed.) | 1595 | | mic_opt | `false` | `{sample_rate: number, channel: number}` | Mic options. Default = `{sample_rate: 48000, channel: 1}` | 1596 | | manual_opt | `false` | `{char_id: string, chat_id: string}` | Manual Options. (Must fill if you're not connected to the Single Character.) | 1597 | 1598 | [Back to the Table of contents](#table-of-contents) 1599 | 1600 | 1601 | # Livekit Function List 1602 | - ## voice.connect().is_character_speaking 1603 | Check is Character is speaking or not. 1604 | 1605 | ```js 1606 | const voice = await client.voice.connect(); 1607 | console.log(voice.is_character_speaking) 1608 | ``` 1609 | 1610 | | Param | Require | Type | Description | 1611 | | --- | --- | --- | --- | 1612 | | none | `false` | `null` | - | 1613 | [Back to the Table of contents](#table-of-contents) 1614 | 1615 | - ## voice.connect().on event 1616 | Get Character.AI Voices (Livekit) data events. 1617 | 1618 | - `dataReceived`: Receive Character.AI Livekit data events. 1619 | ```js 1620 | const voice = await client.voice.connect(); 1621 | voice.on("dataReceived", data => { 1622 | console.log(data) 1623 | }) 1624 | ``` 1625 | - `frameReceived`: Receive audio stream from Livekit Server. 1626 | ```js 1627 | const voice = await client.voice.connect(); 1628 | voice.on("frameReceived", data => { 1629 | console.log(data) 1630 | }) 1631 | ``` 1632 | - `disconnected`: Notify when the Voice is disconnect. 1633 | ```js 1634 | const voice = await client.voice.connect(); 1635 | voice.on("disconnected", () => { 1636 | console.log("Voice disconnected!") 1637 | }) 1638 | ``` 1639 | [Back to the Table of contents](#table-of-contents) 1640 | 1641 | - ## voice.connect().input_write 1642 | Send audio PCM raw data to the Livekit Server. 1643 | 1644 | ```js 1645 | const voice = await client.voice.connect(); 1646 | voice.input_write(); 1647 | ``` 1648 | 1649 | | Param | Require | Type | Description | 1650 | | --- | --- | --- | --- | 1651 | | pcm_data | `true` | `Buffer` | PCM Buffer Data. | 1652 | 1653 | [Back to the Table of contents](#table-of-contents) 1654 | 1655 | - ## voice.connect().is_speech 1656 | this function checking is the PCM buffer frame is silence or not. 1657 | if the PCM Buffer is silence, it will return false. if not, it will return true 1658 | 1659 | Threshold default: 1000 1660 | 1661 | Credit: https://github.com/ashishbajaj99/mic/blob/master/lib/silenceTransform.js 1662 | 1663 | ```js 1664 | const voice = await client.voice.connect(); 1665 | voice.is_speech(); 1666 | ``` 1667 | 1668 | | Param | Require | Type | Description | 1669 | | --- | --- | --- | --- | 1670 | | chunk | `true` | `Buffer` | PCM Buffer Data. | 1671 | | Threshold | `false` | `number` | Threshold. (Default = 1000) | 1672 | 1673 | [Back to the Table of contents](#table-of-contents) 1674 | 1675 | - ## voice.connect().interrupt_call 1676 | Interrupt while character talking. 1677 | 1678 | ```js 1679 | const voice = await client.voice.connect(); 1680 | await voice.interrupt_call(); 1681 | ``` 1682 | 1683 | | Param | Require | Type | Description | 1684 | | --- | --- | --- | --- | 1685 | | none | `false` | `null` | - | 1686 | 1687 | [Back to the Table of contents](#table-of-contents) 1688 | 1689 | - ## voice.connect().disconnect 1690 | Disconnect from voice character. 1691 | 1692 | ```js 1693 | const voice = await client.voice.connect(); 1694 | await voice.disconnect(); 1695 | ``` 1696 | 1697 | | Param | Require | Type | Description | 1698 | | --- | --- | --- | --- | 1699 | | none | `false` | `null` | - | 1700 | 1701 | [Back to the Table of contents](#table-of-contents) 1702 | 1703 | # Notification Function List 1704 | - ## notification.history() 1705 | Get all of the history notification. 1706 | 1707 | ```js 1708 | await library_name.notification.history() 1709 | ``` 1710 | 1711 | | Param | Require | Type | Description | 1712 | | --- | --- | --- | --- | 1713 | | none | `false` | `null` | - | 1714 | 1715 | [Back to the Table of contents](#table-of-contents) 1716 | 1717 | 1718 | - ## notification.history_v2() 1719 | Get all of the history notification (Version 2). 1720 | 1721 | ```js 1722 | await library_name.notification.history_v2() 1723 | ``` 1724 | 1725 | | Param | Require | Type | Description | 1726 | | --- | --- | --- | --- | 1727 | | none | `false` | `null` | - | 1728 | 1729 | [Back to the Table of contents](#table-of-contents) 1730 | 1731 | 1732 | # Issues 1733 | Feel free to open the issue, I hope this documentation can help you maximally and make it easier for you to use this package. 1734 | 1735 | > *Thanks to [ZTRdiamond](https://github.com/ZTRdiamond) for helping me making a documentation.* 1736 | --------------------------------------------------------------------------------