> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apigo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# /v1/chat/completions

> 다중 대화, 도구 호출 및 스트리밍 응답을 위한 OpenAI 호환 채팅 완료 엔드포인트입니다.

채팅 대화에 대한 모델 응답을 만듭니다.

이 엔드포인트는 기존 OpenAI SDK, 채팅 클라이언트 또는 레거시 채팅 완료 워크플로와의 호환성이 필요할 때 여전히 가장 안전한 기본값입니다. 지원되는 필드는 특히 추론, 도구 사용 및 다중 모드 입력의 경우 모델에 따라 다릅니다.

## 통합 지침

* `Authorization: Bearer {API_KEY}`로 인증
* 이를 기존 OpenAI 스타일 채팅 통합의 기본 진입점으로 사용합니다.
* 구조화된 출력, 다중 모드 입력 및 도구에 대한 보다 통합된 인터페이스를 원한다면 `/v1/responses`를 선호하세요.
* 스트리밍 클라이언트는 하나의 최종 JSON 응답을 기다리는 대신 SSE 청크를 점진적으로 처리해야 합니다.

## 요청 하이라이트

* `messages`가 필요하며 대화 기록을 전달합니다.
* `model`가 필요하며 대상 모델을 선택합니다.
* `temperature` 및 `top_p`는 모두 샘플링에 영향을 미치지만 대부분의 통합에서는 둘 중 하나만 조정해야 합니다.
* 토큰 수준의 확률이 필요한 경우 `logprobs`와 `top_logprobs`를 결합하세요.
* 캐싱 및 안전 속성을 위해서는 `prompt_cache_key` 및 `safety_identifier`를 선호합니다.

## 응답 하이라이트

* 일반 텍스트는 일반적으로 `choices[0].message.content`에서 읽습니다.
* `message.tool_calls`에서 도구 호출을 읽을 수 있습니다.
* 스트리밍 응답은 SSE 청크로 도착하며 점진적으로 병합되어야 합니다.
* 보다 자세한 토큰 분석을 포함하여 사용량 계산은 `usage`를 통해 노출됩니다.


## OpenAPI

````yaml POST /v1/chat/completions
openapi: 3.1.0
info:
  title: OpenAPI Plant Store
  description: >-
    A sample API that uses a plant store as an example to demonstrate features
    in the OpenAPI specification
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://maas.apigo.ai
security:
  - bearerAuth: []
paths:
  /v1/chat/completions:
    post:
      summary: OpenAI chat completions
      description: >-
        OpenAI-compatible chat completion endpoint for multi-turn conversations,
        tool calling, and streaming responses.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenAIChatCompletionsRequest'
      responses:
        '200':
          description: Successful chat completion response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIChatCompletionsResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    OpenAIChatCompletionsRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          example: gpt-4o
        messages:
          type: array
          items:
            $ref: '#/components/schemas/OpenAIMessage'
        temperature:
          type: number
          format: double
          minimum: 0
          maximum: 2
          description: 采样温度。类型：double。取值范围：0-2。
        stream:
          type: boolean
    OpenAIChatCompletionsResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          example: chat.completion
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                $ref: '#/components/schemas/OpenAIMessage'
              finish_reason:
                type: string
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
            completion_tokens:
              type: integer
            total_tokens:
              type: integer
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
    OpenAIMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
            - tool
        content:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````