이미지 변환(이미지 편집)
BetterToken의 OpenAI-compatible API를 통해 GPT Image 2로 reference images에서 이미지를 생성하거나 편집하세요.
POST /v1/images/edits
image-to-image endpoint는 multipart/form-data request body를 사용합니다. 하나 이상의 reference images를 업로드하고 prompt 및 parameter fields를 form fields로 제출하세요.
https://www.bettertoken.ai/v1을 Base URL로 사용하세요. Authorization: Bearer YOUR_API_KEY를 통해 BetterToken API Key를 전달하세요.권장 값
모든 request에서 다음 fields를 명시적으로 보내세요.image를 사용하세요. 여러 reference images에는 반복된 image[] fields를 사용하세요.
단일 reference image
여러 reference images
Python 예시
권장 sizes
size는 예상 aspect ratio와 size tier를 나타냅니다. 실제 반환 pixels는 server에 의해 mapping 또는 adjusted될 수 있습니다. output을 요청한 값으로 강제로 crop하지 말고 decoded image dimensions를 사용하세요.
이미지 저장
성공한 response는 다음 OpenAI-compatible image response shape를 따릅니다.data[0].b64_json을 읽어 base64 image content로 저장하세요. 항상 output_format: "png"를 설정하면 decoded image를 .png로 저장할 수 있습니다.
Response flow
이 endpoint는 synchronous입니다.POST /images/edits를 보낸 후 server가 response할 때까지 현재 HTTP request를 열어 두세요. generation에 성공하면 image content가 data[0].b64_json으로 반환됩니다.
endpoint는 task_id를 반환하지 않으며 별도의 status query 또는 result download endpoint가 없습니다.
관련 문서
인증
Use your BetterToken API Key as a bearer token. Do not expose API keys in frontend browser code, screenshots, logs, tickets, or Git repositories.
본문
固定使用 YOUR_MODEL_ID。
YOUR_MODEL_ID "YOUR_MODEL_ID"
图片编辑或参考图生成说明。
"参考这张图片,生成一张更精致的方形产品主视觉,保持主体风格一致。"
单张参考图字段名。单参考图时使用 image。
多张参考图字段名。多参考图时重复提交 image[]。
推荐固定为 1。多张图片建议发起多次独立请求。
"1"
图片尺寸和比例档位。auto 为自动;1024x1024 和 2048x2048 为 1:1;1536x1024 为 3:2;1024x1536 为 2:3;1536x1152 为 4:3;1152x1536 为 3:4;2048x1152 和 3840x2160 为 16:9;2160x3840 为 9:16。实际返回像素可能由服务端映射或调整,客户端应以解码后的真实图片尺寸为准。
auto, 1024x1024, 1536x1024, 1024x1536, 1536x1152, 1152x1536, 2048x2048, 2048x1152, 3840x2160, 2160x3840 "1024x1024"
推荐固定为 b64_json。
b64_json "b64_json"
推荐固定为 png。不要依赖 jpeg 或 webp 直接返回对应格式。
png "png"

