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

# Grok 模型

> 通过 OpenAI Chat Completions 格式调用 Grok 文本模型

> 更新日期：2026-06-06

# Grok 模型

```
POST /v1/chat/completions
```

Grok 文本模型使用 OpenAI Chat Completions 兼容格式调用。你只需要把 `base_url` 指向 Crazyrouter，并在 `model` 中填写 Grok 模型 ID。

<Note>
  模型可用性会随渠道、令牌权限和 pricing 页面配置变化。正式上线前建议先用 `GET /v1/models` 确认当前 API Key 是否能看到目标模型。
</Note>

## 常用模型

以下是当前常见的 Grok 文本模型写法：

| 模型                          | 说明                |
| --------------------------- | ----------------- |
| `grok-4`                    | Grok 4 主模型        |
| `grok-4-fast`               | Grok 4 fast 变体    |
| `grok-4-fast-non-reasoning` | Grok 4 fast 非推理变体 |
| `grok-4-fast-reasoning`     | Grok 4 fast 推理变体  |
| `grok-4.1`                  | Grok 4.1          |
| `grok-4.1-fast`             | Grok 4.1 fast     |
| `grok-4.1-fast`             | Grok 4.1 thinking |
| `grok-4.1-fast`             | Grok 4.2          |
| `grok-4-0709`               | Grok 4 日期版本       |

<Warning>
  旧的 `grok-4` / `grok-4.1` 系列可能仍被历史调用或兼容配置引用，但当前公开 pricing 主要保留 `grok-4*` 系列。新接入优先选择 `grok-4`、`grok-4.1`、`grok-4.1-fast` 或 fast/reasoning 变体。
</Warning>

## 最小请求

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.crazyrouter.com/v1/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -d '{
      "model": "grok-4",
      "messages": [
        {
          "role": "user",
          "content": "Reply with one short sentence: what is Grok?"
        }
      ],
      "temperature": 0.7,
      "max_tokens": 120
    }'
  ```

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

  client = OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://api.crazyrouter.com/v1",
  )

  response = client.chat.completions.create(
      model="grok-4",
      messages=[
          {"role": "user", "content": "Reply with one short sentence: what is Grok?"}
      ],
      temperature=0.7,
      max_tokens=120,
  )

  print(response.choices[0].message.content)
  ```

  ```javascript Node.js theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: "YOUR_API_KEY",
    baseURL: "https://api.crazyrouter.com/v1",
  });

  const response = await client.chat.completions.create({
    model: "grok-4",
    messages: [
      { role: "user", content: "Reply with one short sentence: what is Grok?" },
    ],
    temperature: 0.7,
    max_tokens: 120,
  });

  console.log(response.choices[0].message.content);
  ```
</CodeGroup>

## 流式输出

设置 `stream: true` 即可使用 SSE 流式输出。

```bash theme={null}
curl https://api.crazyrouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "grok-4-fast",
    "stream": true,
    "messages": [
      {
        "role": "user",
        "content": "Write a concise API migration checklist."
      }
    ]
  }'
```

## 推理变体

对于名称中包含 `reasoning` 或 `thinking` 的 Grok 模型，建议保持请求参数简单：

```json theme={null}
{
  "model": "grok-4-fast-reasoning",
  "messages": [
    {
      "role": "user",
      "content": "Compare two implementation options and explain the tradeoffs."
    }
  ],
  "max_tokens": 800
}
```

<Note>
  不同上游渠道对推理字段、搜索字段或实验参数的支持可能不同。跨渠道稳定接入时，优先使用标准 OpenAI Chat 字段：`model`、`messages`、`temperature`、`top_p`、`max_tokens`、`stream`。
</Note>

## 相关图片模型

Grok 图片生成不走 Chat Completions。请使用：

```text theme={null}
POST /v1/images/generations
```

图片模型参数请看 [Grok 图片模型](/images/grok)。

相关页面：

* [模型官方定价方式](/reference/official-pricing-methods)
