Image to image (इमेज एडिटिंग)
BetterToken के OpenAI-compatible API से GPT Image 2 का उपयोग करके reference image से इमेज बनाएं या संपादित करें।
POST /v1/images/edits
image-to-image endpoint multipart/form-data request body उपयोग करता है। एक या अधिक reference image अपलोड करें और prompt व parameter फ़ील्ड को form field के रूप में भेजें।
https://www.bettertoken.ai/v1 को Base URL के रूप में उपयोग करें। BetterToken API Key को Authorization: Bearer YOUR_API_KEY से भेजें।अनुशंसित मान
हर अनुरोध में इन फ़ील्ड को स्पष्ट रूप से भेजें:image उपयोग करें। कई reference image के लिए image[] फ़ील्ड दोहराएं।
एक reference image
कई reference image
Python उदाहरण
अनुशंसित आकार
size अपेक्षित aspect ratio और size tier दर्शाता है। वास्तविक लौटे pixel server द्वारा map या adjust किए जा सकते हैं। output को मांगे गए मान पर जबरन crop करने के बजाय decoded इमेज dimension उपयोग करें।
इमेज सहेजें
सफल response OpenAI-compatible इमेज response स्वरूप का पालन करता है:data[0].b64_json पढ़ें और इसे base64 image content के रूप में सहेजें। output_format: "png" हमेशा सेट करें ताकि decoded इमेज को .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"

