AI 모델 API채팅기본 OpenAI 형식

ChatCompletions 형식

대화 기록을 기반으로 모델 응답을 생성합니다. 스트리밍 및 비스트리밍 응답을 지원합니다.

OpenAI Chat Completions API와 호환됩니다.

POST
/v1/chat/completions

인증

BearerAuth

AuthorizationBearer <token>

Bearer Token 인증을 사용합니다. 형식: Authorization: Bearer sk-xxxxxx

In: header

요청 본문

application/json

model*string

모델 ID

messages*

대화 메시지 목록

temperature?number

Sampling temperature

Default1
Range0 <= value <= 2
top_p?number

Nucleus sampling parameters

Default1
Range0 <= value <= 1
n?integer

Generation Count

Default1
Range1 <= value
stream?boolean

Is streaming response

Defaultfalse
stream_options?
stop?string|

Stop sequence

max_tokens?integer

Maximum number of generated tokens

max_completion_tokens?integer

Maximum completion tokens

presence_penalty?number
Default0
Range-2 <= value <= 2
frequency_penalty?number
Default0
Range-2 <= value <= 2
logit_bias?
user?string
tools?
tool_choice?string|
response_format?
seed?integer
reasoning_effort?string

Inference Intensity (Model used to support inference)

Value in"low" | "medium" | "high"
modalities?array<string>
audio?
curl -X POST "https://us-api.tokenhub.com/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-4",    "messages": [      {        "role": "system",        "content": "string"      }    ]  }'
{
  "id": "string",
  "object": "chat.completion",
  "created": 0,
  "model": "string",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "system",
        "content": "string",
        "name": "string",
        "tool_calls": [
          {
            "id": "string",
            "type": "function",
            "function": {
              "name": "string",
              "arguments": "string"
            }
          }
        ],
        "tool_call_id": "string",
        "reasoning_content": "string"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "text_tokens": 0,
      "audio_tokens": 0,
      "image_tokens": 0
    },
    "completion_tokens_details": {
      "text_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0
    }
  },
  "system_fingerprint": "string"
}
{
  "error": {
    "message": "string",
    "type": "string",
    "param": "string",
    "code": "string"
  }
}
{
  "error": {
    "message": "string",
    "type": "string",
    "param": "string",
    "code": "string"
  }
}

응답 본문

application/json

application/json

application/json

마지막 업데이트