# Grok Grok 2 Image — Text To Image > Access grok 4 image through our unified API. Leverage advanced visual reasoning, real-time X search, and high-fidelity OCR for your enterprise AI applications. ## Overview - **Endpoint**: `POST https://gptproto.com/v1/images/generations` - **Model ID**: `grok-2-image` - **Vendor**: Grok - **Scene**: `text-to-image` - **Category**: text-to-image - **Modalities**: input text → output image - **Model page**: https://gptproto.com/model/grok/grok-2-image - **API documentation**: https://docs.gptproto.com/docs/allapi/Grok/grok-2-image/openai-format/text-to-image ## Authentication Every request needs a GPTProto API key. Create one at https://gptproto.com/dashboard/api-key, then export it: ```bash export GPTPROTO_API_KEY="your-api-key" ``` Header: `Authorization: Bearer $GPTPROTO_API_KEY`. ## Pricing Platform price by tier (USD, already includes the GPTProto discount): - **Per run** — $0.042 per run Price range: $0.042 – $0.042 per generation. Prices may change. The model page always shows the live price: https://gptproto.com/model/grok/grok-2-image ## API Information The examples below use this model's official request format from the model page. Copy them as-is and replace the API key placeholder. ### Input Schema The accepted JSON body is the official request shape below: **Full Example**: ```json { "model": "grok-2-image", "prompt": "a cat.", "n": 1 } ``` ## Usage Examples ### 1. Submit a request ```bash curl --request POST "https://gptproto.com/v1/images/generations" \ --header "Authorization: Bearer $GPTPROTO_API_KEY" \ --header "Content-Type: application/json" \ --data '{ "model": "grok-2-image", "prompt": "a cat.", "n": 1 }' ``` ```python import os import requests url = "https://gptproto.com/v1/images/generations" headers = { "Authorization": f"Bearer {os.environ['GPTPROTO_API_KEY']}", "Content-Type": "application/json" } payload = { "model": "grok-2-image", "prompt": "a cat.", "n": 1 } response = requests.request("POST", url, headers=headers, json=payload) print(response.json()) ``` ```typescript const response = await fetch("https://gptproto.com/v1/images/generations", { method: "POST", headers: { "Authorization": `Bearer ${process.env.GPTPROTO_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "grok-2-image", prompt: "a cat.", n: 1, }), }); const data = await response.json(); console.log(data); ``` ## Example Prompts - Dramatic panoramic view of Shanghai Bund 200 years after apocalypse, iconic skyline completely overtaken by massive glowing mushrooms and vines, Oriental Pearl Tower wrapped in bioluminescent flora, aurora borealis in the sky, abandoned ships floating in the Huangpu River covered… - Cinematic aerial view of a post-apocalyptic Tokyo at sunrise, overgrown with massive glowing cherry blossom trees that emit pink particles, abandoned Shibuya crossing completely covered in petals, giant broken holographic billboards still flickering, golden rays piercing through… - Cinematic aerial shot of a colossal biomechanical city-ship drifting through a nebula at golden hour, intricate organic-metallic architecture covered in bioluminescent veins, massive translucent wings made of light, thousands of tiny ships swarming like fireflies, warm rim lighti… ## HTTP Status Codes - `400` — malformed body, a parameter or value this model does not accept, or input blocked by the provider's content moderation - `401` — missing or invalid API key - `403` — insufficient credits - `413` — request body too large - `429` — rate limited; retry with backoff - `500` — An internal server error occurred - `502` — An internal server error occurred - `504` — Gateway timeout — upstream service did not respond in time; retry later ## Additional Resources - [Model page](https://gptproto.com/model/grok/grok-2-image) - [API documentation](https://docs.gptproto.com/docs/allapi/Grok/grok-2-image/openai-format/text-to-image) - [All models](https://gptproto.com/model) - [API keys](https://gptproto.com/dashboard/api-key) - [Platform overview for LLMs](https://gptproto.com/llm-full.txt) - Any other model: `https://gptproto.com/model/{vendor}/{model}/{scene}/llms.txt`