OpenAI Images 兼容图像生成
curl --request POST \
--url https://www.geeknow.top/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"quality": "<string>",
"response_format": "<string>",
"style": {},
"background": {},
"watermark": true
}
'import requests
url = "https://www.geeknow.top/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"quality": "<string>",
"response_format": "<string>",
"style": {},
"background": {},
"watermark": True
}
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: '<string>',
prompt: '<string>',
n: 123,
size: '<string>',
quality: '<string>',
response_format: '<string>',
style: {},
background: {},
watermark: true
})
};
fetch('https://www.geeknow.top/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://www.geeknow.top/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' => '<string>',
'prompt' => '<string>',
'n' => 123,
'size' => '<string>',
'quality' => '<string>',
'response_format' => '<string>',
'style' => [
],
'background' => [
],
'watermark' => true
]),
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://www.geeknow.top/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\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://www.geeknow.top/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.geeknow.top/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\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\n}"
response = http.request(request)
puts response.read_body{
"created": 1735689600,
"data": [
{
"url": "https://.../images/img-abc123.png",
"revised_prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀"
}
]
}
{
"created": 1735689600,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"revised_prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀"
}
]
}
{
"error": {
"message": "size must be one of 1024x1024, 1024x1792 or 1792x1024 for dall-e-3",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "用户额度不足",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "当前请求频率过高,请稍后再试",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
OpenAI Images 兼容
OpenAI Images 兼容图像生成
使用 POST /v1/images/generations 调用统一图像生成入口,按 model 选择 gpt-image-1、dall-e-3、dall-e-2 等兼容模型。
POST
https://www.geeknow.top
/
v1
/
images
/
generations
OpenAI Images 兼容图像生成
curl --request POST \
--url https://www.geeknow.top/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"quality": "<string>",
"response_format": "<string>",
"style": {},
"background": {},
"watermark": true
}
'import requests
url = "https://www.geeknow.top/v1/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"n": 123,
"size": "<string>",
"quality": "<string>",
"response_format": "<string>",
"style": {},
"background": {},
"watermark": True
}
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: '<string>',
prompt: '<string>',
n: 123,
size: '<string>',
quality: '<string>',
response_format: '<string>',
style: {},
background: {},
watermark: true
})
};
fetch('https://www.geeknow.top/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://www.geeknow.top/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' => '<string>',
'prompt' => '<string>',
'n' => 123,
'size' => '<string>',
'quality' => '<string>',
'response_format' => '<string>',
'style' => [
],
'background' => [
],
'watermark' => true
]),
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://www.geeknow.top/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\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://www.geeknow.top/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.geeknow.top/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\": \"<string>\",\n \"prompt\": \"<string>\",\n \"n\": 123,\n \"size\": \"<string>\",\n \"quality\": \"<string>\",\n \"response_format\": \"<string>\",\n \"style\": {},\n \"background\": {},\n \"watermark\": true\n}"
response = http.request(request)
puts response.read_body{
"created": 1735689600,
"data": [
{
"url": "https://.../images/img-abc123.png",
"revised_prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀"
}
]
}
{
"created": 1735689600,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"revised_prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀"
}
]
}
{
"error": {
"message": "size must be one of 1024x1024, 1024x1792 or 1792x1024 for dall-e-3",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "用户额度不足",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "当前请求频率过高,请稍后再试",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
OpenAI Images 兼容图像生成
使用统一图像生成入口提交文生图请求,返回 OpenAI Images 风格响应。- 统一的图像生成接口,通过
model选择不同图像模型。 - 保持 OpenAI Images 响应结构:
created+data[]。 - 支持
url和b64_json两种返回格式。 dall-e-2、dall-e-3会按各自支持的尺寸范围校验。n不传或显式传0时会按1处理。
方法与路径
POST /v1/images/generations
请求示例
curl -X POST https://www.geeknow.top/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀",
"n": 1,
"size": "1024x1024",
"quality": "auto",
"response_format": "url"
}'
import requests
resp = requests.post(
"https://www.geeknow.top/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "gpt-image-1",
"prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀",
"n": 1,
"size": "1024x1024",
"quality": "auto",
"response_format": "url",
},
timeout=60,
)
print(resp.json())
const response = await fetch("https://www.geeknow.top/v1/images/generations", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-image-1",
prompt: "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀",
n: 1,
size: "1024x1024",
quality: "auto",
response_format: "url",
}),
});
console.log(await response.json());
响应示例
{
"created": 1735689600,
"data": [
{
"url": "https://.../images/img-abc123.png",
"revised_prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀"
}
]
}
{
"created": 1735689600,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"revised_prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀"
}
]
}
{
"error": {
"message": "size must be one of 1024x1024, 1024x1792 or 1792x1024 for dall-e-3",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request"
}
}
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"param": "",
"code": "invalid_api_key"
}
}
{
"error": {
"message": "用户额度不足",
"type": "new_api_error",
"param": "",
"code": "insufficient_user_quota"
}
}
{
"error": {
"message": "当前请求频率过高,请稍后再试",
"type": "new_api_error",
"param": "",
"code": "too_many_requests"
}
}
{
"error": {
"message": "bad response body",
"type": "new_api_error",
"param": "",
"code": "bad_response_body"
}
}
认证
Authorization: Bearer YOUR_API_KEY
Body
模型名称。该字段必填。
生成提示词。对于图像生成语义应视为必填;具体校验规则取决于目标模型和渠道能力。
生成数量。若不传或显式传
0,按 1 处理。输出尺寸。
dall-e-2 只接受 256x256、512x512、1024x1024;dall-e-3 只接受 1024x1024、1024x1792、1792x1024。如果你实际使用的是
gpt-image-2-pro,还可以使用 1:1(2K)、4:3(2K)、3:2(2K)、2:3(2K)、16:9(2K)、9:16(2K)、1:1(4K)、4:3(4K)、3:2(4K)、2:3(4K)、16:9(4K)、9:16(4K) 这类高分档位。完整映射见 图像模型支持矩阵。图像质量。
dall-e-3 默认补成 standard;gpt-image-1 默认补成 auto。返回格式,常见值为
url、b64_json。当请求 b64_json 或 base64 时,返回 Base64 图像数据。风格字段,原样透传给支持的上游。
背景控制字段,原样透传给支持的上游。
显式水印开关。
false 与不传语义不同:不传表示交给默认策略,传 false 表示明确关闭。Response
生成时间戳。
response_format = url 时返回的图片 URL。response_format = b64_json 时返回的图片 Base64 数据。部分上游会改写提示词并返回在这个字段里。
附加元数据。是否存在取决于具体渠道。
使用场景
基础生图
curl -X POST https://www.geeknow.top/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "生成一张简洁的产品海报"
}'
高质量 DALL·E 3
curl -X POST https://www.geeknow.top/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type": "application/json" \
-d '{
"model": "dall-e-3",
"prompt": "一张科幻城市夜景插画",
"size": "1792x1024",
"quality": "hd",
"response_format": "url"
}'
Base64 输出
curl -X POST https://www.geeknow.top/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type": "application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "生成一张简洁的图标集海报",
"response_format": "b64_json"
}'
注意事项
这个页面只描述统一入口的公共语义,不代表所有图像渠道都支持完全相同的字段。像
style、background、watermark 等字段是否真正生效,取决于最终命中的渠道。相关接口
⌘I