В документации сказано:
image string Required
The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
Я пытаюсь отправить запрос так:
headers = {
"Content-Type": "multipart/form-data",
"Authorization": f"Bearer {OPENAI_TOKEN}",
}
async with aiohttp.ClientSession() as session:
async with session.post("https://api.openai.com/v1/images/variations", headers=headers, data=data) as response:
data = await response.json()
data выглядит так:
data = {
"image": image,
"n": str(count),
"size": resolution,
"response_format": "url",
"user": user,
}
Пробовал также использовать FormData
form_data = aiohttp.FormData()
form_data.add_field("image", image)
form_data.add_field("n", str(count))
form_data.add_field("size", resolution)
form_data.add_field("response_format", "url")
form_data.add_field("user", str(user))
В итоге в ответ ошибка от API
{'error': {'code': None, 'message': "'image' is a required property", 'param': None, 'type': 'invalid_request_error'}}