Skip to main content
POST
/
v1
/
chat
/
completions
Create chat completion
curl --request POST \
  --url https://api.dgrid.ai/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "openai/gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": "What is the meaning of life?"
    }
  ]
}
'
{
  "id": "<string>",
  "object": "<string>",
  "created": 123,
  "model": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "<string>",
        "content": "<string>",
        "reasoning_content": "<string>",
        "tool_calls": [
          {}
        ]
      },
      "finish_reason": "<string>"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123,
    "prompt_tokens_details": {
      "cached_tokens": 123,
      "text_tokens": 123,
      "audio_tokens": 123,
      "image_tokens": 123
    },
    "completion_tokens_details": {
      "text_tokens": 123,
      "audio_tokens": 123,
      "reasoning_tokens": 123
    }
  },
  "system_fingerprint": "<string>"
}

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