Skip to main content
POST
Create chat completion
This page uses the same chat/completions operation as Create chat completion, with the playground above pre-filled for the generic chat schema. The notes below describe how to use this endpoint to request Gemini-backed image generation from an OpenAI-compatible client.
Include an image-generation model in model (such as gemini-2.0-flash-preview-image-generation), set stream as needed, and supply your prompt through messages. Optionally include contents for additional Gemini-style multimodal context alongside messages.

Provider-specific notes

The contents field is a DGrid extension layered on top of the standard chat completions schema — it lets you pass Gemini-native parts (such as inlineData) alongside the OpenAI-style messages array when the target model supports it.

Example: requesting an image

Response fields

The response follows the standard chat completions shape. The generated image is embedded directly in the assistant message content:
array
Returned choice entries.
object
Token usage summary.

Example response

200

Authorizations

Authorization
string
header
required

Your DGrid API key. All endpoints use Authorization: Bearer <DGRID_API_KEY>.

Body

application/json
model
string
required

Target model ID in provider/model-name format.

Example:

"openai/gpt-4o"

messages
object[]
required

Conversation message list.

temperature
number
default:1

Sampling temperature.

top_p
number
default:1

Nucleus sampling value.

n
integer
default:1

Number of choices to generate.

stream
boolean
default:false

Enable SSE streaming.

max_tokens
integer

Maximum token count.

max_completion_tokens
integer

Max completion-only tokens.

presence_penalty
number
default:0

Presence penalty.

frequency_penalty
number
default:0

Frequency penalty.

logit_bias
object

Token bias configuration.

stop

Stop sequence string or array.

tools
object[]

Tool definitions.

tool_choice

Tool selection behavior. Defaults to auto.

response_format
object

Response schema or JSON mode config.

seed
integer

Deterministic seed.

user
string

End-user identifier.

Response

Chat completion result.

id
string

Completion identifier.

object
string

Always chat.completion.

created
integer

Creation timestamp.

model
string

Model that served the request.

choices
object[]

Returned choices.

usage
object

Token usage breakdown.

system_fingerprint
string