Model Information
| Model ID | openai/gpt-image-2 |
| Category | Image |
| Endpoint | /api/v1/images/generations |
Request
POST https://shark.ai/api/v1/images/generationsAuthentication: Authorization: Bearer <api-key>
Request Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| model | string | ✓ | Model ID: openai/gpt-image-2 | |
| n | number (1..4) | 1 | Number of images to generate | |
| mask | url | Mask image for partial editing (PNG with alpha channel) | ||
| size | enum: 1024x1024 | 1536x1024 | 1024x1536 | 2048x2048 | auto | "auto" | Output image size | |
| image | array<url> | Reference images for editing (base64 data URL or HTTP URL) | ||
| prompt | string | ✓ | Text description of the image to generate or edit | |
| quality | enum: low | medium | high | auto | "auto" | Rendering quality | |
| background | enum: opaque | auto | "auto" | Background type (gpt-image-2 does not support transparent) | |
| output_format | enum: png | jpeg | webp | "png" | Output file format |
Code Examples
curl -X POST https://shark.ai/api/v1/images/generations \
-H "Authorization: Bearer <api-key>" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-2",
"n": 1,
"size": "auto",
"prompt": "Your prompt here",
"quality": "auto",
"background": "auto",
"output_format": "png"
}'Response
Response (200 OK)
{
"created": 1700000000,
"data": [
{
"url": "https://cos.example.com/images/...signed..."
}
],
"usage": {
"input_tokens": 14,
"output_tokens": 1542,
"total_tokens": 1556
},
"credit": 90
}Error Codes
| HTTP | Type | Description |
|---|---|---|
| 400 | invalid_request_error | Invalid parameters |
| 400 | content_moderation | Content blocked by safety system |
| 400 | input_too_large | Input exceeds model limit |
| 401 | auth_error | Invalid API key |
| 402 | insufficient_credits | Not enough credits |
| 429 | rate_limit_error | Too many requests |
| 502 | provider_error | Upstream error, retry later |
| 504 | timeout_error | Request timed out |