GPT-4o Image 图片生成
curl --request POST \
--url https://api.sinancode.com/v1/generate/k/gpt4o-image \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"size": "1:1",
"filesUrl": [
""
],
"isEnhance": false,
"maskUrl": "",
"nVariants": 1,
"prompt": "A beautiful sunset over the mountains"
}
'import requests
url = "https://api.sinancode.com/v1/generate/k/gpt4o-image"
payload = {
"size": "1:1",
"filesUrl": [""],
"isEnhance": False,
"maskUrl": "",
"nVariants": 1,
"prompt": "A beautiful sunset over the mountains"
}
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({
size: '1:1',
filesUrl: [''],
isEnhance: false,
maskUrl: '',
nVariants: 1,
prompt: 'A beautiful sunset over the mountains'
})
};
fetch('https://api.sinancode.com/v1/generate/k/gpt4o-image', 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://api.sinancode.com/v1/generate/k/gpt4o-image",
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([
'size' => '1:1',
'filesUrl' => [
''
],
'isEnhance' => false,
'maskUrl' => '',
'nVariants' => 1,
'prompt' => 'A beautiful sunset over the mountains'
]),
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://api.sinancode.com/v1/generate/k/gpt4o-image"
payload := strings.NewReader("{\n \"size\": \"1:1\",\n \"filesUrl\": [\n \"\"\n ],\n \"isEnhance\": false,\n \"maskUrl\": \"\",\n \"nVariants\": 1,\n \"prompt\": \"A beautiful sunset over the mountains\"\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://api.sinancode.com/v1/generate/k/gpt4o-image")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"size\": \"1:1\",\n \"filesUrl\": [\n \"\"\n ],\n \"isEnhance\": false,\n \"maskUrl\": \"\",\n \"nVariants\": 1,\n \"prompt\": \"A beautiful sunset over the mountains\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sinancode.com/v1/generate/k/gpt4o-image")
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 \"size\": \"1:1\",\n \"filesUrl\": [\n \"\"\n ],\n \"isEnhance\": false,\n \"maskUrl\": \"\",\n \"nVariants\": 1,\n \"prompt\": \"A beautiful sunset over the mountains\"\n}"
response = http.request(request)
puts response.read_body{
"task_id": "01234567-89ab-cdef-0123-456789abcdef"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}图片生成 - gpt4o
GPT-4o Image
使用 OpenAI GPT-4o 模型生成图片(异步)
POST
/
generate
/
k
/
gpt4o-image
GPT-4o Image 图片生成
curl --request POST \
--url https://api.sinancode.com/v1/generate/k/gpt4o-image \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"size": "1:1",
"filesUrl": [
""
],
"isEnhance": false,
"maskUrl": "",
"nVariants": 1,
"prompt": "A beautiful sunset over the mountains"
}
'import requests
url = "https://api.sinancode.com/v1/generate/k/gpt4o-image"
payload = {
"size": "1:1",
"filesUrl": [""],
"isEnhance": False,
"maskUrl": "",
"nVariants": 1,
"prompt": "A beautiful sunset over the mountains"
}
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({
size: '1:1',
filesUrl: [''],
isEnhance: false,
maskUrl: '',
nVariants: 1,
prompt: 'A beautiful sunset over the mountains'
})
};
fetch('https://api.sinancode.com/v1/generate/k/gpt4o-image', 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://api.sinancode.com/v1/generate/k/gpt4o-image",
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([
'size' => '1:1',
'filesUrl' => [
''
],
'isEnhance' => false,
'maskUrl' => '',
'nVariants' => 1,
'prompt' => 'A beautiful sunset over the mountains'
]),
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://api.sinancode.com/v1/generate/k/gpt4o-image"
payload := strings.NewReader("{\n \"size\": \"1:1\",\n \"filesUrl\": [\n \"\"\n ],\n \"isEnhance\": false,\n \"maskUrl\": \"\",\n \"nVariants\": 1,\n \"prompt\": \"A beautiful sunset over the mountains\"\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://api.sinancode.com/v1/generate/k/gpt4o-image")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"size\": \"1:1\",\n \"filesUrl\": [\n \"\"\n ],\n \"isEnhance\": false,\n \"maskUrl\": \"\",\n \"nVariants\": 1,\n \"prompt\": \"A beautiful sunset over the mountains\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sinancode.com/v1/generate/k/gpt4o-image")
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 \"size\": \"1:1\",\n \"filesUrl\": [\n \"\"\n ],\n \"isEnhance\": false,\n \"maskUrl\": \"\",\n \"nVariants\": 1,\n \"prompt\": \"A beautiful sunset over the mountains\"\n}"
response = http.request(request)
puts response.read_body{
"task_id": "01234567-89ab-cdef-0123-456789abcdef"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}{
"error_code": "<string>",
"message": "<string>"
}使用 OpenAI 的 GPT-4o 原生图像生成能力创建和编辑图片。
模型特点:
- 原生多模态 - 图像生成内置于 GPT-4o 架构,非外部模型调用
- 精准文字渲染 - 显著优于 DALL·E 3 的文字生成能力
- 多轮对话一致性 - 通过自然对话迭代优化,保持风格连贯
- 图片理解与编辑 - 支持上传图片作为输入进行理解和变换
授权
请使用您的 API Token 进行认证
请求体
application/json
Task parameters
尺寸(必填)- 图片宽高比,必须是支持的格式之一
可用选项:
1:1, 3:2, 2:3 示例:
"1:1"
文件 URL 列表(可选)- 文件 URL 列表,最多5张图片
示例:
[""]
启用增强(可选)- 提示词增强,默认 false
示例:
false
遮罩 URL(可选)- 用于编辑的遮罩图片 URL,黑色区域将被替换/修改
示例:
""
变体数量(可选)- 图片变体数量,可选 1、2 或 4,默认1
可用选项:
1, 2, 4 示例:
1
提示词(可选)- 描述你希望 GPT-4o 生成的内容
示例:
"A beautiful sunset over the mountains"
响应
OK
Task ID
示例:
"01234567-89ab-cdef-0123-456789abcdef"
⌘I