메인 콘텐츠로 건너뛰기
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>"
}
이 페이지는 채팅 완성 생성과 동일한 chat/completions 작업을 사용하며, 위의 플레이그라운드에는 일반적인 채팅 스키마가 미리 입력되어 있습니다. 아래 내용은 OpenAI 호환 클라이언트에서 이 엔드포인트를 사용하여 Gemini 기반 이미지 생성을 요청하는 방법을 설명합니다.
model에 이미지 생성 모델(예: gemini-2.0-flash-preview-image-generation)을 포함하고, 필요에 따라 stream을 설정하며, messages를 통해 프롬프트를 제공하세요. 선택적으로 messages와 함께 추가적인 Gemini 스타일 멀티모달 컨텍스트를 위해 contents를 포함할 수 있습니다.

제공자별 참고 사항

필드유형필수설명
modelstring이미지 생성 모델 식별자입니다 (예: gemini-2.0-flash-preview-image-generation).
messages[].contentstring원하는 이미지를 설명하는 프롬프트 텍스트입니다.
contentsarray아니요추가적인 멀티모달 컨텍스트를 위한 선택적 Gemini 스타일 콘텐츠 배열로, 표준 OpenAI 채팅 스키마의 일부가 아닙니다.
contents 필드는 표준 채팅 완성 스키마 위에 추가된 DGrid 확장 기능입니다 — 대상 모델이 지원하는 경우, OpenAI 스타일의 messages 배열과 함께 Gemini 네이티브 parts(예: inlineData)를 전달할 수 있게 해줍니다.

예시: 이미지 요청

{
  "model": "gemini-2.0-flash-preview-image-generation",
  "stream": false,
  "messages": [
    {
      "role": "user",
      "content": "Generate an image of a futuristic city skyline at sunset."
    }
  ]
}

응답 필드

응답은 표준 채팅 완성 형식을 따릅니다. 생성된 이미지는 어시스턴트 메시지 콘텐츠에 직접 포함됩니다.
choices
array
반환된 선택 항목입니다.
usage
object
토큰 사용량 요약입니다.

응답 예시

200
{
  "id": "chatcmpl-abc123",
  "model": "gemini-2.0-flash-preview-image-generation",
  "object": "chat.completion",
  "created": 1719859200,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "![generated image](data:image/png;base64,<base64-encoded-image-bytes>)"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 0,
    "total_tokens": 12
  }
}

인증

Authorization
string
header
필수

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

본문

application/json
model
string
필수

Target model ID in provider/model-name format.

예시:

"openai/gpt-4o"

messages
object[]
필수

Conversation message list.

temperature
number
기본값:1

Sampling temperature.

top_p
number
기본값:1

Nucleus sampling value.

n
integer
기본값:1

Number of choices to generate.

stream
boolean
기본값:false

Enable SSE streaming.

max_tokens
integer

Maximum token count.

max_completion_tokens
integer

Max completion-only tokens.

presence_penalty
number
기본값:0

Presence penalty.

frequency_penalty
number
기본값: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.

응답

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