Skip to content

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.

POST
https://api.dgrid.ai
POST/v1/models/{model}:generateContent
Authorization
Authorization: Bearer <DGRID_API_KEY>
Request
application/json
Response
200 · application/json

Request Body

FieldTypeRequiredDescription
contentsarrayYesInput content array.
contents[]objectYesThe sample uses an empty object item inside contents.
generationConfigobjectYesGeneration configuration object.
generationConfig.responseModalitiesarrayYesRequested modalities array.
generationConfig.imageConfigobjectYesImage configuration object.
generationConfig.imageConfig.aspectRatiostringYesAspect ratio value used in the sample.
generationConfig.imageConfig.imageSizestringYesImage size value used in the sample.

Response Body

FieldTypeDescription
candidatesarrayCandidate responses returned by the model.
candidates[].contentobjectGenerated content object.
candidates[].content.rolestringRole returned in the generated content block.
candidates[].content.partsarrayReturned content parts.
candidates[].finishReasonstringFinish reason string.
candidates[].safetyRatingsarraySafety evaluation results.
usageMetadataobjectToken usage metadata.
usageMetadata.promptTokenCountintegerPrompt token count.
usageMetadata.candidatesTokenCountintegerCandidate output token count.
usageMetadata.totalTokenCountintegerTotal token count.

OpenAI Chat Format

Use the Chat Completions endpoint when you want to request Gemini-backed image generation from an OpenAI-compatible client.

POST
https://api.dgrid.ai
POST/v1/chat/completions
Authorization
Authorization: Bearer <DGRID_API_KEY>
Request
application/json
Response
200 · application/json

Request Body

FieldTypeRequiredDescription
modelstringYesModel identifier sent in the request body.
streambooleanYesStreaming flag included in the sample request.
messagesarrayYesMessages array included in the request body.
messages[]objectYesMessage objects inside messages.
contentsarrayYesAdditional contents array sent in the sample request.

Response Body

FieldTypeDescription
idstringChat completion identifier.
modelstringModel used for the request.
objectstringResponse object type.
createdintegerCreation timestamp.
choicesarrayReturned choice entries.
choices[].indexintegerChoice index.
choices[].messageobjectAssistant message object.
choices[].message.rolestringMessage role.
choices[].message.contentstringMessage content.
choices[].finish_reasonstringFinish reason.
usageobjectToken usage summary.

OpenAI Image Generations

Generate images with the OpenAI-compatible image creation endpoint.

POST
https://api.dgrid.ai
POST/v1/images/generations
Authorization
Authorization: Bearer <DGRID_API_KEY>
Request
application/json
Response
200 · application/json

Request Body

FieldTypeRequiredDefaultDescription
promptstringYes-Image prompt.
modelstringNodall-e-2Model such as dall-e-2 or dall-e-3.
nintegerNo1Number of images to generate.
qualitystringNostandardstandard or hd.
response_formatstringNourlurl or b64_json.
sizestringNo1024x1024Output size.
stylestringNovividvivid or natural.
userstringNo-End-user identifier.

Response Body

FieldTypeDescription
createdintegerCreation timestamp.
dataarrayGenerated image entries.
data[].urlstringImage URL when using URL output.
data[].b64_jsonstringBase64 image payload when requested.
data[].revised_promptstringRefined prompt returned by the model.

OpenAI Image Edits

Edit an uploaded image with an optional mask using the OpenAI-compatible image editing endpoint.

POST
https://api.dgrid.ai
POST/v1/images/edits
Authorization
Authorization: Bearer <DGRID_API_KEY>
Request
multipart/form-data
Response
200 · application/json

Form Data

FieldTypeRequiredDescription
imagefileYesSource image in PNG format, under 4 MB.
maskfileNoOptional mask image.
promptstringYesEditing instruction.
modelstringNoTarget image model.
nintegerNoNumber of outputs.
sizestringNoOutput size.
response_formatstringNoResponse format.
userstringNoEnd-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.

POST
https://api.dgrid.ai
POST/v1/images/generations
Authorization
Authorization: Bearer <DGRID_API_KEY>
Request
application/json
Response
200 · application/json

Request Body

FieldTypeRequiredDescription
modelstringYesModel identifier, such as wanx-v1.
inputobjectYesInput wrapper object sent in the sample request.
input.messagesarrayYesMessages array nested under input.
input.messages[]objectYesMessage objects inside input.messages.

Response Body

FieldTypeDescription
createdintegerCreation timestamp.
dataarrayGenerated image entries.
data[].urlstringImage URL.
data[].b64_jsonstringBase64 image payload.
data[].revised_promptstringRevised prompt returned by the model.

Qwen Image Edits

Edit images through the Qwen-compatible OpenAI image editing workflow.

POST
https://api.dgrid.ai
POST/v1/images/edits
Authorization
Authorization: Bearer <DGRID_API_KEY>
Request
application/json
Response
200 · application/json

Request Body

FieldTypeRequiredDescription
modelstringYesModel identifier sent in the sample request.
inputobjectYesInput wrapper object sent in the request body.
input.messagesarrayYesMessages array nested under input.
input.messages[]objectYesMessage objects inside input.messages.

Response Body

FieldTypeDescription
createdintegerCreation timestamp.
dataarrayGenerated image entries.
data[].urlstringImage URL.
data[].b64_jsonstringBase64 image payload.
data[].revised_promptstringRevised prompt returned by the model.