https://hunyuan.tencentcloudapi.com hy4 控制台支持设置超额自动断流,建议开启避免产生后付费账单
curl https://hunyuan.tencentcloudapi.com/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "hy4",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}' from openai import OpenAI
client = OpenAI(
base_url="https://hunyuan.tencentcloudapi.com",
api_key="YOUR_API_KEY"
)
response = client.chat.completions.create(
model="hy4",
messages=[{"role": "user", "content": "Hello!"}],
stream=True
)
for chunk in response:
content = chunk.choices[0].delta.content or ""
print(content, end="", flush=True) import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://hunyuan.tencentcloudapi.com",
apiKey: "YOUR_API_KEY"
});
const stream = await client.chat.completions.create({
model: "hy4",
messages: [{ role: "user", content: "Hello!" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
} {
"apiProvider": "openai",
"openAiBaseUrl": "https://hunyuan.tencentcloudapi.com",
"openAiApiKey": "YOUR_API_KEY",
"openAiModelId": "hy4"
}