An unofficial asynchronous api wrapper for Character AI
Project description
PyCharacterAI
An unofficial asynchronous api wrapper for Character AI. For Python.
This library is based on the Character AI Unofficial Node API, made by realcoloride.
If you have any questions or problems, please contact me on Discord (xtraf) or Telegram.
Installation
pip install PyCharacterAI
Getting started
First, import and create a new instance of the Client class
from PyCharacterAI import Client
client = Client()
This library allows you to log in in two ways.
- As a guest (Some api features are not available):
await client.authenticate_as_guest()
- Using a token.
token = 'TOKEN'
await client.authenticate_with_token(token)
Instructions for getting a token:
- Open the Character AI website in your browser
- Open the developer tools
F12and go to theApplicationtab.- Go to the
Storagesection and click onLocal Storage.- Look for the
@@auth0spajs@@::dyD3gE281MqgISG7FuIXYhL2WEknqZzv::https://auth0.character.ai/::openid profile email offline_accesskey.- Open the body and copy the access token.
вљ пёЏ Warning! Do not share this token with anyone!
Simple example
import asyncio
from PyCharacterAI import Client
token = "TOKEN"
async def main():
client = Client()
await client.authenticate_with_token(token)
username = (await client.fetch_user())['user']['user']['username']
print(f'Authenticated as {username}')
character_id = "iV5qb8ttzD7Ytl69U_-ONcW2tW_lrFrOVKExyKJHlJM" # Lily (by @landon)
chat = await client.create_or_continue_chat(character_id)
while True:
message = input(f'{username}: ') # In: Hi!
answer = await chat.send_message(message)
print(f"Character: {answer.text}") # Out: hello there! what kind of question you gonna ask me ? i'm here to assist you :)
asyncio.run(main())
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file PyCharacterAI-1.0.0.tar.gz.
File metadata
- Download URL: PyCharacterAI-1.0.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a413b86c4c230d2dedcfe3943a59b457ae9bee414fb570cde8b11eab2701d6f6
|
|
| MD5 |
4c829180b56bcaf40967a4dc4aba9448
|
|
| BLAKE2b-256 |
a0e821729a5b91db6c507f18b40bbd7967d4bb7fa6a4c3b3d31fd76f1cdf6f42
|
File details
Details for the file PyCharacterAI-1.0.0-py3-none-any.whl.
File metadata
- Download URL: PyCharacterAI-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d41df28f170d9d227322345f5027327da86790e5893c246f0bea537d56d2d585
|
|
| MD5 |
34463b92f89fd50b0ba2996e071af8e7
|
|
| BLAKE2b-256 |
e0904ce9cf734892b305ffde8c54afcaa14ef61c545828bc2209e8c6aa6ca790
|