图片生成(OpenAI 兼容)
curl --request POST \
--url https://xxx.wengaocloud.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "一张极简风格的云端工作站插画"
}
'import requests
url = "https://xxx.wengaocloud.com/v1/images/generations"
payload = {
"model": "gpt-image-2",
"prompt": "一张极简风格的云端工作站插画"
}
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: '一张极简风格的云端工作站插画'})
};
fetch('https://xxx.wengaocloud.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://xxx.wengaocloud.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"一张极简风格的云端工作站插画\"\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))
}{
"created": 123,
"data": [
{
"url": "<string>",
"b64_json": "<string>"
}
]
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}图片生成
图片生成(OpenAI 兼容)
OpenAI 兼容的同步图片生成接口。该接口保留兼容形态,具体按 token 还是按图片单位计费,以模型和控制台价格配置为准。
图片生成(OpenAI 兼容)
curl --request POST \
--url https://xxx.wengaocloud.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"prompt": "一张极简风格的云端工作站插画"
}
'import requests
url = "https://xxx.wengaocloud.com/v1/images/generations"
payload = {
"model": "gpt-image-2",
"prompt": "一张极简风格的云端工作站插画"
}
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: '一张极简风格的云端工作站插画'})
};
fetch('https://xxx.wengaocloud.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://xxx.wengaocloud.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"gpt-image-2\",\n \"prompt\": \"一张极简风格的云端工作站插画\"\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))
}{
"created": 123,
"data": [
{
"url": "<string>",
"b64_json": "<string>"
}
]
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
⌘I
.png?fit=max&auto=format&n=v_sJS-AFS6goKAv3&q=85&s=e03202fddb83c95be2a503ab9c79163a)