文档说明
接口支持
本API支持官方原生的接入方式
- OpenAI GPT原生格式
- Google Gemini原生格式
- Anthropic Claude原生格式
列出模型
获取所有可用的模型列表。
GET
/v1/models
请求示例
cURL
curl https://api.tuoyuntech.com/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
Python
import requests
url = "https://api.tuoyuntech.com/v1/models"
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/models', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data);
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/models"))
.header("Authorization", "Bearer YOUR_API_KEY")
.GET()
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/models"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
响应示例
JSON
{
"object": "list",
"data": [
{
"id": "gpt-4o",
"object": "model",
"created": 1709600000,
"owned_by": "openai"
}
]
}
ChatCompletions
使用 OpenAI ChatCompletions 格式进行聊天对话。
POST
/v1/chat/completions
请求体参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
model |
string | 是 | 模型ID,如 gpt-4o |
messages |
array | 是 | 消息数组 |
temperature |
number | 否 | 采样温度,0-2之间 |
max_tokens |
integer | 否 | 最大生成token数 |
请求示例
cURL
curl https://api.tuoyuntech.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "你好"}
]
}'
Python
import requests
import json
url = "https://api.tuoyuntech.com/v1/chat/completions"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "你好"}
]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-4o',
messages: [{role: 'user', content: '你好'}]
})
});
const data = await response.json();
console.log(data);
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String jsonBody = """
{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "你好"}]
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/chat/completions"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/chat/completions"
jsonBody := []byte(`{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "你好"}]
}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
响应示例
JSON
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1709600000,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好!有什么可以帮助你的吗?"
},
"finish_reason": "stop"
}
]
}
原生Gemini格式 - 文本聊天
使用 Google Gemini 原生格式进行聊天对话。
POST
/v1beta/models/{model}:generateContent
请求示例
cURL
curl https://api.tuoyuntech.com/v1beta/models/gemini-pro:generateContent \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"parts": [{"text": "你好"}]
}
]
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1beta/models/gemini-pro:generateContent"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"contents": [{"parts": [{"text": "你好"}]}]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1beta/models/gemini-pro:generateContent', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
contents: [{parts: [{text: '你好'}]}]
})
});
console.log(await response.json());
原生Gemini格式 - 多模态聊天
使用 Google Gemini 原生格式进行多模态对话。
POST
/v1beta/models/{model}:generateContent
请求示例
cURL
curl https://api.tuoyuntech.com/v1beta/models/gemini-pro-vision:generateContent \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"parts": [
{"text": "描述这张图片"},
{"inline_data": {"mime_type": "image/jpeg", "data": "BASE64_IMAGE_DATA"}}
]
}
]
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1beta/models/gemini-pro-vision:generateContent"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"contents": [{
"parts": [
{"text": "描述这张图片"},
{"inline_data": {"mime_type": "image/jpeg", "data": "BASE64_IMAGE_DATA"}}
]
}]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1beta/models/gemini-pro-vision:generateContent', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
contents: [{
parts: [
{text: '描述这张图片'},
{inline_data: {mime_type: 'image/jpeg', data: 'BASE64_IMAGE_DATA'}}
]
}]
})
});
console.log(await response.json());
Responses
使用 OpenAI Responses 格式进行对话。
POST
/v1/responses
请求示例
cURL
curl https://api.tuoyuntech.com/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"input": "你好"
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1/responses"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "gpt-4o",
"input": "你好"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/responses', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-4o',
input: '你好'
})
});
console.log(await response.json());
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String jsonBody = """
{
"model": "gpt-4o",
"input": "你好"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/responses"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/responses"
jsonBody := []byte(`{
"model": "gpt-4o",
"input": "你好"
}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
原生Claude格式
使用 Anthropic Claude 原生格式进行聊天对话。
POST
/v1/messages
请求示例
cURL
curl https://api.tuoyuntech.com/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-sonnet",
"messages": [{"role": "user", "content": "你好"}],
"max_tokens": 1024
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1/messages"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "claude-3-5-sonnet",
"messages": [{"role": "user", "content": "你好"}],
"max_tokens": 1024
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/messages', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'claude-3-5-sonnet',
messages: [{role: 'user', content: '你好'}],
max_tokens: 1024
})
});
console.log(await response.json());
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String jsonBody = """
{
"model": "claude-3-5-sonnet",
"messages": [{"role": "user", "content": "你好"}],
"max_tokens": 1024
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/messages"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/messages"
jsonBody := []byte(`{
"model": "claude-3-5-sonnet",
"messages": [{"role": "user", "content": "你好"}],
"max_tokens": 1024
}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
原生OpenAI格式 - 图像生成
使用 OpenAI 原生格式生成图像。
POST
/v1/images/generations
请求示例
cURL
curl https://api.tuoyuntech.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "dall-e-3",
"prompt": "一只可爱的猫咪",
"n": 1,
"size": "1024x1024"
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1/images/generations"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "dall-e-3",
"prompt": "一只可爱的猫咪",
"n": 1,
"size": "1024x1024"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'dall-e-3',
prompt: '一只可爱的猫咪',
n: 1,
size: '1024x1024'
})
});
console.log(await response.json());
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String jsonBody = """
{
"model": "dall-e-3",
"prompt": "一只可爱的猫咪",
"n": 1,
"size": "1024x1024"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/images/generations"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/images/generations"
jsonBody := []byte(`{
"model": "dall-e-3",
"prompt": "一只可爱的猫咪",
"n": 1,
"size": "1024x1024"
}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
通义千问格式
使用通义千问格式生成图像。
POST
/v1/images/generations
请求示例
cURL
curl https://api.tuoyuntech.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-vl-max",
"prompt": "山水画"
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1/images/generations"
headers = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
data = {"model": "qwen-vl-max", "prompt": "山水画"}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/images/generations', {
method: 'POST',
headers: {'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'qwen-vl-max', prompt: '山水画'})
});
console.log(await response.json());
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String jsonBody = "{\"model\": \"qwen-vl-max\", \"prompt\": \"山水画\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/images/generations"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/images/generations"
jsonBody := []byte(`{"model": "qwen-vl-max", "prompt": "山水画"}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Nano Banana
使用 Nano Banana 格式生成图像。
POST
/v1/images/generations
请求示例
cURL
curl https://api.tuoyuntech.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana",
"prompt": "抽象艺术"
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1/images/generations"
headers = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
data = {"model": "nano-banana", "prompt": "抽象艺术"}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/images/generations', {
method: 'POST',
headers: {'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'nano-banana', prompt: '抽象艺术'})
});
console.log(await response.json());
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String jsonBody = "{\"model\": \"nano-banana\", \"prompt\": \"抽象艺术\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/images/generations"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/images/generations"
jsonBody := []byte(`{"model": "nano-banana", "prompt": "抽象艺术"}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Sora格式
使用 OpenAI Sora 格式生成视频。
POST
/v1/videos/generations
请求示例
cURL
curl https://api.tuoyuntech.com/v1/videos/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "sora",
"prompt": "一只金毛犬在海滩上奔跑"
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1/videos/generations"
headers = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
data = {"model": "sora", "prompt": "一只金毛犬在海滩上奔跑"}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/videos/generations', {
method: 'POST',
headers: {'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'sora', prompt: '一只金毛犬在海滩上奔跑'})
});
console.log(await response.json());
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String jsonBody = "{\"model\": \"sora\", \"prompt\": \"一只金毛犬在海滩上奔跑\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/videos/generations"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/videos/generations"
jsonBody := []byte(`{"model": "sora", "prompt": "一只金毛犬在海滩上奔跑"}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
可灵格式
使用可灵格式生成视频。
POST
/v1/videos/generations
请求示例
cURL
curl https://api.tuoyuntech.com/v1/videos/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling",
"prompt": "中国山水画风格的风景"
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1/videos/generations"
headers = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
data = {"model": "kling", "prompt": "中国山水画风格的风景"}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/videos/generations', {
method: 'POST',
headers: {'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'kling', prompt: '中国山水画风格的风景'})
});
console.log(await response.json());
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String jsonBody = "{\"model\": \"kling\", \"prompt\": \"中国山水画风格的风景\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/videos/generations"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/videos/generations"
jsonBody := []byte(`{"model": "kling", "prompt": "中国山水画风格的风景"}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
即梦格式
使用即梦格式生成视频。
POST
/v1/videos/generations
请求示例
cURL
curl https://api.tuoyuntech.com/v1/videos/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "jimeng",
"prompt": "梦幻般的星空"
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1/videos/generations"
headers = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
data = {"model": "jimeng", "prompt": "梦幻般的星空"}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/videos/generations', {
method: 'POST',
headers: {'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'jimeng', prompt: '梦幻般的星空'})
});
console.log(await response.json());
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String jsonBody = "{\"model\": \"jimeng\", \"prompt\": \"梦幻般的星空\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/videos/generations"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/videos/generations"
jsonBody := []byte(`{"model": "jimeng", "prompt": "梦幻般的星空"}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
创建视频生成任务
创建一个新的视频生成任务。
POST
/v1/videos/generations
响应示例
JSON
{
"id": "video-abc123",
"object": "video.generation",
"model": "kling",
"status": "processing",
"task_id": "task_xyz789"
}
获取视频生成任务状态
查询视频生成任务的当前状态。
GET
/v1/videos/{task_id}
请求示例
cURL
curl https://api.tuoyuntech.com/v1/videos/task_xyz789 \
-H "Authorization: Bearer YOUR_API_KEY"
Python
import requests
url = "https://api.tuoyuntech.com/v1/videos/task_xyz789"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
response = requests.get(url, headers=headers)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/videos/task_xyz789', {
headers: {'Authorization': 'Bearer YOUR_API_KEY'}
});
console.log(await response.json());
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/videos/task_xyz789"))
.header("Authorization", "Bearer YOUR_API_KEY")
.GET()
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/videos/task_xyz789"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
响应示例
JSON
{
"id": "video-abc123",
"status": "completed",
"output": {
"video_url": "https://cdn.example.com/video/xxx.mp4"
}
}
原生OpenAI格式 - 嵌入
使用 OpenAI 原生格式获取文本嵌入向量。
POST
/v1/embeddings
请求示例
cURL
curl https://api.tuoyuntech.com/v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": "Hello world"
}'
Python
import requests
url = "https://api.tuoyuntech.com/v1/embeddings"
headers = {"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
data = {"model": "text-embedding-3-small", "input": "Hello world"}
response = requests.post(url, headers=headers, json=data)
print(response.json())
JavaScript
const response = await fetch('https://api.tuoyuntech.com/v1/embeddings', {
method: 'POST',
headers: {'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'text-embedding-3-small', input: 'Hello world'})
});
console.log(await response.json());
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String jsonBody = "{\"model\": \"text-embedding-3-small\", \"input\": \"Hello world\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.tuoyuntech.com/v1/embeddings"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Go
package main
import (
"bytes"
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tuoyuntech.com/v1/embeddings"
jsonBody := []byte(`{"model": "text-embedding-3-small", "input": "Hello world"}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
响应示例
JSON
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [0.0023, -0.0098, 0.0156, ...],
"index": 0
}
],
"model": "text-embedding-3-small"
}