Images
The Images API covers Gemini-native image generation, OpenAI-compatible image endpoints, and Qwen-compatible image workflows exposed through the DGrid API gateway.
Gemini Native Format
Generate images through the Gemini native generateContent interface when you need provider-specific multimodal response controls.
/v1/models/{model}:generateContentRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
contents | array | Yes | Input content array. |
contents[] | object | Yes | The sample uses an empty object item inside contents. |
generationConfig | object | Yes | Generation configuration object. |
generationConfig.responseModalities | array | Yes | Requested modalities array. |
generationConfig.imageConfig | object | Yes | Image configuration object. |
generationConfig.imageConfig.aspectRatio | string | Yes | Aspect ratio value used in the sample. |
generationConfig.imageConfig.imageSize | string | Yes | Image size value used in the sample. |
Response Body
| Field | Type | Description |
|---|---|---|
candidates | array | Candidate responses returned by the model. |
candidates[].content | object | Generated content object. |
candidates[].content.role | string | Role returned in the generated content block. |
candidates[].content.parts | array | Returned content parts. |
candidates[].finishReason | string | Finish reason string. |
candidates[].safetyRatings | array | Safety evaluation results. |
usageMetadata | object | Token usage metadata. |
usageMetadata.promptTokenCount | integer | Prompt token count. |
usageMetadata.candidatesTokenCount | integer | Candidate output token count. |
usageMetadata.totalTokenCount | integer | Total token count. |
OpenAI Chat Format
Use the Chat Completions endpoint when you want to request Gemini-backed image generation from an OpenAI-compatible client.
/v1/chat/completionsRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model identifier sent in the request body. |
stream | boolean | Yes | Streaming flag included in the sample request. |
messages | array | Yes | Messages array included in the request body. |
messages[] | object | Yes | Message objects inside messages. |
contents | array | Yes | Additional contents array sent in the sample request. |
Response Body
| Field | Type | Description |
|---|---|---|
id | string | Chat completion identifier. |
model | string | Model used for the request. |
object | string | Response object type. |
created | integer | Creation timestamp. |
choices | array | Returned choice entries. |
choices[].index | integer | Choice index. |
choices[].message | object | Assistant message object. |
choices[].message.role | string | Message role. |
choices[].message.content | string | Message content. |
choices[].finish_reason | string | Finish reason. |
usage | object | Token usage summary. |
OpenAI Image Generations
Generate images with the OpenAI-compatible image creation endpoint.
/v1/images/generationsRequest Body
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | Yes | - | Image prompt. |
model | string | No | dall-e-2 | Model such as dall-e-2 or dall-e-3. |
n | integer | No | 1 | Number of images to generate. |
quality | string | No | standard | standard or hd. |
response_format | string | No | url | url or b64_json. |
size | string | No | 1024x1024 | Output size. |
style | string | No | vivid | vivid or natural. |
user | string | No | - | End-user identifier. |
Response Body
| Field | Type | Description |
|---|---|---|
created | integer | Creation timestamp. |
data | array | Generated image entries. |
data[].url | string | Image URL when using URL output. |
data[].b64_json | string | Base64 image payload when requested. |
data[].revised_prompt | string | Refined prompt returned by the model. |
OpenAI Image Edits
Edit an uploaded image with an optional mask using the OpenAI-compatible image editing endpoint.
/v1/images/editsForm Data
| Field | Type | Required | Description |
|---|---|---|---|
image | file | Yes | Source image in PNG format, under 4 MB. |
mask | file | No | Optional mask image. |
prompt | string | Yes | Editing instruction. |
model | string | No | Target image model. |
n | integer | No | Number of outputs. |
size | string | No | Output size. |
response_format | string | No | Response format. |
user | string | No | End-user identifier. |
Response Body
The response matches the OpenAI image generation schema, including data[].url or data[].b64_json.
Qwen Image Generations
Generate images through the Qwen-compatible OpenAI image endpoint for `wanx-v1` style models.
/v1/images/generationsRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model identifier, such as wanx-v1. |
input | object | Yes | Input wrapper object sent in the sample request. |
input.messages | array | Yes | Messages array nested under input. |
input.messages[] | object | Yes | Message objects inside input.messages. |
Response Body
| Field | Type | Description |
|---|---|---|
created | integer | Creation timestamp. |
data | array | Generated image entries. |
data[].url | string | Image URL. |
data[].b64_json | string | Base64 image payload. |
data[].revised_prompt | string | Revised prompt returned by the model. |
Qwen Image Edits
Edit images through the Qwen-compatible OpenAI image editing workflow.
/v1/images/editsRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model identifier sent in the sample request. |
input | object | Yes | Input wrapper object sent in the request body. |
input.messages | array | Yes | Messages array nested under input. |
input.messages[] | object | Yes | Message objects inside input.messages. |
Response Body
| Field | Type | Description |
|---|---|---|
created | integer | Creation timestamp. |
data | array | Generated image entries. |
data[].url | string | Image URL. |
data[].b64_json | string | Base64 image payload. |
data[].revised_prompt | string | Revised prompt returned by the model. |
