Edit image
package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.mirapi.ai/v1/images/edits"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"31225951_59371037e9_small.png\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask\"; filename=\"file\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\nContent-Type: text/plain\r\n\r\nA cute baby sea otter wearing a beret.\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"n\"\r\nContent-Type: text/plain\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"size\"\r\nContent-Type: text/plain\r\n\r\n1024x1024\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"response_format\"\r\nContent-Type: text/plain\r\n\r\nurl\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"user\"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\nContent-Type: text/plain\r\n\r\ndall-e-2\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>") req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://api.mirapi.ai/v1/images/edits';const form = new FormData();form.append('image', 'cmMtdXBsb2FkLTE2ODc4MzMzNDc3NTEtMjA=/31225951_59371037e9_small.png');form.append('mask', 'file');form.append('prompt', 'A cute baby sea otter wearing a beret.');form.append('n', '1');form.append('size', '1024x1024');form.append('response_format', 'url');form.append('user', '');form.append('model', 'dall-e-2');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.mirapi.ai/v1/images/edits \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form image=@cmMtdXBsb2FkLTE2ODc4MzMzNDc3NTEtMjA=/31225951_59371037e9_small.png \ --form mask=@file \ --form 'prompt=A cute baby sea otter wearing a beret.' \ --form n=1 \ --form size=1024x1024 \ --form response_format=url \ --form user= \ --form model=dall-e-2Creates an edited or extended image given an original image and a prompt.
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where image should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as image.
A text description of the desired image(s). The maximum length is 1000 characters.
The number of images to generate. Must be between 1 and 10.
The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.
The format in which the generated images are returned. Must be one of url or b64_json.
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
Example
{ "image": "cmMtdXBsb2FkLTE2ODc4MzMzNDc3NTEtMjA=/31225951_59371037e9_small.png", "mask": [], "prompt": "A cute baby sea otter wearing a beret.", "n": "1", "size": "1024x1024", "response_format": "url", "user": "", "model": "dall-e-2"}Responses
Section titled “Responses”object
Examplegenerated
{}