# xAI (Grok)

## Endpoints

| API | URL |
|---|---|
| Chat Completions | `https://www.aixapi.io/v1/chat/completions` |
| Responses | `https://www.aixapi.io/v1/responses` |

```python
from openai import OpenAI

client = OpenAI(base_url="https://www.aixapi.io/v1", api_key="sk-...")
resp = client.chat.completions.create(
    model="grok-4.7",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
```

## Thinking

On by default. Reasoning is in `message.reasoning_content` and counts as output tokens.

## Tool calling

Supported, OpenAI `tools` format.

## Image input

Supported; `image_url` takes a URL or a base64 data URL.

## Caching

Automatic prefix caching, no parameter. Cached count: `prompt_tokens_details.cached_tokens`.
