媒体生成
生成图像
使用 Theo Create 引擎根据文本提示生成图像。
POST
/
api
/
v1
/
images
生成图像
curl --request POST \
--url https://api.example.com/api/v1/images \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"style": "<string>",
"aspect_ratio": "<string>",
"count": 123
}
'import requests
url = "https://api.example.com/api/v1/images"
payload = {
"prompt": "<string>",
"style": "<string>",
"aspect_ratio": "<string>",
"count": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({prompt: '<string>', style: '<string>', aspect_ratio: '<string>', count: 123})
};
fetch('https://api.example.com/api/v1/images', 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.example.com/api/v1/images",
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([
'prompt' => '<string>',
'style' => '<string>',
'aspect_ratio' => '<string>',
'count' => 123
]),
CURLOPT_HTTPHEADER => [
"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.example.com/api/v1/images"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"style\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"count\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/v1/images")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"style\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"count\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/images")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"style\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"count\": 123\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created": "<string>",
"images": [
{
"url": {},
"engine": "<string>",
"model": "<string>",
"prompt": "<string>"
}
],
"usage": {
"cost_cents": 123
}
}根据文本提示生成一张或多张图像。这是一个同步端点——图像会直接在响应中返回。
身份验证
需要 Bearer 令牌。参见身份验证。请求体
string
必填
要生成的图像的文本描述。
string
视觉风格提示(例如
"photorealistic"、"illustration"、"watercolor"、"3d-render")。会附加到提示词中传给图像引擎。string
宽高比(例如
"1:1"、"16:9"、"9:16"、"4:3")。默认为引擎的原生比例。integer
默认值:"1"
要生成的图像数量(1–4)。
请求示例
curl -X POST https://www.hitheo.ai/api/v1/images \
-H "Authorization: Bearer $THEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A minimalist tech logo, blue and white",
"style": "photorealistic",
"aspect_ratio": "1:1",
"count": 2
}'
const res = await theo.images({
prompt: "A minimalist tech logo, blue and white",
style: "photorealistic",
aspect_ratio: "1:1",
count: 2,
});
for (const img of res.images) {
console.log(img.url, img.engine);
}
响应
string
唯一的图像生成 ID(前缀为
img_)。string
ISO 8601 时间戳。
object[]
响应示例
{
"id": "img_abc123",
"created": "2026-04-10T12:00:00Z",
"images": [
{
"url": "https://artifacts.hitheo.ai/img/abc123-1.png",
"engine": "theo-vision",
"model": "theo-1-create",
"prompt": "A minimalist tech logo, blue and white Style: photorealistic. Aspect ratio: 1:1."
},
{
"url": "https://artifacts.hitheo.ai/img/abc123-2.png",
"engine": "theo-vision",
"model": "theo-1-create",
"prompt": "A minimalist tech logo, blue and white Style: photorealistic. Aspect ratio: 1:1."
}
],
"usage": { "cost_cents": 0.08 }
}
错误
| 状态码 | 代码 | 描述 |
|---|---|---|
| 400 | missing_prompt | 缺少必填的 prompt |
| 401 | invalid_api_key | API 密钥缺失或无效 |
| 429 | rate_limit_exceeded | 请求次数过多 |
此页面对您有帮助吗?
生成图像
curl --request POST \
--url https://api.example.com/api/v1/images \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"style": "<string>",
"aspect_ratio": "<string>",
"count": 123
}
'import requests
url = "https://api.example.com/api/v1/images"
payload = {
"prompt": "<string>",
"style": "<string>",
"aspect_ratio": "<string>",
"count": 123
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({prompt: '<string>', style: '<string>', aspect_ratio: '<string>', count: 123})
};
fetch('https://api.example.com/api/v1/images', 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.example.com/api/v1/images",
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([
'prompt' => '<string>',
'style' => '<string>',
'aspect_ratio' => '<string>',
'count' => 123
]),
CURLOPT_HTTPHEADER => [
"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.example.com/api/v1/images"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"style\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"count\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/api/v1/images")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"style\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"count\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/images")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"style\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"count\": 123\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created": "<string>",
"images": [
{
"url": {},
"engine": "<string>",
"model": "<string>",
"prompt": "<string>"
}
],
"usage": {
"cost_cents": 123
}
}