[GH-ISSUE #291] kiro不支持图像 #205

Closed
opened 2026-02-27 07:18:28 +03:00 by kerem · 2 comments
Owner

Originally created by @88489754 on GitHub (Jan 29, 2026).
Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/291

kiro不支持图像,上传了图像无法回答

{
"model": "claude-sonnet-4-5-20250929",
"stream":false,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "这个是什么"
},
{
"type": "image_url",
"image_url": {
"url": "https://p2.a.kwimgs.com/bs2/upload-ylab-stunt/ai_portal/1731125871/6N0QrAnAeU/409-f054fa25c21a.png"
}
}
]
}
]
}

Originally created by @88489754 on GitHub (Jan 29, 2026). Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/291 kiro不支持图像,上传了图像无法回答 { "model": "claude-sonnet-4-5-20250929", "stream":false, "messages": [ { "role": "user", "content": [ { "type": "text", "text": "这个是什么" }, { "type": "image_url", "image_url": { "url": "https://p2.a.kwimgs.com/bs2/upload-ylab-stunt/ai_portal/1731125871/6N0QrAnAeU/409-f054fa25c21a.png" } } ] } ] }
kerem closed this issue 2026-02-27 07:18:29 +03:00
Author
Owner

@88489754 commented on GitHub (Jan 29, 2026):

希望支持这两种类型的openai的图像问答

from openai import OpenAI

client = OpenAI()

response = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What’s in this image?"},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
},
],
}
],
max_tokens=300,
)

print(response.choices[0])


import base64
import requests

api_key = "YOUR_OPENAI_API_KEY"

def encode_image(image_path):
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode('utf-8')

image_path = "path_to_your_image.jpg"

base64_image = encode_image(image_path)

headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}

payload = {
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What’s in this image?"
},
{
"type": "image_url",
"image_url": {
"url": f"data:image/jpeg;base64,{base64_image}"
}
}
]
}
],
"max_tokens": 300
}

response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)

print(response.json())

<!-- gh-comment-id:3814923626 --> @88489754 commented on GitHub (Jan 29, 2026): 希望支持这两种类型的openai的图像问答 from openai import OpenAI client = OpenAI() response = client.chat.completions.create( model="gpt-4o", messages=[ { "role": "user", "content": [ {"type": "text", "text": "What’s in this image?"}, { "type": "image_url", "image_url": { "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg", }, }, ], } ], max_tokens=300, ) print(response.choices[0]) ------------------------------------------------------ import base64 import requests api_key = "YOUR_OPENAI_API_KEY" def encode_image(image_path): with open(image_path, "rb") as image_file: return base64.b64encode(image_file.read()).decode('utf-8') image_path = "path_to_your_image.jpg" base64_image = encode_image(image_path) headers = { "Content-Type": "application/json", "Authorization": f"Bearer {api_key}" } payload = { "model": "gpt-4o", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "What’s in this image?" }, { "type": "image_url", "image_url": { "url": f"data:image/jpeg;base64,{base64_image}" } } ] } ], "max_tokens": 300 } response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload) print(response.json())
Author
Owner

@justlovemaki commented on GitHub (Jan 29, 2026):

使用claude协议

<!-- gh-comment-id:3815352953 --> @justlovemaki commented on GitHub (Jan 29, 2026): 使用claude协议
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#205
No description provided.