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

# /v1/chat/completions

> OpenAI-compatible chat completion endpoint for multi-turn conversations, tool calling, and streaming responses.

Creates a model response for a chat conversation.

This endpoint is still the safest default when you need compatibility with existing OpenAI SDKs, chat clients, or legacy chat-completion workflows. Supported fields vary by model, especially for reasoning, tool use, and multimodal inputs.

## Integration guidance

* Authenticate with `Authorization: Bearer {API_KEY}`
* Use this as the default entry point for existing OpenAI-style chat integrations
* If you want a more unified interface for structured output, multimodal input, and tools, prefer `/v1/responses`
* Streaming clients should handle SSE chunks incrementally instead of waiting for one final JSON response

## Request highlights

* `messages` is required and carries the conversation history
* `model` is required and selects the target model
* `temperature` and `top_p` both affect sampling, but most integrations should tune only one of them
* If you need token-level probabilities, combine `logprobs` with `top_logprobs`
* For caching and safety attribution, prefer `prompt_cache_key` and `safety_identifier`

## Response highlights

* Plain text is usually read from `choices[0].message.content`
* Tool calls can be read from `message.tool_calls`
* Streaming responses arrive as SSE chunks and must be merged incrementally
* Usage accounting is exposed through `usage`, including more detailed token breakdowns


## 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://api-vip.apigo.ai
security:
  - bearerAuth: []
paths:
  /v1/chat/completions:
    post:
      summary: OpenAI chat completions
      description: 兼容 OpenAI 的聊天补全接口，支持多轮对话、工具调用和流式返回。
      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
          example: 0.7
        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

````