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

# Grok 4.20

> xAI's 4.20 generation. 2M context, vision, file input, reasoning; the rate doubles above 200K prompt tokens.

## Overview

xAI's 4.20 generation. 2M context, vision, file input, reasoning; the rate doubles above 200K prompt tokens.

## Specs

| Field | Value |
| - | - |
| Model ID | `grok-4.20` |
| Best for | Very long documents and codebases in one prompt |
| Context window | 2M |
| Max output tokens | 8K |
| Input modalities | Text, Image, File |
| Output modalities | Text |
| Tool calling | Yes |
| Structured outputs | Yes |
| Prompt caching | No |
| Vision | Yes |
| Reasoning | Yes |
| Speed | Medium |
| Cost band | Premium |
| Release stage | Stable |

## Pricing

| | Per 1M tokens |
| - | :-: |
| Input | \$1.763 |
| Output | \$3.528 |

Above a long prompt this model costs more per token, because the infrastructure
serving it charges more there. The threshold is on the **prompt**, so you know which
rate applies before you send.

| Prompt length | Input | Output |
| - | :-: | :-: |
| Standard | \$1.763 | \$3.528 |
| Above 200,000 tokens | \$3.375 | \$6.75 |

## Example

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

client = OpenAI(base_url="https://kymaapi.com/v1", api_key="kyma-...")

response = client.chat.completions.create(
    model="grok-4.20",
    messages=[{"role": "user", "content": "..."}],
    tools=[...],  # function calling supported
)
```

## Agent query example

Ask the API which models fit, instead of hardcoding an id:

```bash theme={null}
curl "https://kymaapi.com/v1/models?recommended_for=chat&tools=true&quality_tier=strong"
```


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