# Create Chat Completion

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /chat/completions:
    post:
      summary: Create Chat Completion
      deprecated: false
      description: Creates a model response for the given chat conversation.
      tags:
        - API Reference
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                messages:
                  type: array
                  items:
                    oneOf:
                      - type: object
                        properties: {}
                        x-apidog-orders: []
                      - type: object
                        properties: {}
                        x-apidog-orders: []
                      - type: object
                        properties: {}
                        x-apidog-orders: []
                model:
                  type: string
                frequency_penalty:
                  type: integer
                  nullable: true
                max_tokens:
                  type: integer
                  nullable: true
                presence_penalty:
                  type: number
                  nullable: true
                response_format:
                  type: object
                  properties:
                    type:
                      type: string
                  x-apidog-orders:
                    - type
                  required:
                    - type
                  nullable: true
                stop:
                  oneOf:
                    - type: object
                      properties: {}
                      x-apidog-orders: []
                      nullable: true
                    - type: object
                      properties: {}
                      x-apidog-orders: []
                      nullable: true
                stream:
                  type: boolean
                  nullable: true
                stream_options:
                  type: object
                  properties: {}
                  x-apidog-orders: []
                  nullable: true
                temperature:
                  type: number
                  nullable: true
                top_p:
                  type: integer
                  nullable: true
                tools:
                  type: 'null'
                tool_choice:
                  oneOf:
                    - type: object
                      properties: {}
                      x-apidog-orders: []
                    - type: object
                      properties: {}
                      x-apidog-orders: []
                logprobs:
                  type: boolean
                  nullable: true
                top_logprobs:
                  type: integer
                  nullable: true
              required:
                - messages
                - model
              x-apidog-orders:
                - messages
                - model
                - frequency_penalty
                - max_tokens
                - presence_penalty
                - response_format
                - stop
                - stream
                - stream_options
                - temperature
                - top_p
                - tools
                - tool_choice
                - logprobs
                - top_logprobs
            examples:
              '1':
                value:
                  messages:
                    - content: You are a helpful assistant
                      role: system
                    - content: Hi
                      role: user
                  model: deepseek-chat
                  frequency_penalty: 0
                  max_tokens: 2048
                  presence_penalty: 0
                  response_format:
                    type: text
                  stop: null
                  stream: false
                  stream_options: null
                  temperature: 1
                  top_p: 1
                  tools: null
                  tool_choice: none
                  logprobs: false
                  top_logprobs: null
                summary: No streaminng
              '2':
                value:
                  messages:
                    - content: You are a helpful assistant
                      role: system
                    - content: Hi
                      role: user
                  model: deepseek-chat
                  frequency_penalty: 0
                  max_tokens: 2048
                  presence_penalty: 0
                  response_format:
                    type: text
                  stop: null
                  stream: true
                  stream_options: null
                  temperature: 1
                  top_p: 1
                  tools: null
                  tool_choice: none
                  logprobs: false
                  top_logprobs: null
                summary: Streaming
      responses:
        '200':
          description: OK, returns a `chat completion object`
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  choices:
                    type: array
                    items:
                      type: object
                      properties:
                        finish_reason:
                          type: string
                        index:
                          type: integer
                        message:
                          type: object
                          properties:
                            content:
                              type: string
                            role:
                              type: string
                            reasoning_content:
                              type: string
                            tool_calls:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: string
                                  type:
                                    type: string
                                  function:
                                    type: object
                                    properties:
                                      name:
                                        type: string
                                      arguments:
                                        type: string
                                    required:
                                      - name
                                      - arguments
                                    x-apidog-orders:
                                      - name
                                      - arguments
                                x-apidog-orders:
                                  - id
                                  - type
                                  - function
                          required:
                            - content
                            - role
                            - reasoning_content
                            - tool_calls
                          x-apidog-orders:
                            - content
                            - role
                            - reasoning_content
                            - tool_calls
                        logprobs:
                          type: object
                          properties:
                            content:
                              type: array
                              items:
                                type: object
                                properties:
                                  token:
                                    type: string
                                  logprob:
                                    type: integer
                                  bytes:
                                    type: array
                                    items:
                                      type: integer
                                  top_logprobs:
                                    type: array
                                    items:
                                      type: object
                                      properties:
                                        token:
                                          type: string
                                        logprob:
                                          type: integer
                                        bytes:
                                          type: array
                                          items:
                                            type: integer
                                      x-apidog-orders:
                                        - token
                                        - logprob
                                        - bytes
                                x-apidog-orders:
                                  - token
                                  - logprob
                                  - bytes
                                  - top_logprobs
                          required:
                            - content
                          x-apidog-orders:
                            - content
                      x-apidog-orders:
                        - finish_reason
                        - index
                        - message
                        - logprobs
                  created:
                    type: integer
                  model:
                    type: string
                  object:
                    type: string
                  usage:
                    type: object
                    properties:
                      completion_tokens:
                        type: integer
                      prompt_tokens:
                        type: integer
                      total_tokens:
                        type: integer
                      prompt_cache_hit_tokens:
                        type: integer
                      prompt_cache_miss_tokens:
                        type: integer
                      completion_tokens_details:
                        type: object
                        properties:
                          reasoning_tokens:
                            type: integer
                        required:
                          - reasoning_tokens
                        x-apidog-orders:
                          - reasoning_tokens
                    required:
                      - completion_tokens
                      - prompt_tokens
                      - total_tokens
                      - prompt_cache_hit_tokens
                      - prompt_cache_miss_tokens
                      - completion_tokens_details
                    x-apidog-orders:
                      - completion_tokens
                      - prompt_tokens
                      - total_tokens
                      - prompt_cache_hit_tokens
                      - prompt_cache_miss_tokens
                      - completion_tokens_details
                  system_fingerprint:
                    type: string
                required:
                  - id
                  - choices
                  - created
                  - model
                  - object
                  - usage
                  - system_fingerprint
                x-apidog-orders:
                  - id
                  - choices
                  - created
                  - model
                  - object
                  - usage
                  - system_fingerprint
              example:
                id: 930c60df-bf64-41c9-a88e-3ec75f81e00e
                choices:
                  - finish_reason: stop
                    index: 0
                    message:
                      content: Hello! How can I help you today?
                      role: assistant
                created: 1705651092
                model: deepseek-chat
                object: chat.completion
                usage:
                  completion_tokens: 10
                  prompt_tokens: 16
                  total_tokens: 26
          headers: {}
          x-apidog-name: No streaming
        x-200:Streaming:
          description: OK, returns a streamed sequence of `chat completion chunk` objects
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  choices:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                        delta:
                          type: object
                          properties:
                            content:
                              type: string
                            role:
                              type: string
                          required:
                            - content
                            - role
                          x-apidog-orders:
                            - content
                            - role
                        finish_reason:
                          type: 'null'
                        logprobs:
                          type: 'null'
                      x-apidog-orders:
                        - index
                        - delta
                        - finish_reason
                        - logprobs
                  created:
                    type: integer
                  model:
                    type: string
                  system_fingerprint:
                    type: string
                  object:
                    type: string
                  usage:
                    type: 'null'
                required:
                  - id
                  - choices
                  - created
                  - model
                  - system_fingerprint
                  - object
                  - usage
                x-apidog-orders:
                  - id
                  - choices
                  - created
                  - model
                  - system_fingerprint
                  - object
                  - usage
              example: "data: {\"id\": \"1f633d8bfc032625086f14113c411638\", \"choices\": [{\"index\": 0, \"delta\": {\"content\": \"\", \"role\": \"assistant\"}, \"finish_reason\": null, \"logprobs\": null}], \"created\": 1718345013, \"model\": \"deepseek-chat\", \"system_fingerprint\": \"fp_a49d71b8a1\", \"object\": \"chat.completion.chunk\", \"usage\": null}\r\n\r\ndata: {\"choices\": [{\"delta\": {\"content\": \"Hello\", \"role\": \"assistant\"}, \"finish_reason\": null, \"index\": 0, \"logprobs\": null}], \"created\": 1718345013, \"id\": \"1f633d8bfc032625086f14113c411638\", \"model\": \"deepseek-chat\", \"object\": \"chat.completion.chunk\", \"system_fingerprint\": \"fp_a49d71b8a1\"}\r\n\r\ndata: {\"choices\": [{\"delta\": {\"content\": \"!\", \"role\": \"assistant\"}, \"finish_reason\": null, \"index\": 0, \"logprobs\": null}], \"created\": 1718345013, \"id\": \"1f633d8bfc032625086f14113c411638\", \"model\": \"deepseek-chat\", \"object\": \"chat.completion.chunk\", \"system_fingerprint\": \"fp_a49d71b8a1\"}\r\n\r\ndata: {\"choices\": [{\"delta\": {\"content\": \" How\", \"role\": \"assistant\"}, \"finish_reason\": null, \"index\": 0, \"logprobs\": null}], \"created\": 1718345013, \"id\": \"1f633d8bfc032625086f14113c411638\", \"model\": \"deepseek-chat\", \"object\": \"chat.completion.chunk\", \"system_fingerprint\": \"fp_a49d71b8a1\"}\r\n\r\ndata: {\"choices\": [{\"delta\": {\"content\": \" can\", \"role\": \"assistant\"}, \"finish_reason\": null, \"index\": 0, \"logprobs\": null}], \"created\": 1718345013, \"id\": \"1f633d8bfc032625086f14113c411638\", \"model\": \"deepseek-chat\", \"object\": \"chat.completion.chunk\", \"system_fingerprint\": \"fp_a49d71b8a1\"}\r\n\r\ndata: {\"choices\": [{\"delta\": {\"content\": \" I\", \"role\": \"assistant\"}, \"finish_reason\": null, \"index\": 0, \"logprobs\": null}], \"created\": 1718345013, \"id\": \"1f633d8bfc032625086f14113c411638\", \"model\": \"deepseek-chat\", \"object\": \"chat.completion.chunk\", \"system_fingerprint\": \"fp_a49d71b8a1\"}\r\n\r\ndata: {\"choices\": [{\"delta\": {\"content\": \" assist\", \"role\": \"assistant\"}, \"finish_reason\": null, \"index\": 0, \"logprobs\": null}], \"created\": 1718345013, \"id\": \"1f633d8bfc032625086f14113c411638\", \"model\": \"deepseek-chat\", \"object\": \"chat.completion.chunk\", \"system_fingerprint\": \"fp_a49d71b8a1\"}\r\n\r\ndata: {\"choices\": [{\"delta\": {\"content\": \" you\", \"role\": \"assistant\"}, \"finish_reason\": null, \"index\": 0, \"logprobs\": null}], \"created\": 1718345013, \"id\": \"1f633d8bfc032625086f14113c411638\", \"model\": \"deepseek-chat\", \"object\": \"chat.completion.chunk\", \"system_fingerprint\": \"fp_a49d71b8a1\"}\r\n\r\ndata: {\"choices\": [{\"delta\": {\"content\": \" today\", \"role\": \"assistant\"}, \"finish_reason\": null, \"index\": 0, \"logprobs\": null}], \"created\": 1718345013, \"id\": \"1f633d8bfc032625086f14113c411638\", \"model\": \"deepseek-chat\", \"object\": \"chat.completion.chunk\", \"system_fingerprint\": \"fp_a49d71b8a1\"}\r\n\r\ndata: {\"choices\": [{\"delta\": {\"content\": \"?\", \"role\": \"assistant\"}, \"finish_reason\": null, \"index\": 0, \"logprobs\": null}], \"created\": 1718345013, \"id\": \"1f633d8bfc032625086f14113c411638\", \"model\": \"deepseek-chat\", \"object\": \"chat.completion.chunk\", \"system_fingerprint\": \"fp_a49d71b8a1\"}\r\n\r\ndata: {\"choices\": [{\"delta\": {\"content\": \"\", \"role\": null}, \"finish_reason\": \"stop\", \"index\": 0, \"logprobs\": null}], \"created\": 1718345013, \"id\": \"1f633d8bfc032625086f14113c411638\", \"model\": \"deepseek-chat\", \"object\": \"chat.completion.chunk\", \"system_fingerprint\": \"fp_a49d71b8a1\", \"usage\": {\"completion_tokens\": 9, \"prompt_tokens\": 17, \"total_tokens\": 26}}\r\n\r\ndata: [DONE]"
          headers: {}
          x-apidog-name: Streaming
      security: []
      x-apidog-folder: API Reference
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/806570/apis/api-13759421-run
components:
  schemas: {}
  securitySchemes:
    bearer:
      type: bearer
      scheme: bearer
servers:
  - url: https://api.deepseek.com
    description: Prod Env
security:
  - bearer: []
    x-apidog:
      required: true
      schemeGroups:
        - id: n8qJSdwi83VLcgtIOHMrr
          schemeIds:
            - bearer
      use:
        id: n8qJSdwi83VLcgtIOHMrr

```
