grok_agent
Answers prompts by combining web and X search, code execution, file and image analysis, and image generation. Enable only the tools each task needs and attach files, images, or URLs.
Instructions
All-in-one Grok agent combining files, vision, web/X search, code execution, and image generation.
Enable any subset of tools and attach any mix of uploaded files and images.
The agent decides which tools to use per turn. Supports optional local
session history and multi-agent research via `agent_count`.
Args:
prompt: Task or question for the agent.
session: Optional session name for persistent history in `chats/{session}.json`.
model: Grok model driving the agent (default `grok-4.6`).
file_ids: IDs of previously uploaded files to attach as context.
image_urls: Public image URLs to attach.
image_paths: Local image files to attach (sent as base64 data URIs).
use_web_search: Enable the agentic web search tool.
use_x_search: Enable the agentic X (Twitter) search tool.
use_code_execution: Enable the Python code execution tool.
use_image_generation: Enable the server-side image generation tool, letting the agent
create and edit images mid-conversation. Images are saved under `images/`.
image_generation_action: Which image capabilities to expose: `"auto"` (default, generate
and edit), `"generate"` (text-to-image only), or `"edit"` (editing only).
allowed_domains: Web search allow-list (max 5, mutually exclusive with excluded).
excluded_domains: Web search deny-list (max 5).
allowed_x_handles: X search handle allow-list (max 10, mutually exclusive with excluded).
excluded_x_handles: X search handle deny-list (max 10).
from_date: X search inclusive start date as `DD-MM-YYYY`.
to_date: X search inclusive end date as `DD-MM-YYYY`.
enable_image_understanding: Let search tools analyze images they encounter.
enable_video_understanding: Let X search analyze videos in posts.
enable_image_search: Let web search find and return image results.
include_inline_citations: Embed `[1]`-style citation markers into the answer.
system_prompt: Optional system instruction prepended to the conversation.
max_turns: Cap the agent's reasoning/tool turns.
agent_count: 4 or 16. Only valid with `grok-4.20-multi-agent`.
service_tier: `"default"` or `"priority"`. Priority is processed faster at a higher token price.
show_usage: Append a token usage and cost footer to the answer (default False).
Returns:
Markdown with the answer body, then a `**Generated Images:**` list of saved file paths
when the agent produced images, then a `**Sources:**` list when citations exist.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | grok-4.6 | |
| prompt | Yes | ||
| session | No | ||
| to_date | No | ||
| file_ids | No | ||
| from_date | No | ||
| max_turns | No | ||
| image_urls | No | ||
| show_usage | No | ||
| agent_count | No | ||
| image_paths | No | ||
| service_tier | No | ||
| use_x_search | No | ||
| system_prompt | No | ||
| use_web_search | No | ||
| allowed_domains | No | ||
| excluded_domains | No | ||
| allowed_x_handles | No | ||
| excluded_x_handles | No | ||
| use_code_execution | No | ||
| enable_image_search | No | ||
| use_image_generation | No | ||
| image_generation_action | No | ||
| include_inline_citations | No | ||
| enable_image_understanding | No | ||
| enable_video_understanding | No |