> For the complete documentation index, see [llms.txt](https://pycai.gitbook.io/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pycai.gitbook.io/welcome/api/chat/send_message.md).

# send\_message

Sending a message to a character

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

or send message with image

{% tabs %}
{% tab title="Sync" %}

```python
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)
```

{% endtab %}

{% tab title="Async" %}

```python
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())
```

{% endtab %}
{% endtabs %}

### text <mark style="color:green;">\[str]</mark>

Message text

### history\_id <mark style="color:green;">\[str]</mark>

Unique ID for character history

### tgt <mark style="color:green;">\[str]</mark>

Character's username

### image\_description <mark style="color:green;">\[str]</mark> <mark style="color:purple;">(</mark>*<mark style="color:purple;">optional)</mark>*

Image description instead of automatic recognition, set `image_description_type` to `HUMAN`

### image\_description\_type <mark style="color:green;">\[str]</mark> <mark style="color:purple;">(</mark>*<mark style="color:purple;">optional)</mark>*

When image uploaded, can be `HUMAN` or `AUTO_IMAGE_CAPTIONING`

### image\_rel\_path <mark style="color:green;">\[str]</mark> <mark style="color:purple;">(</mark>*<mark style="color:purple;">optional)</mark>*

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 <mark style="color:green;">\[str]</mark> <mark style="color:purple;">(</mark>*<mark style="color:purple;">optional)</mark>*

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