xai/grok-imagine-image-2.0
The second-generation Grok Imagine image model and xAI's recommended image model. Served through the OpenAI-compatible /v1/images/generations and /v1/images/edits endpoints: set the frame with aspect_ratio, choose 1k, 1.5k or 2k resolution and low or medium quality, and generate up to 4 images per request. An edit takes up to 3 source images. Billed per image by quality and resolution; each source image in an edit is billed once per request.
Use either ID to call this model via the API.
xai/grok-imagine-image-2.0Replace the ONEHOP_KEY placeholder with your API key. Create one →
from openai import OpenAI
client = OpenAI(
base_url="https://api.onehop.ai/v1",
api_key="<ONEHOP_KEY>",
)
response = client.images.generate(
model="xai/grok-imagine-image-2.0",
prompt="A red panda coding under the moonlight",
n=1,
)
print(response.data[0].url)