Submit an APIMart-compatible GPT Image 2 text-to-image task
curl --request POST \
--url https://gateway.yir.ai/apimart/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "A quiet observatory above a sea of clouds",
"size": "16:9",
"resolution": "1k",
"n": 1
}
'import requests
url = "https://gateway.yir.ai/apimart/v1/images/generations"
payload = {
"model": "gpt-image-2",
"prompt": "A quiet observatory above a sea of clouds",
"size": "16:9",
"resolution": "1k",
"n": 1
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-image-2',
prompt: 'A quiet observatory above a sea of clouds',
size: '16:9',
resolution: '1k',
n: 1
})
};
fetch('https://gateway.yir.ai/apimart/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://gateway.yir.ai/apimart/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-image-2',
'prompt' => 'A quiet observatory above a sea of clouds',
'size' => '16:9',
'resolution' => '1k',
'n' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://gateway.yir.ai/apimart/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"A quiet observatory above a sea of clouds\",\n \"size\": \"16:9\",\n \"resolution\": \"1k\",\n \"n\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://gateway.yir.ai/apimart/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"A quiet observatory above a sea of clouds\",\n \"size\": \"16:9\",\n \"resolution\": \"1k\",\n \"n\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://gateway.yir.ai/apimart/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"A quiet observatory above a sea of clouds\",\n \"size\": \"16:9\",\n \"resolution\": \"1k\",\n \"n\": 1\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"data": [
{
"status": "<string>",
"task_id": "<string>"
}
]
}{
"code": 123,
"error": {
"code": "<string>",
"message": "<string>"
}
}Gateway reference
Submit an APIMart-compatible GPT Image 2 text-to-image task
Submit an APIMart-compatible GPT Image 2 text-to-image task
curl --request POST \
--url https://gateway.yir.ai/apimart/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "A quiet observatory above a sea of clouds",
"size": "16:9",
"resolution": "1k",
"n": 1
}
'import requests
url = "https://gateway.yir.ai/apimart/v1/images/generations"
payload = {
"model": "gpt-image-2",
"prompt": "A quiet observatory above a sea of clouds",
"size": "16:9",
"resolution": "1k",
"n": 1
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-image-2',
prompt: 'A quiet observatory above a sea of clouds',
size: '16:9',
resolution: '1k',
n: 1
})
};
fetch('https://gateway.yir.ai/apimart/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://gateway.yir.ai/apimart/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-image-2',
'prompt' => 'A quiet observatory above a sea of clouds',
'size' => '16:9',
'resolution' => '1k',
'n' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://gateway.yir.ai/apimart/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"A quiet observatory above a sea of clouds\",\n \"size\": \"16:9\",\n \"resolution\": \"1k\",\n \"n\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://gateway.yir.ai/apimart/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"A quiet observatory above a sea of clouds\",\n \"size\": \"16:9\",\n \"resolution\": \"1k\",\n \"n\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://gateway.yir.ai/apimart/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"A quiet observatory above a sea of clouds\",\n \"size\": \"16:9\",\n \"resolution\": \"1k\",\n \"n\": 1\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"data": [
{
"status": "<string>",
"task_id": "<string>"
}
]
}{
"code": 123,
"error": {
"code": "<string>",
"message": "<string>"
}
}Authorizations
Use Authorization: Bearer <YIR_API_KEY>. Upstream provider keys are not accepted.
Headers
Optional caller-generated key. Reusing a key with a different request is rejected.
Maximum string length:
255Body
application/json
The JSON body must be no larger than 256 KiB. Unknown fields are rejected.
Allowed value:
"gpt-image-2"Non-blank Unicode text prompt
Required string length:
1 - 20000Pattern:
\SSome KIE resolution/aspect-ratio combinations are unsupported: auto requires 1K; 1:1 rejects 4K; 5:4, 4:5, 3:1, 1:3 and 9:21 require 1K.
Available options:
auto, 1:1, 3:2, 2:3, 4:3, 3:4, 5:4, 4:5, 16:9, 9:16, 2:1, 1:2, 3:1, 1:3, 21:9, 9:21 Available options:
1k, 2k, 4k ⌘I