AI生图-文生图
curl --request POST \
--url https://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"req.prompt": "<string>",
"req.size": "<string>",
"req.value": "<string>",
"req.req_key": "<string>",
"req.return_url": true,
"req.width": 123,
"req.height": 123
}
'import requests
url = "https://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit"
payload = {
"req.prompt": "<string>",
"req.size": "<string>",
"req.value": "<string>",
"req.req_key": "<string>",
"req.return_url": True,
"req.width": 123,
"req.height": 123
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
'req.prompt': '<string>',
'req.size': '<string>',
'req.value': '<string>',
'req.req_key': '<string>',
'req.return_url': true,
'req.width': 123,
'req.height': 123
})
};
fetch('https://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit', 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://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit",
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([
'req.prompt' => '<string>',
'req.size' => '<string>',
'req.value' => '<string>',
'req.req_key' => '<string>',
'req.return_url' => true,
'req.width' => 123,
'req.height' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit"
payload := strings.NewReader("{\n \"req.prompt\": \"<string>\",\n \"req.size\": \"<string>\",\n \"req.value\": \"<string>\",\n \"req.req_key\": \"<string>\",\n \"req.return_url\": true,\n \"req.width\": 123,\n \"req.height\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"req.prompt\": \"<string>\",\n \"req.size\": \"<string>\",\n \"req.value\": \"<string>\",\n \"req.req_key\": \"<string>\",\n \"req.return_url\": true,\n \"req.width\": 123,\n \"req.height\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"req.prompt\": \"<string>\",\n \"req.size\": \"<string>\",\n \"req.value\": \"<string>\",\n \"req.req_key\": \"<string>\",\n \"req.return_url\": true,\n \"req.width\": 123,\n \"req.height\": 123\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "操作成功",
"data": {
"images": [{
"url": "https://example.com/image.jpg"
}]
}
}
AI 生图
AI生图-文生图
POST
/
prod-api
/
nebula
/
v4
/
api
/
text2imageSubmit
AI生图-文生图
curl --request POST \
--url https://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"req.prompt": "<string>",
"req.size": "<string>",
"req.value": "<string>",
"req.req_key": "<string>",
"req.return_url": true,
"req.width": 123,
"req.height": 123
}
'import requests
url = "https://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit"
payload = {
"req.prompt": "<string>",
"req.size": "<string>",
"req.value": "<string>",
"req.req_key": "<string>",
"req.return_url": True,
"req.width": 123,
"req.height": 123
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
'req.prompt': '<string>',
'req.size': '<string>',
'req.value': '<string>',
'req.req_key': '<string>',
'req.return_url': true,
'req.width': 123,
'req.height': 123
})
};
fetch('https://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit', 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://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit",
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([
'req.prompt' => '<string>',
'req.size' => '<string>',
'req.value' => '<string>',
'req.req_key' => '<string>',
'req.return_url' => true,
'req.width' => 123,
'req.height' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit"
payload := strings.NewReader("{\n \"req.prompt\": \"<string>\",\n \"req.size\": \"<string>\",\n \"req.value\": \"<string>\",\n \"req.req_key\": \"<string>\",\n \"req.return_url\": true,\n \"req.width\": 123,\n \"req.height\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"req.prompt\": \"<string>\",\n \"req.size\": \"<string>\",\n \"req.value\": \"<string>\",\n \"req.req_key\": \"<string>\",\n \"req.return_url\": true,\n \"req.width\": 123,\n \"req.height\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"req.prompt\": \"<string>\",\n \"req.size\": \"<string>\",\n \"req.value\": \"<string>\",\n \"req.req_key\": \"<string>\",\n \"req.return_url\": true,\n \"req.width\": 123,\n \"req.height\": 123\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "操作成功",
"data": {
"images": [{
"url": "https://example.com/image.jpg"
}]
}
}
简介
提交文生图任务,用于根据文本描述生成新的图片。认证
string
必填
Bearer Token,如
Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...
获取方法:依照左侧最上面认证模块的post接口获取,https://docs.leapx-hub.com/cn/leapx-lab-v4/endpoint/get-token请求参数
请求体为 JSON,根级字段req 对应示例中的 "req" 对象。
string
必填
图片描述提示词
string
必填
图片尺寸,如:512x512, 1024x1024
string
必填
图片尺寸枚举值,与 size 一致即可,如:1024x1024
string
必填
请求标识,用于业务侧关联与去重
boolean
是否返回图片 URL
integer
图片宽度。推荐 1.3K 左右分辨率;宽高乘积小于 2048×2048 均可出图
integer
图片高度。推荐 1.3K 左右分辨率;宽高乘积小于 2048×2048 均可出图
示例代码
- cURL示例
- Python示例
curl -X POST "https://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"req": {
"prompt": "一只可爱的小猫在草地上玩耍",
"size": "1024x1024",
"value": "1024x1024",
"req_key": "req-001",
"return_url": true,
"width": 1024,
"height": 1024
}
}'
import requests
import json
url = "https://leapx-hub.com/prod-api/nebula/v4/api/text2imageSubmit"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer sk-xxxxxxxxxx"
}
data = {
"req": {
"prompt": "一只可爱的小猫在草地上玩耍",
"size": "1024x1024",
"value": "1024x1024",
"req_key": "req-001",
"return_url": True,
"width": 1024,
"height": 1024
}
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
响应示例
{
"code": 200,
"msg": "操作成功",
"data": {
"images": [{
"url": "https://example.com/image.jpg"
}]
}
}
⌘I
