Skip to main content

An unofficial API for character.ai for Python

Project description

💬 CharacterAI

Tag Downloads

An unofficial API for Character AI for Python using Playwright

Discord Server

If you have any questions/problems/suggestions or you just want to talk about AI and CharacterAI - welcome to my new Discord server

discord.gg/ZHJe3tXQkf

💻 Installation

pip install characterai

📚 Documentation

For a complete understanding of the library, there is documentation

🔑 Get Token

DO NOT SHARE IT The token is needed for authorization and operation of requests from your account

  1. Open DevTools in your browser
  2. Go to Storage -> Local Storage -> char_token
  3. Copy value

📙 Example

from characterai import PyCAI

client = PyCAI('TOKEN')

char = input('Enter CHAR: ')

chat = client.chat.get_chat(char)

participants = chat['participants']

if not participants[0]['is_human']:
    tgt = participants[0]['user']['username']
else:
    tgt = participants[1]['user']['username']

while True:
    message = input('You: ')

    data = client.chat.send_message(
        chat['external_id'], tgt, message
    )

    name = data['src_char']['participant']['name']
    text = data['replies'][0]['text']

    print(f"{name}: {text}")

⚠️ Issues

Describe how to cause an error, when the error is called, how often, whether it was before, etc. You can write about the error in Github Issues, and you can also write to Discord server

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

characterai-0.8.0.tar.gz (8.5 kB view details)

Uploaded Source

File details

Details for the file characterai-0.8.0.tar.gz.

File metadata

  • Download URL: characterai-0.8.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for characterai-0.8.0.tar.gz
Algorithm Hash digest
SHA256 7dca99365aa25b547ce23f2eaeec5352b1510cf44334abd6bb5ddaa07268d29a
MD5 9993e99eea5dd0f81323317019444592
BLAKE2b-256 8d3cdaf01659ba68f7089e5f3e48f34b85e4be7bf330889c3ed56523af2dd59f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page