Skip to content

Chat

The Chat API section covers Claude-compatible conversations, Gemini-native multimodal messaging, OpenAI-compatible Chat Completions, and the newer Responses API.

Native Claude Format

Use the Claude Messages API when you need Anthropic-compatible payloads, tool use, or system prompts.

POST
https://api.dgrid.ai
POST/v1/messages
Authorization
Authorization: Bearer <DGRID_API_KEY>; anthropic-version: 2023-06-01
Request
application/json
Response
200 · application/json

Request Body

FieldTypeRequiredDescription
modelstringYesModel ID, such as claude-3-5-sonnet-20241022.
max_tokensintegerYesMaximum output token count.
messagesarrayYesConversation message list.
messages[].rolestringYesuser or assistant.
messages[].contentstring or arrayYesMessage content or content blocks.
systemstringNoSystem instructions.
temperaturenumberNoSampling temperature.
top_pnumberNoTop-p sampling.
top_kintegerNoTop-k sampling.
stop_sequencesarrayNoStop sequences.
streambooleanNoEnable streaming responses.
toolsarrayNoTool schema definitions.
tool_choiceobjectNoTool selection strategy.

Response Body

FieldTypeDescription
idstringMessage identifier.
typestringAlways message.
rolestringAlways assistant.
contentarrayReturned content blocks.
content[].typestringtext or tool_use.
content[].textstringText body when the content type is text.
modelstringModel that produced the output.
stop_reasonstringend_turn, max_tokens, stop_sequence, or tool_use.
usageobjectToken usage metadata.

Gemini Media Recognition

Use Gemini-native multimodal parts to analyze images, audio, video, or mixed media in a single request.

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

Path Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID such as gemini-1.5-pro.

Request Body

FieldTypeRequiredDescription
bodyobjectYesThe current example sends an empty JSON object {}.

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 accounting metadata.
usageMetadata.promptTokenCountintegerPrompt token count.
usageMetadata.candidatesTokenCountintegerCandidate output token count.
usageMetadata.totalTokenCountintegerTotal token count.

Gemini Text Chat

Use the Gemini native chat format when you want a lightweight text-only payload without switching providers.

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
bodyobjectYesThe current example sends an empty JSON object {}.

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 accounting metadata.
usageMetadata.promptTokenCountintegerPrompt token count.
usageMetadata.candidatesTokenCountintegerCandidate output token count.
usageMetadata.totalTokenCountintegerTotal token count.

Chat Completions

Use the OpenAI-compatible Chat Completions format for standard multi-turn chat, structured output, and tool calling.

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

Request Body

FieldTypeRequiredDefaultDescription
modelstringYes-Target model ID.
messagesarrayYes-Conversation message list.
messages[].rolestringYes-system, user, assistant, or tool.
messages[].contentstringYes-Message content.
messages[].namestringNo-Optional participant name.
messages[].tool_callsarrayNo-Tool invocation payloads.
messages[].tool_call_idstringNo-Tool call identifier.
temperaturenumberNo1Sampling temperature.
top_pnumberNo1Nucleus sampling value.
nintegerNo1Number of choices to generate.
streambooleanNofalseEnable SSE streaming.
max_tokensintegerNo-Maximum token count.
max_completion_tokensintegerNo-Max completion-only tokens.
presence_penaltynumberNo0Presence penalty.
frequency_penaltynumberNo0Frequency penalty.
logit_biasobjectNo-Token bias configuration.
stopstring or arrayNo-Stop sequence.
toolsarrayNo-Tool definitions.
tool_choicestring or objectNoautoTool selection behavior.
response_formatobjectNo-Response schema or JSON mode config.
seedintegerNo-Deterministic seed.
userstringNo-End-user identifier.

Response Body

FieldTypeDescription
idstringCompletion identifier.
objectstringAlways chat.completion.
createdintegerCreation timestamp.
modelstringModel that served the request.
choicesarrayReturned choices.
choices[].messageobjectAssistant message object.
choices[].message.rolestringResponse role.
choices[].message.contentstringResponse text.
choices[].message.tool_callsarrayTool call payloads.
choices[].finish_reasonstringstop, length, content_filter, or tool_calls.
usageobjectToken usage breakdown.

Responses

Use the OpenAI Responses API when you want stateful flows, reasoning-specific options, or newer OpenAI tooling patterns.

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

Request Body

FieldTypeRequiredDescription
modelstringYesTarget model ID.
body.modelstringYesThe current example only sends the model field in the request body.

Response Body

FieldTypeDescription
idstringResponse identifier.
objectstringAlways response.
created_atintegerCreation timestamp.
statusstringResponse lifecycle state.
modelstringModel used for inference.
outputarrayOutput items.
output[].typestringTypically message.
output[].rolestringOutput role.
output[].contentarrayOutput content blocks.
output[].content[].typestringoutput_text for text payloads.
output[].content[].textstringOutput text.
usageobjectToken usage summary.