媒体生成
生成文档
根据自然语言生成 PDF、DOCX、PPTX、XLSX 或 CSV 文档。
POST
/
api
/
v1
/
documents
生成文档
curl --request POST \
--url https://api.example.com/api/v1/documents \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"format": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/documents"
payload = {
"prompt": "<string>",
"format": "<string>"
}
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>', format: '<string>'})
};
fetch('https://api.example.com/api/v1/documents', 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/documents",
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>',
'format' => '<string>'
]),
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/documents"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"format\": \"<string>\"\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/documents")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"format\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/documents")
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 \"format\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created": "<string>",
"format": "<string>",
"title": "<string>",
"download_url": {},
"size_bytes": {},
"content": "<string>",
"usage": {
"cost_cents": 123
}
}根据自然语言提示生成结构化文档。支持 PDF、DOCX、PPTX、XLSX 和 CSV 格式。
身份验证
需要 Bearer 令牌。参见身份验证。请求正文
string
必填
要生成的文档的描述。
string
默认值:"pdf"
输出格式。可选值:
pdf、docx、pptx、xlsx、csv。请求示例
curl -X POST https://www.hitheo.ai/api/v1/documents \
-H "Authorization: Bearer $THEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Create a Q1 2026 sales report with executive summary and charts",
"format": "pdf"
}'
const res = await theo.documents({
prompt: "Create a Q1 2026 sales report with executive summary and charts",
format: "pdf",
});
console.log(res.title); // "Q1 2026 Sales Report"
console.log(res.download_url); // Presigned download URL
console.log(res.content); // Document text content
响应
string
唯一文档 ID(以
doc_ 为前缀)。string
ISO 8601 时间戳。
string
输出格式(例如
"pdf")。string
自动生成的文档标题。
string | null
用于下载文档文件的预签名 URL。若文件仍在生成中,则可能为
null。integer | null
文件大小(字节)。
string
生成文档的文本内容。
响应示例
{
"id": "doc_abc123",
"created": "2026-04-10T12:00:00Z",
"format": "pdf",
"title": "Q1 2026 Sales Report",
"download_url": "https://artifacts.hitheo.ai/docs/abc123.pdf?token=...",
"size_bytes": 245760,
"content": "# Q1 2026 Sales Report\n\n## Executive Summary\n...",
"usage": { "cost_cents": 0.12 }
}
错误
| 状态码 | 代码 | 描述 |
|---|---|---|
| 400 | missing_prompt | 缺少必需的 prompt 参数 |
| 400 | invalid_format | 不支持的格式。支持的格式:pdf、docx、pptx、xlsx、csv |
| 401 | invalid_api_key | 缺少 API 密钥或密钥无效 |
| 429 | rate_limit_exceeded | 请求次数过多 |
此页面对您有帮助吗?
生成文档
curl --request POST \
--url https://api.example.com/api/v1/documents \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"format": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/documents"
payload = {
"prompt": "<string>",
"format": "<string>"
}
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>', format: '<string>'})
};
fetch('https://api.example.com/api/v1/documents', 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/documents",
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>',
'format' => '<string>'
]),
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/documents"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"format\": \"<string>\"\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/documents")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"format\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/documents")
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 \"format\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"created": "<string>",
"format": "<string>",
"title": "<string>",
"download_url": {},
"size_bytes": {},
"content": "<string>",
"usage": {
"cost_cents": 123
}
}