> ## 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.7

> Use Grok 4.7 through the AnyFast Responses or OpenAI-compatible Chat Completions API.

Grok 4.7 is available through AnyFast at `POST /v1/responses` and `POST /v1/chat/completions`. Use model ID `grok-4.7`. The Responses API is the primary interface for reasoning, function calls, structured output, and image input.

<Info>The upstream xAI specification lists a 500,000-token context window, text and image input, and text output.</Info>

## When to use Grok 4.7

* Long-running coding and agentic tasks
* Multi-step knowledge work and complex analysis
* Visual understanding with text and image inputs
* Function calling or schema-constrained JSON output

## Quick example

<Tabs sync={false}>
  <Tab title="Responses API">
    <CodeGroup>
      ```bash cURL theme={null}
      curl https://www.anyfast.ai/v1/responses \
        -H "Authorization: Bearer YOUR_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "grok-4.7",
          "input": "Review this function for correctness: function median(a){a.sort();return a[a.length/2]}",
          "reasoning": {"effort": "high"},
          "max_output_tokens": 1024
        }'
      ```

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

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

      response = client.responses.create(
          model="grok-4.7",
          input="Review this function for correctness: function median(a){a.sort();return a[a.length/2]}",
          reasoning={"effort": "high"},
          max_output_tokens=1024,
      )

      print(response.output_text)
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Chat Completions">
    <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.7",
          "messages": [{"role": "user", "content": "Explain why binary search is O(log n)."}],
          "reasoning_effort": "low",
          "max_tokens": 1024
        }'
      ```

      ```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.7",
          messages=[{"role": "user", "content": "Explain why binary search is O(log n)."}],
          reasoning_effort="low",
          max_tokens=1024,
      )

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

## Image input

Send image URLs through the Responses API multimodal message format:

```json theme={null}
{
  "model": "grok-4.7",
  "input": [{
    "role": "user",
    "content": [
      {"type": "input_image", "image_url": "https://science.nasa.gov/wp-content/uploads/2023/09/web-first-images-release.png", "detail": "low"},
      {"type": "input_text", "text": "Describe this image in one short sentence."}
    ]
  }],
  "store": false
}
```

## Reasoning behavior

Set `reasoning.effort` on Responses or `reasoning_effort` on Chat Completions:

| Value | Behavior |
| - | - |
| `low` | Lower latency for simpler tasks |
| `medium` | Balanced reasoning |
| `high` | Default; deeper reasoning for difficult tasks |
| `xhigh` | Maximum reasoning depth and latency |

<Warning>Reasoning cannot be disabled. Setting `reasoning: {"effort": "none"}` returns `400`.</Warning>

## Core request fields

| Parameter | Type | Required | Description |
| - | - | - | - |
| `model` | string | Yes | Must be `grok-4.7` on both endpoints |
| `input` / `messages` | string / array | Yes | Responses uses `input`; Chat Completions uses `messages` |
| `reasoning.effort` / `reasoning_effort` | string | No | `low`, `medium`, `high`, or `xhigh`; default `high` |
| `max_output_tokens` / `max_tokens` | integer | No | Responses / Chat Completions output-token budget |
| `tools` and `tool_choice` | array / string | No | Define functions and control when to call them |
| `text.format` | object | No | Set `type: "json_schema"` for strict JSON Schema output on Responses |
| `stream` | boolean | No | Return Responses API SSE events when `true` |

## Response and streaming

For non-streaming requests, read the final answer from `output[].content[].text` on Responses or `choices[0].message.content` on Chat Completions. For Responses streaming, concatenate the text from `response.output_text.delta` events.

The reasoning-token count is available in `usage.output_tokens_details.reasoning_tokens` on Responses and `usage.completion_tokens_details.reasoning_tokens` on Chat Completions. For multi-turn Responses conversations, pass the `reasoning` item containing `encrypted_content` back unchanged.

<Card title="API Reference" icon="code" href="/api-reference/model-api/xai/grok-4-7">
  View the Grok 4.7 request and response schema.
</Card>

## Official references

* [Grok 4.7 model page](https://docs.x.ai/developers/models/grok-4.7)
* [Grok 4.7 developer guide](https://docs.x.ai/developers/grok-4-7)
* [xAI reasoning guide](https://docs.x.ai/developers/model-capabilities/text/reasoning)
* [xAI image understanding guide](https://docs.x.ai/developers/model-capabilities/images/understanding)

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


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