API Reference
Terra chat completion API
Terra chat completion for text and image prompts. Returns choices and usage in the same response.
Overview
- 纯文本对话
- 图片 URL 多模态
- 同步返回
- 按次计费
Use cases
- 爆款标题创作
- 口播文案改写
- 图文理解问答
- Agent 同步推理
- Gateway ·
https://xiaoapis.com - Auth · send
key(query or JSON body, as this API specifies) - Response · JSON. Check the business code and the HTTP status, not only HTTP 200
Authentication
Send the platform API key (query parameter key or JSON field key, as this page specifies). Create one in API key management.
REQUEST https://xiaoapis.com/api/chat/terra
Content-Type: application/json
{
"key": "YOUR_API_KEY"
}
Request example
https://xiaoapis.com/api/chat/terra?key=你的密钥
Details
接口说明:
Terra 对话补全接口。支持纯文字对话,也支持在 messages 中传入图片 URL 进行多模态提问。
返回统一结构 {code,msg,data},对话结果在 data 内(含 choices / usage 等字段)。
请求方法:推荐 POST + application/json。
计费:每次成功调用扣除 5 点(可在后台调整 consume);失败不扣费。
请求HEADER:
| 名称 | 值 |
|---|---|
| Content-Type | application/json |
鉴权说明:
key 可放在 URL 查询参数、JSON Body,或 Authorization: Bearer <key>。
请求参数说明:
| 名称 | 必填 | 类型 | 示例值 | 说明 |
|---|---|---|---|---|
| key | 是 | string | 你的密钥 | 平台 API Key;也可放在 URL 或 Authorization Bearer |
| model | 否 | string | terra | 模型名称,本接口固定为 terra |
| stream | 否 | boolean | false | 是否流式;当前仅支持 false |
| messages | 是 | array | 见下方示例 | 对话消息列表,至少一条 |
| messages[].role | 是 | string | user | system / user / assistant / tool |
| messages[].content | 是 | string / array | 你好 | 纯文本 string,或多模态 content 数组(text + image_url) |
| temperature | 否 | number | 0.7 | 可选扩展参数 |
| max_tokens | 否 | integer | 2048 | 可选扩展参数 |
文字提问示例:
{"key":"你的密钥","model":"terra","stream":false,"messages":[{"role":"user","content":"你好"}]}图片提问示例:
{"key":"你的密钥","model":"terra","stream":false,"messages":[{"role":"user","content":[{"type":"text","text":"这张图片内容是什么"},{"type":"image_url","image_url":{"url":"https://你的域名/demo.png"}}]}]}返回参数说明:
| 名称 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,200 表示成功 |
| msg | string | 状态信息 |
| data | object | 补全结果 |
| data.id | string | 补全 ID |
| data.model | string | 实际模型,固定 terra |
| data.choices | array | 候选回复列表 |
| data.choices[].message.role | string | 通常为 assistant |
| data.choices[].message.content | string | 模型回复正文 |
| data.choices[].finish_reason | string | 结束原因,如 stop |
| data.usage | object | token 用量(prompt / completion / total) |
| data.power_cost | number | 本次扣除点数 |
Response example
{"code":200,"msg":"success","data":{"id":"1-2ede12b5-77cc-48f9-b1d0-7ae35ee8d444","object":"","created":1777897048,"model":"terra","choices":[{"index":0,"message":{"role":"assistant","content":"你好!请问有什么我可以帮您的吗?"},"finish_reason":"stop"}],"usage":{"prompt_tokens":2,"completion_tokens":20,"total_tokens":22},"power_cost":5}}
Error codes
| HTTP / 业务码 | 说明 |
|---|---|
| 200 | 调用成功 |
| 400 | 参数错误、请求被拒绝或 stream 不支持 |
| 401 / 403 | 认证失败,请检查 key |
| 500 | 服务端异常 |
FAQ
什么是 Terra API?
Terra 是销豹开放的对话补全接口,支持 messages 文本与 image_url 多模态提问,同步返回助手回复与用量。
Terra 怎么调用?
POST /api/chat/terra,JSON 提交 key 与 messages 数组;当前仅支持 stream=false。
可以传图片吗?
可以。user content 使用数组,包含 type=text 与 type=image_url。
和 IP 视频封面有什么关系?
IP 视频封面内部会用同类能力提炼标题;若只需标题/文案而不出图,可直接调 Terra。
如何计费?
按次扣点(默认以接口文档与控制台为准),失败不扣费。
Related APIs
Full console doc (with the debugger):/doc/54