grok_chat_completions
Send messages to Grok models to generate chat completions with reasoning, vision, and function calling capabilities. Returns the response in OpenAI-compatible format.
Instructions
Create a Grok (xAI) chat completion via the AceDataCloud Grok API.
Sends messages to a Grok chat model and returns the generated response in the
OpenAI-compatible chat completion format.
Use this when:
- You want to chat/reason with a Grok model (grok-4 / grok-3 family)
- You need vision/image understanding (use grok-2-vision)
- You need tool/function calling with Grok
For generating videos, use grok_text_to_video / grok_image_to_video instead.
Returns:
JSON response containing the chat completion result.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| seed | No | Random seed for (best-effort) deterministic sampling. | |
| stop | No | Stop sequences where the API will stop generating tokens. | |
| user | No | End-user identifier for abuse monitoring. | |
| model | No | The Grok chat model. grok-4 (default, flagship) and grok-3 are the broadly available models. Also: grok-4-1-fast, grok-4-1-fast-non-reasoning, grok-3-mini, grok-2-vision (image input) — availability depends on upstream provisioning. | grok-4 |
| tools | No | List of tools (functions) the model may call. | |
| top_p | No | Nucleus sampling probability mass. Default 1. | |
| stream | No | Whether to stream partial message deltas. Default False. | |
| messages | Yes | Conversation messages. Each message is a dict with 'role' ('system'/'user'/'assistant'/'tool') and 'content' keys. For vision with grok-2-vision, content may be a list of text/image_url parts. Required. | |
| max_tokens | No | Maximum number of tokens to generate. | |
| temperature | No | Sampling temperature between 0 and 2. Higher = more random. | |
| tool_choice | No | Controls tool calling. 'none', 'auto', 'required', or a dict. | |
| response_format | No | Response format specification (e.g. {"type": "json_object"}). | |
| presence_penalty | No | Presence penalty between -2.0 and 2.0. Positive increases topic variety. | |
| reasoning_effort | No | Reasoning effort: 'low' or 'high'. Only applies to reasoning-capable models (e.g. grok-3-mini). Ignored by non-reasoning models. | |
| frequency_penalty | No | Frequency penalty between -2.0 and 2.0. Positive decreases repetition. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |