外观
语言模型 API
OpenAI Chat Completions 兼容接口。
POST https://api.ashpetals.com/v1/chat/completions请求参数
| 参数 | 类型 | 说明 |
|---|---|---|
model | string | 必填,模型 ID(/v1/models 可查) |
messages | array | 必填,对话消息列表 |
stream | boolean | 是否流式返回(SSE),默认 false |
max_tokens | int | 最大输出 token 数 |
temperature | number | 采样温度,默认 1 |
top_p | number | 核采样 |
tools | array | 工具调用定义(Function Calling) |
tool_choice | string/object | 工具选择策略 |
基础请求
bash
curl https://api.ashpetals.com/v1/chat/completions \
-H "Authorization: Bearer sk-你的APIKey" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-sol",
"messages": [
{ "role": "system", "content": "你是一个乐于助人的助手。" },
{ "role": "user", "content": "用一句话介绍你自己。" }
],
"max_tokens": 200
}'流式请求(SSE)
bash
curl https://api.ashpetals.com/v1/chat/completions \
-H "Authorization: Bearer sk-你的APIKey" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{ "role": "user", "content": "讲个笑话" }],
"stream": true
}'响应为 data: 开头的 SSE 分块,以 data: [DONE] 结束。
视觉理解
支持视觉的模型可在消息中携带图片(图片 URL 或 Base64):
json
{
"model": "gpt-5.6-sol",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "这张图里有什么?" },
{ "type": "image_url", "image_url": { "url": "https://example.com/cat.png" } }
]
}
]
}工具调用
json
{
"model": "gpt-5.6-sol",
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "查询城市天气",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}
}
],
"tool_choice": "auto"
}注意事项
- 推理模型(如带 reasoning 的模型)的思考内容会占用
max_tokens预算,请设置足够大的max_tokens。 - 上下文长度与并发限制以模型与分组策略为准;超长上下文可尝试精简历史消息。
- 使用 Anthropic 协议的 Claude 模型请见 Claude Code 配置 或直接调用
/v1/messages。