Skip to content
This repository was archived by the owner on Nov 29, 2025. It is now read-only.

Latest commit

 

History

History
35 lines (26 loc) · 1.43 KB

File metadata and controls

35 lines (26 loc) · 1.43 KB

Character.AI

img.png

Unofficial Javascript/Typescript Wrapper for character.ai

AS OF 3/14/2023 This seems to only work for Bun

Initialize a Client and Login

import  Log_in,{Client}  from 'character.ai';

let client:Client = await Log_in("token") // returns the Client

the default of the second arg of innit is false, will start a new chat if it set to true, if there is no previous history between character and client it will create one

const character = await client.init("characterId",true) // returns a Character and sets client's current character to it 
const msg :Msg = await client.sendMsg("Hello!") // returns a Message Object
const History : Array<Msg> = client.history // returns an Array of Messages

to get user info

const user = client.me // returns a User Object

lookFor returns an Array of Characters that has the same name as the first arg the second argument sorts the array by the amount of interactions the characters has, the default is "score"

const characters : Array<char> = await client.lookFor("characterName","interactions") // returns an Array of Characters

This project was created using bun init in bun v0.5.7. Bun is a fast all-in-one JavaScript runtime.