Generate Image
curl --request POST \
--url https://utoken.yoostudio.ai/v1/images/generations/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"model": "<string>",
"n": 123,
"size": "<string>",
"background": "<string>",
"moderation": "<string>",
"quality": "<string>",
"stream": "<string>",
"style": "<string>",
"user": "<string>"
}
'import requests
url = "https://utoken.yoostudio.ai/v1/images/generations/"
payload = {
"prompt": "<string>",
"model": "<string>",
"n": 123,
"size": "<string>",
"background": "<string>",
"moderation": "<string>",
"quality": "<string>",
"stream": "<string>",
"style": "<string>",
"user": "<string>"
}
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({
prompt: '<string>',
model: '<string>',
n: 123,
size: '<string>',
background: '<string>',
moderation: '<string>',
quality: '<string>',
stream: '<string>',
style: '<string>',
user: '<string>'
})
};
fetch('https://utoken.yoostudio.ai/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://utoken.yoostudio.ai/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([
'prompt' => '<string>',
'model' => '<string>',
'n' => 123,
'size' => '<string>',
'background' => '<string>',
'moderation' => '<string>',
'quality' => '<string>',
'stream' => '<string>',
'style' => '<string>',
'user' => '<string>'
]),
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://utoken.yoostudio.ai/v1/images/generations/"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"quality\": \"<string>\",\n \"stream\": \"<string>\",\n \"style\": \"<string>\",\n \"user\": \"<string>\"\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://utoken.yoostudio.ai/v1/images/generations/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"quality\": \"<string>\",\n \"stream\": \"<string>\",\n \"style\": \"<string>\",\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://utoken.yoostudio.ai/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 \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"quality\": \"<string>\",\n \"stream\": \"<string>\",\n \"style\": \"<string>\",\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"url": "<string>",
"b64_json": "<string>"
}
],
"usage": {
"total_tokens": 123,
"input_tokens": 123,
"output_tokens": 123,
"input_tokens_details": {
"text_tokens": 123,
"image_tokens": 123
}
}
}OpenAI
Generate Images
在给定提示的情况下创建图像。了解更多。
POST
/
v1
/
images
/
generations
/
Generate Image
curl --request POST \
--url https://utoken.yoostudio.ai/v1/images/generations/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"model": "<string>",
"n": 123,
"size": "<string>",
"background": "<string>",
"moderation": "<string>",
"quality": "<string>",
"stream": "<string>",
"style": "<string>",
"user": "<string>"
}
'import requests
url = "https://utoken.yoostudio.ai/v1/images/generations/"
payload = {
"prompt": "<string>",
"model": "<string>",
"n": 123,
"size": "<string>",
"background": "<string>",
"moderation": "<string>",
"quality": "<string>",
"stream": "<string>",
"style": "<string>",
"user": "<string>"
}
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({
prompt: '<string>',
model: '<string>',
n: 123,
size: '<string>',
background: '<string>',
moderation: '<string>',
quality: '<string>',
stream: '<string>',
style: '<string>',
user: '<string>'
})
};
fetch('https://utoken.yoostudio.ai/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://utoken.yoostudio.ai/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([
'prompt' => '<string>',
'model' => '<string>',
'n' => 123,
'size' => '<string>',
'background' => '<string>',
'moderation' => '<string>',
'quality' => '<string>',
'stream' => '<string>',
'style' => '<string>',
'user' => '<string>'
]),
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://utoken.yoostudio.ai/v1/images/generations/"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"quality\": \"<string>\",\n \"stream\": \"<string>\",\n \"style\": \"<string>\",\n \"user\": \"<string>\"\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://utoken.yoostudio.ai/v1/images/generations/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"quality\": \"<string>\",\n \"stream\": \"<string>\",\n \"style\": \"<string>\",\n \"user\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://utoken.yoostudio.ai/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 \"prompt\": \"<string>\",\n \"model\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"background\": \"<string>\",\n \"moderation\": \"<string>\",\n \"quality\": \"<string>\",\n \"stream\": \"<string>\",\n \"style\": \"<string>\",\n \"user\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"url": "<string>",
"b64_json": "<string>"
}
],
"usage": {
"total_tokens": 123,
"input_tokens": 123,
"output_tokens": 123,
"input_tokens_details": {
"text_tokens": 123,
"image_tokens": 123
}
}
}Authorizations
Body
application/json
Allows setting transparency for the background of generated images. This parameter only supports gpt-image-1. Must be one of transparent, opaque, or auto (default). When using auto, the model will automatically determine the optimal background for the image.
If transparent, the output format needs to support transparency, so it should be set to png (default) or webp.
Was this page helpful?
