> ## Documentation Index
> Fetch the complete documentation index at: https://docs.socialvision.tisyk.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude 对话接口

> 支持 Claude 5.5 系列、Claude Fable 5.1 与 Claude 3.7 原生消息协议与标准 OpenAI 兼容协议

## 对话补全（OpenAI 兼容）

`POST /v1/chat/completions`

统一 OpenAI 兼容入口。通过 `model` 选择上游，例如：

* `claude-5.5-sonnet` / `claude-fable-5.1` / `claude-3-7-sonnet` → Anthropic
* `gpt-5.6` / `gpt-6-astra` → OpenAI
* `gemini-3.8-pro` / `gemini-3.8-flash` → Google Gemini
* 其他模型见 `GET /v1/models`

OpenAI 官方文档：[https://platform.openai.com/docs/api-reference/chat/create](https://platform.openai.com/docs/api-reference/chat/create)

模型名称格式为：gpt-4-gizmo-\*，系统会自动进行识别

比如这个GPTs：[https://chatgpt.com/g/g-B3hgivKK9-write-for-me](https://chatgpt.com/g/g-B3hgivKK9-write-for-me)

那么它的模型名应该填写为：gpt-4-gizmo-g-B3hgivKK9

GPTs列表：[https://chatgpt.com/gpts](https://chatgpt.com/gpts)

### 请求体参数 (Body)

<ParamField body="enable_thinking" type="boolean">
  是否开启思考模式（本仓库扩展）。仅布尔值 true 生效；与 extra\_body.enable\_thinking 二选一即可。
</ParamField>

<ParamField body="extra_body" type="object">
  对话扩展参数。常用：enable\_thinking；部分 Gemini 模型可用 google.thinking\_config 等。是否生效取决于渠道与模型。
</ParamField>

<ParamField body="frequency_penalty" type="number">
  频率惩罚，约 -2～2。正值降低重复相同词句的概率。
</ParamField>

<ParamField body="logit_bias" type="object">
  按 token ID 调整出现概率，取值为 -100～100 的映射对象。
</ParamField>

<ParamField body="max_completion_tokens" type="integer">
  补全 token 上限（o 系、GPT-5 等推理模型更常用）。未设置时可能沿用 max\_tokens。
</ParamField>

<ParamField body="max_tokens" type="integer">
  本次回复最多生成的 token 数（常用字段）。
</ParamField>

<ParamField body="messages" type="array" required>
  对话消息列表，至少一条。支持多轮：system / user / assistant / tool。
</ParamField>

<ParamField body="model" type="string" required>
  要使用的模型 ID。网关会按令牌分组选择渠道，并可能做模型名映射或后缀解析（如 -thinking、-search）。
</ParamField>

<ParamField body="n" type="integer">
  对同一轮输入生成几条 assistant 回复候选。
</ParamField>

<ParamField body="parallel_tool_calls" type="boolean">
  是否允许在一次回复中并行发起多个工具调用（上游支持时）。
</ParamField>

<ParamField body="presence_penalty" type="number">
  存在惩罚，约 -2～2。正值减少重复已出现过的主题表述。
</ParamField>

<ParamField body="reasoning_effort" type="string">
  推理模型力度（如 low / medium / high）。也可通过模型名后缀由网关自动注入。
</ParamField>

<ParamField body="response_format" type="object" />

<ParamField body="seed" type="number">
  随机种子，在相同参数下尽量得到可复现结果（不保证完全一致）。注意字段名为 seed。
</ParamField>

<ParamField body="stop" type="any">
  遇到这些字符串时停止生成。可为单个字符串或字符串数组（最多 4 个）。
</ParamField>

<ParamField body="stream" type="boolean">
  是否流式输出。false：一次返回完整 JSON；true：SSE 增量推送，结束为 data: \[DONE]。
</ParamField>

<ParamField body="stream_options" type="object" />

<ParamField body="temperature" type="number">
  采样温度，通常 0～2。值越高回复越随机，越低越稳定。与 top\_p 一般只调一个。
</ParamField>

<ParamField body="tool_choice" type="any">
  控制是否调用工具：none（不调用）、auto（自动）、required（必须调用），或指定某个函数。
</ParamField>

<ParamField body="tools" type="array">
  模型可调用的工具（函数）列表，用于对话中的 function calling。
</ParamField>

<ParamField body="top_p" type="number">
  核采样，0～1。只从累计概率达到 top\_p 的 token 中采样。
</ParamField>

<ParamField body="user" type="string">
  终端用户唯一标识，便于平台侧滥用检测与统计。
</ParamField>

<ParamField body="web_search_options" type="object" />

### 请求示例 (JSON)

```json theme={null}
{
  "extra_body": {
    "enable_thinking": true
  },
  "messages": [
    {
      "content": "有三个盒子，只有一个里面有奖品。你选 2 号，主持人打开 3 号（空），问要不要改选 1 号？分析并给建议。",
      "role": "user"
    }
  ],
  "model": "deepseek-chat",
  "stream": true,
  "stream_options": {
    "include_usage": true
  }
}
```

### 请求示例 (cURL)

```bash theme={null}
curl -X POST "https://socialvision.tisyk.xyz/v1/chat/completions" \
  -H "Authorization: Bearer sk-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "extra_body": {
    "enable_thinking": true
  },
  "messages": [
    {
      "content": "有三个盒子，只有一个里面有奖品。你选 2 号，主持人打开 3 号（空），问要不要改选 1 号？分析并给建议。",
      "role": "user"
    }
  ],
  "model": "deepseek-chat",
  "stream": true,
  "stream_options": {
    "include_usage": true
  }
}'
```

### 响应示例 (200 OK)

```json theme={null}
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": "",
      "message": {
        "annotations": [],
        "content": "\n\nHello there, how may I assist you today?",
        "refusal": "",
        "role": "assistant"
      }
    }
  ],
  "created": 1677652288,
  "id": "chatcmpl-123",
  "model": "gpt-4o",
  "object": "chat.completion",
  "service_tier": "default",
  "system_fingerprint": "fp_abc123",
  "usage": {
    "completion_tokens": 12,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "rejected_prediction_tokens": 0
    },
    "latency_checkpoint": {
      "engine_tbt_ms": 0,
      "engine_ttft_ms": 0,
      "engine_ttlt_ms": 0,
      "pre_inference_ms": 0,
      "service_tbt_ms": 0,
      "service_ttft_ms": 0,
      "service_ttlt_ms": 0,
      "total_duration_ms": 0,
      "user_visible_ttft_ms": 0
    },
    "prompt_tokens": 9,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    },
    "total_tokens": 21
  }
}
```

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.