CharacterAI
  • 👋Welcome
  • 🧑‍💻Quick Start
  • 🛠️API
    • 🔑 Values
    • ⚠️ Errors
    • connect
    • ping
    • user
      • info
      • get_profile
      • followers
      • following
      • recent
      • update
    • post
      • get_post
      • my_posts
      • get_posts
      • upvote
      • undo_upvote
      • send_comment
      • delete_comment
      • create
      • delete
      • get_topics
      • feed
    • character
      • create
      • update
      • trending
      • recommended
      • categories
      • info
      • search
      • voices
    • chat
      • create_room
      • rate
      • next_message
      • get_histories
      • get_history
      • get_chat
      • send_message
      • delete_message
      • new_chat
    • chat2
      • next_message
      • send_message
      • get_histories
      • new_chat
      • get_chat
      • get_history
      • rate
      • delete_message
  • 📚Examples
    • Chatting
    • Parse Chat
  • ⚠️Issues
Powered by GitBook
On this page
  • text [str]
  • history_id [str]
  • tgt [str]
  • image_description [str] (optional)
  • image_description_type [str] (optional)
  • image_rel_path [str] (optional)
  • token [str] (optional)
  1. API
  2. chat

send_message

Sending a message to a character

client.chat.send_message('HISTORY_ID', 'TGT', 'TEXT')

or send message with image

from characterai import PyCAI

client = PyCAI('TOKEN')

image = client.upload_image('image.jpg')

message = client.chat.send_message(
    'HISTORY_ID', 'TGT', 'TEXT',
    image_description_type='AUTO_IMAGE_CAPTIONING',
    image_rel_path=f'https://characterai.io/i/400/static/user/{image["value"]}',
    image_origin_type='UPLOADED'
)
    
print(message)
import asyncio
from characterai import PyAsyncCAI

async def main():
    client = PyAsyncCAI('TOKEN')

    image = await client.upload_image('PATH')

    message = await client.chat.send_message(
        'HISTORY_ID', 'TGT', 'TEXT',
        image_description_type='AUTO_IMAGE_CAPTIONING',
        image_rel_path=f'https://characterai.io/i/400/static/user/{image["value"]}',
        image_origin_type='UPLOADED'
    )
    
    print(message)

asyncio.run(main())

text [str]

Message text

history_id [str]

Unique ID for character history

tgt [str]

Character's username

image_description [str] (optional)

Image description instead of automatic recognition, set image_description_type to HUMAN

image_description_type [str] (optional)

When image uploaded, can be HUMAN or AUTO_IMAGE_CAPTIONING

image_rel_path [str] (optional)

The path to the image on the server. You can create this path with the upload_image() function, set image_origin_type to UPLOADED

token [str] (optional)

You can set a specific token for the function, it will be executed from the specified token

Previousget_chatNextdelete_message

Last updated 1 year ago

🛠️