生成图片
curl --request POST \
--url https://api.vizluma.online/v1/images/generationsimport requests
url = "https://api.vizluma.online/v1/images/generations"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.vizluma.online/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://api.vizluma.online/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",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.vizluma.online/v1/images/generations"
req, _ := http.NewRequest("POST", url, nil)
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.vizluma.online/v1/images/generations")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vizluma.online/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body图像接口
生成图片
同步生成图片,返回 URL 或 Base64 图片结果。
生成图片
curl --request POST \
--url https://api.vizluma.online/v1/images/generationsimport requests
url = "https://api.vizluma.online/v1/images/generations"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.vizluma.online/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://api.vizluma.online/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",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.vizluma.online/v1/images/generations"
req, _ := http.NewRequest("POST", url, nil)
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.vizluma.online/v1/images/generations")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vizluma.online/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body请求
使用 HTTPS 和 JSON 请求体:POST https://api.vizluma.online/v1/images/generations
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
stream: true 和 mask 不在当前支持范围内。不要假设官方接口的所有扩展参数在这里都可用。
请求示例
curl --fail-with-body --silent --show-error \
--connect-timeout 15 --max-time 600 \
"$VIZLUMA_BASE_URL/images/generations" \
-H "Authorization: Bearer $VIZLUMA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "一只小橘猫坐在纯白色背景上,简洁插画,无文字",
"size": "1024x1024",
"n": 1,
"response_format": "url"
}' \
-o generation.json
成功响应
HTTP200,以下链接为结构占位,不是实际图片:
{
"created": 1793289600,
"data": [
{
"url": "https://static.vizluma.online/new-api/images/IMAGE_OBJECT.png"
}
]
}
| 字段 | 类型 | 说明 |
|---|---|---|
created | integer | 结果/任务创建时间,Unix 秒时间戳;不表示生成结束时间 |
data | array | 图片结果列表,遍历每个有效条目 |
data[].url | string | 图片下载链接;使用实际返回值,不拼接固定域名和路径 |
data[].b64_json | string | Base64 图片内容,返回此形式时解码保存 |
b64_json 是可选返回方式:将请求的 response_format 改为 b64_json。服务端实现和响应回退说明见 图片结果与保存。生产接入不应假设响应总有 usage、任务 ID 或 revised_prompt。
执行与结果
- 一次请求同步等待图片完成,不需要调用方轮询任务接口。
- 不支持客户端要求 SSE 流式生图。
n大于 1 时需遍历返回数组,不要假设只读取第一项即可。- 请求超时或断连时结果可能尚不确定,先核对记录,见 重试说明。
错误响应
错误使用非2xx HTTP 状态码。错误消息可能包含请求 ID;不要依赖固定中文或英文字符串判断错误。完整分类见 错误处理。