| name | xai_image_generate |
| description | Use when the user asks to generate, create, make, or save images with xAI, Grok Imagine, xai_image_generate, or codex-xai-oauth image artifacts. |
xAI Image Generate
Use xai_image_generate for xAI/Grok Imagine image requests.
Preferred MCP Call
{
"prompt": "tiny minimalist blue dot icon on white background",
"resolution": "2k",
"artifact_dir": ".codex-xai-artifacts"
}
CLI Equivalent
codex-xai-oauth image \
--prompt "tiny minimalist blue dot icon on white background" \
--resolution 2k \
--artifact-dir .codex-xai-artifacts
For base64 image payloads saved locally:
codex-xai-oauth image \
--prompt "a cinematic robot reading a book" \
--response-format b64_json \
--artifact-dir .codex-xai-artifacts
Options
prompt: required image prompt.
model: defaults to grok-imagine-image.
n: number of images.
resolution: 1k or 2k.
response_format: url or b64_json.
size: provider-specific size string.
artifact_dir: local directory for saved image artifacts.
When artifact_dir is present, return the upstream JSON plus artifacts. Saved artifacts include path, mime_type, source, and status. If a remote URL cannot be downloaded, preserve its upstream url with status: remote.
Credential Safety
Use existing credentials. If credentials are missing, ask the user to run:
codex-xai-oauth login --device
or set XAI_API_KEY. Never print or expose OAuth tokens or API keys.