import os
import requests
import json
def image_edits():
url = "https://api-ai.gitcode.com/v1/images/edits"
headers = {
"Authorization": f"Bearer {os.environ['ACCESS_TOKEN']}"
}
# 图片文件路径
image_path = '/Your/Image/Path.png'
# 使用 with 语句确保文件正确关闭
with open(image_path, 'rb') as image_file:
# 文件和表单数据
files = {
'image': image_file,
}
data = {
"prompt": "在这个照片上帮我加上日期水印",
"model": "Qwen/Qwen-Image-Edit-2509"
}
# 发送 POST 请求
response = requests.post(url, headers=headers, files=files, data=data)
# 打印响应内容
print(response.json())
image_edits()