OHGROK / Integration guide
Generate your first image
Choose an image model, submit a prompt, and save the output.
On this page
Before the request
Image generation is available through the API. This walkthrough uses the configured image-2 route, with a single image and a small, explicit prompt.
Image generation uses the API. Registration is open; check your wallet balance and current top-up options, then select a compatible key group with available upstream capacity.
1. Select an image group
In the console, create a site API key in 经济方案|Image (image图片生成) for this example. image-2 also appears in 标准方案|Image (image图片生成稳定), with a different price. Keep the selected group explicit instead of assuming all keys have the same rate.
- Check image-2 in the model catalog before submitting.
- Start with n: 1. Add size or other image options only when the selected model documents support for them.
- The endpoint shown here is the synchronous Images API. It is separate from the asynchronous video-task workflow.
2. Submit the image request
Run this command from your backend environment or terminal. It saves the JSON response to image-response.json so you can inspect the returned output.
export OHGROK_API_KEY='YOUR_API_KEY'
curl --fail-with-body --silent --show-error \
'https://api.ohgrok.com/v1/images/generations' \
-H "Authorization: Bearer $OHGROK_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "image-2",
"prompt": "A blue inflatable puppy on a peach studio set, soft natural shadows",
"n": 1
}' \
-o image-response.json 3. Read and save the output
Inspect the JSON before using it. A successful image response may provide a URL in data[0].url or base64 image data in data[0].b64_json. Handle the format actually returned by your chosen model.
For a URL result, download from that returned URL. For base64, decode the value into an image file and preserve the actual image format. Do not assume every model returns the same file type.
If the request times out, check its recorded outcome before resubmitting. A client timeout alone does not establish that generation was never started.
4. Keep usage and price together
image-2 is billed per generated image. Some Grok and GPT Image routes are billed per request instead, so an image count is not always the billing count. Check the exact model, group and billing unit before estimating a batch; group rates are already included in the displayed price.
The blue puppy artwork on this website is an illustrative design asset. It is not a receipt from this image-2 request or a claim about the output of a particular model.