Feishu upload image

From smallnest/goclaw · View interactive version

Feishu upload image is an AI agent skill from the GitHub repository smallnest/goclaw. Upload images to Feishu/Lark. Returns image_key for use in messages.

How to use this skill

Skill file

Feishu Upload Image

Upload images to Feishu/Lark and get the image_key for use in messages.

Usage

Upload from Local File

python3 ./scripts/upload_image.py /path/to/image.jpg

Upload via HTTP

python3 ./scripts/upload_image.py --type message --image-type message https://example.com/image.jpg

Upload from Base64

python3 ./scripts/upload_image.py --base64 "iVBORw0KGgoAAAANS..."

Options

| Option | Description | Default |

|--------|-------------|---------|

| --type message|avatar | Image usage type | message |

| --image-type message|avatar | Same as --type | message |

Limits

Response

Returns image_key which can be used in Feishu messages:

{
  "code": 0,
  "data": {
    "image_key": "img_v2_xxx"
  }
}

发送图片消息指南

获取必要信息

  1. 飞书访问令牌 (tenant_access_token 或 app_access_token)
  2. 接收者ID (open_id, user_id, chat_id, 或 email)

发送图片消息API

方式1:直接发送图片消息

curl -X POST https://open.feishu.cn/open-apis/im/v1/messages \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "receive_id": "{chat_id}",
    "msg_type": "image",
    "content": "{\"image_key\":\"{image_key}\"}"
  }'

方式2:在富文本中嵌入图片

curl -X POST https://open.feishu.cn/open-apis/im/v1/messages \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "receive_id": "{chat_id}",
    "msg_type": "post",
    "content": "{\"post\":{\"zh_cn\":{\"title\":\"图片消息\",\"content\":[[{\"tag\":\"img\",\"image_key\":\"{image_key}\"}]]}}}"
  }'

获取群聊chat_id

  1. 在飞书中打开群聊,查看URL中的chat_id
  2. 或者通过API查询群聊列表:
curl -X GET https://open.feishu.cn/open-apis/im/v1/chats \
  -H "Authorization: Bearer {access_token}"

实践经验

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.