An unofficial API for character.ai for Python
Project description
💬 CharacterAI
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
ᅠ
💻 Installation
pip install characterai
If you don't have Playwright installed, it will install automatically. But installing Playwright via pip is not enough, you need to install browsers
python -m playwright install
Also, if you have Linux, you will need to install additional packages
python -m playwright install-deps
ᅠ
📚 Documentation
The library has documentation! It says everything about this library
ᅠ
🔑 Get Token
DO NOT SHARE IT The token is needed for authorization and operation of requests from your account
- Open DevTools in your browser
- Go to Storage -> Local Storage -> char_token
- Copy
value
ᅠ
📙 Example
from characterai import PyCAI
client = PyCAI('TOKEN')
client.start()
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
First, you should add headless=False
in client.start()
and describe what happens in the browser and take screenshot of the browser
Also, you should have a screenshot of your error and code
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file characterai-0.7.1.tar.gz
.
File metadata
- Download URL: characterai-0.7.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd9fe84423f0bbd3fad4e9dbe01b24a1cf2f12c52f618184e9750571ff6117ae |
|
MD5 | 012717c85f8f84b7b71623eabfebc4d1 |
|
BLAKE2b-256 | fb29b3c8b716fd5fa13eea3e9f7c95dddc5174b95849d9f86f8f394f31cc71bc |