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

# Grok 4.6

> 通过 AnyFast OpenAI 兼容的 Chat Completions API 调用 Grok 4.6。

Grok 4.6 可通过 AnyFast 的 `POST /v1/chat/completions` 调用。模型 ID 为 `grok-4.6`。

<Info>xAI 上游规格给出的上下文窗口为 500,000 Token，支持文本和图片输入、文本输出。</Info>

## 适用场景

* 长时间运行的编程和智能体任务
* 多步骤知识工作与复杂分析
* 结合文本和图片输入的视觉理解

## 快速示例

<CodeGroup>
  ```bash cURL theme={null}
  curl https://www.anyfast.ai/v1/chat/completions \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "grok-4.6",
      "messages": [
        {
          "role": "user",
          "content": "检查这个函数是否正确：function median(a){a.sort();return a[a.length/2]}"
        }
      ],
      "reasoning_effort": "high",
      "stream": false
    }'
  ```

  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://www.anyfast.ai/v1",
  )

  response = client.chat.completions.create(
      model="grok-4.6",
      messages=[
          {
              "role": "user",
              "content": "检查这个函数是否正确：function median(a){a.sort();return a[a.length/2]}",
          }
      ],
      reasoning_effort="high",
  )

  print(response.choices[0].message.content)
  ```
</CodeGroup>

## 图片输入

使用 OpenAI 兼容的多模态消息格式传入图片 URL：

```json theme={null}
{
  "model": "grok-4.6",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "image_url",
          "image_url": {
            "url": "https://example.com/architecture-diagram.png",
            "detail": "high"
          }
        },
        {
          "type": "text",
          "text": "识别主要组件并说明数据流。"
        }
      ]
    }
  ],
  "reasoning_effort": "high"
}
```

## 推理行为

通过顶层 `reasoning_effort` 字段控制推理强度：

| 值        | 行为              |
| -------- | --------------- |
| `low`    | 面向较简单智能体任务，降低延迟 |
| `medium` | 在分析深度和延迟之间取得平衡  |
| `high`   | 默认值，适合困难任务      |
| `xhigh`  | 最大推理深度，同时延迟最高   |

<Warning>Grok 4.6 无法关闭推理，请勿传入 `reasoning_effort: "none"`。上游模型也不兼容 `stop`、`presence_penalty` 和 `frequency_penalty`。</Warning>

## 核心请求字段

| 参数                 | 类型      | 必填 | 说明                                        |
| ------------------ | ------- | -- | ----------------------------------------- |
| `model`            | string  | 是  | 固定为 `grok-4.6`                            |
| `messages`         | array   | 是  | 对话消息；用户内容可以是文本，也可以是包含文本和图片 URL 的数组        |
| `reasoning_effort` | string  | 否  | `low`、`medium`、`high` 或 `xhigh`，默认 `high` |
| `max_tokens`       | integer | 否  | 最大生成 Token 数                              |
| `stream`           | boolean | 否  | 设为 `true` 时返回 SSE 增量，默认 `false`           |

## 响应与流式输出

非流式请求的最终答案位于 `choices[0].message.content`。流式请求需要依次拼接 SSE 返回的文本增量。

`usage.completion_tokens_details.reasoning_tokens` 会返回推理 Token 数量。这部分 Token 会计入 `usage.total_tokens`，最终回答仍位于 `choices[0].message.content`。

<Note>本页仅说明 AnyFast Chat Completions 核心接口。xAI 原生 Responses API 的服务端网页搜索、X 搜索、代码执行、会话存储和加密推理等能力，不代表可通过此端点使用。</Note>

<Card title="API 参考" icon="code" href="/zh/api-reference/model-api/xai/grok-4-6">
  查看 Grok 4.6 的请求与响应结构。
</Card>

上游模型规格请参考 [Grok 4.6 官方模型页面](https://docs.x.ai/developers/models/grok-4.6)。

<script src="/public/feedback.js" />
