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

# 对话补全（OpenAI 兼容）

> OpenAI-compatible chat completions endpoint. Supports both streaming and non-streaming responses. Token usage is automatically billed to the caller's account.



## OpenAPI

````yaml POST /v1/chat/completions
openapi: 3.0.0
info:
  title: Profy Platform API
  version: 1.0.0
  description: >-
    Platform API for building on Profy — invoke Experts, use models, report
    billing events, and manage OAuth.
servers:
  - url: https://api.profy.cn
    description: Production
security: []
paths:
  /v1/chat/completions:
    post:
      tags:
        - Platform API
      summary: Chat completions (OpenAI-compatible)
      description: >-
        OpenAI-compatible chat completions endpoint. Supports both streaming and
        non-streaming responses. Token usage is automatically billed to the
        caller's account.
      operationId: chatCompletions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: Model identifier
                  example: deepseek-chat
                messages:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                          - tool
                      content:
                        type: string
                    required:
                      - role
                      - content
                  minItems: 1
                stream:
                  type: boolean
                  default: false
                temperature:
                  type: number
                  minimum: 0
                  maximum: 2
                max_tokens:
                  type: integer
                top_p:
                  type: number
                frequency_penalty:
                  type: number
                presence_penalty:
                  type: number
                stop:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                tools:
                  type: array
                  items:
                    type: object
                  description: Tool definitions (OpenAI function calling format)
                tool_choice:
                  description: Controls tool use behavior
              required:
                - model
                - messages
      responses:
        '200':
          description: >-
            Chat completion response (JSON or SSE stream depending on `stream`
            parameter)
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  object:
                    type: string
                    example: chat.completion
                  model:
                    type: string
                  choices:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                        message:
                          type: object
                          properties:
                            role:
                              type: string
                            content:
                              type: string
                        finish_reason:
                          type: string
                  usage:
                    type: object
                    properties:
                      prompt_tokens:
                        type: integer
                      completion_tokens:
                        type: integer
                      total_tokens:
                        type: integer
                  balance_remaining:
                    type: number
                    description: Remaining credit balance after this request
            text/event-stream:
              schema:
                type: string
        '400':
          description: Missing required fields or model not available
        '401':
          description: Unauthorized
        '502':
          description: Model provider returned an error
      security:
        - BearerToken: []
        - ApiKey: []
components:
  securitySchemes:
    BearerToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: OAuth2 access token issued via POST /oauth/token
    ApiKey:
      type: http
      scheme: bearer
      description: Developer API Key (sk-pro-xxx) created at platform.profy.cn

````