# DeepSeek V4.1 Flash

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /openai/v1/responses:
    post:
      summary: DeepSeek V4.1 Flash
      deprecated: false
      description: >
        :::warning

        **⚠️ Chat only**


        This model currently supports chat requests only and has not yet been
        adapted for agent use. Connecting it to an agent may cause request
        errors or unexpected results.

        :::


        :::tip

        **Upgraded to DeepSeek-V4.1-Flash-1017.** `deepseek-v4-1-flash` now
        serves the DeepSeek-V4.1-Flash-1017 release (October 17, 2026). The
        model name, endpoint and request format are unchanged, so existing
        integrations keep working without any changes. The new release improves
        coding and reasoning performance while producing shorter outputs and
        completing tasks faster.

        :::


        > DeepSeek V4.1 Flash API is an OpenAI Responses–compatible endpoint
        that accepts a plain string or a structured input array, thinks deeply
        by default, and supports function calling, image understanding, and
        structured JSON output.


        <CardGroup cols={2}>
          <Card title="Thinking Control" icon="🧠">
            Deep thinking is on by default, with seven effort levels to tune.
          </Card>

          <Card title="Multimodal Input" icon="🖼️">
            Supports mixed text and image inputs in a single message.
          </Card>

          <Card title="Tools & Structured Output" icon="✨">
            Custom function calling, and answers constrained to JSON.
          </Card>

          <Card title="Unified Endpoint" icon="💻">
            Uses the unified <code>/openai/v1/responses</code> endpoint with <code>model</code> set to <code>deepseek-v4-1-flash</code>.
          </Card>
        </CardGroup>


        ## Thinking


        The model **thinks by default**. Turn it off for a faster and cheaper
        answer — `reasoning.effort` and `thinking.type` do the same job, so you
        only need one of them.


        :::caution

        `max_output_tokens`, `temperature` and `top_p` are **not supported** on
        this model and have no effect.

        :::


        <AccordionGroup>
          <Accordion title="Turn thinking off">
            These two are equivalent:

            ```json
            { "reasoning": { "effort": "none" } }
            ```

            ```json
            { "thinking": { "type": "disabled" } }
            ```

            `thinking.type`: `enabled` (default) or `disabled`.
          </Accordion>

          <Accordion title="Effort levels">
            `reasoning.effort` accepts `none`, `minimal`, `low`, `medium`, `high`, `xhigh` and `max`.

            `none` turns thinking off (same as `thinking.type: "disabled"`). `minimal` keeps thinking brief. Above that, the higher the level the more thoroughly the model thinks and the more tokens it spends.
          </Accordion>
        </AccordionGroup>


        ## Tools & input


        <AccordionGroup>
          <Accordion title="Function calling">
            Declare the functions the model may call. Only the `function` type is supported:

            ```json
            {
              "tools": [
                {
                  "type": "function",
                  "name": "get_current_weather",
                  "description": "Get the current weather in a given location",
                  "parameters": {
                    "type": "object",
                    "properties": {
                      "location": {
                        "type": "string",
                        "description": "The city and state, e.g. San Francisco, CA"
                      }
                    },
                    "required": ["location"]
                  }
                }
              ],
              "tool_choice": "auto"
            }
            ```

            `tool_choice` defaults to `auto` once `tools` is present. Use `required` to force a call, or `{"type": "function", "name": "..."}` to pin one specific function.
          </Accordion>

          <Accordion title="Return the execution result">
            The model answers with a `function_call` item. Run the function, then append both that item and your `function_call_output` to `input` — the two are paired through `call_id`:

            ```json
            {
              "input": [
                { "role": "user", "content": "What's the weather in Beijing today?" },
                {
                  "type": "function_call",
                  "call_id": "call_00_xxx",
                  "name": "get_current_weather",
                  "arguments": "{\"location\":\"Beijing\"}"
                },
                {
                  "type": "function_call_output",
                  "call_id": "call_00_xxx",
                  "output": "Sunny, 25°C"
                }
              ]
            }
            ```
          </Accordion>

          <Accordion title="Image understanding">
            Mix `input_image` and `input_text` parts inside one message. `image_url` takes a publicly reachable URL or a `data:image/{format};base64,{encoded}` string:

            ```json
            {
              "input": [
                {
                  "role": "user",
                  "content": [
                    { "type": "input_image", "image_url": "https://example.com/demo.png" },
                    { "type": "input_text", "text": "What is in this image?" }
                  ]
                }
              ]
            }
            ```
          </Accordion>

          <Accordion title="JSON output">
            Set `text.format` to constrain the answer to JSON:

            ```json
            { "text": { "format": { "type": "json_object" } } }
            ```

            Use `json_schema` instead to validate the answer against a schema of your own.
          </Accordion>
        </AccordionGroup>


        ## Error handling


        Check the response body, not only the HTTP status. Errors are returned
        either as `{"code": ..., "msg": "..."}` (for example 401 invalid API
        key, 402 insufficient credits, 429 rate limited; the HTTP status may
        still be 200) or as `{"error": {"type": "...", "message": "..."}}`.
      operationId: openai/v1/responses
      tags:
        - docs/en/Market/Chat  Models/Deepseek
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: 'Target model name. Allowed values: `deepseek-v4-1-flash`.'
                  enum:
                    - deepseek-v4-1-flash
                  x-apidog-enum:
                    - value: deepseek-v4-1-flash
                      name: ''
                      description: ''
                  examples:
                    - deepseek-v4-1-flash
                stream:
                  type: boolean
                  description: >-
                    When true, responses stream in real time as server-sent
                    events. When false, the full response is returned at once
                    after completion. Default is true.
                  default: true
                input:
                  oneOf:
                    - type: string
                      description: Input can be a string.
                    - type: array
                      description: >-
                        Input can be an array; each element is a message, a
                        function call, or a function call result.
                      items:
                        oneOf:
                          - type: object
                            title: message
                            description: >-
                              A message object with role and content. `type` may
                              be omitted, in which case it defaults to
                              `message`.
                            properties:
                              type:
                                type: string
                                enum:
                                  - message
                                x-apidog-enum:
                                  - value: message
                                    name: ''
                                    description: ''
                              role:
                                type: string
                                description: >-
                                  The role of the message author. `system` and
                                  `developer` instructions take precedence over
                                  `user`, while `assistant` carries a previous
                                  answer.
                                enum:
                                  - system
                                  - developer
                                  - user
                                  - assistant
                                x-apidog-enum:
                                  - value: system
                                    name: ''
                                    description: ''
                                  - value: developer
                                    name: ''
                                    description: ''
                                  - value: user
                                    name: ''
                                    description: ''
                                  - value: assistant
                                    name: ''
                                    description: ''
                              content:
                                oneOf:
                                  - type: string
                                  - type: array
                                    items:
                                      oneOf:
                                        - type: object
                                          title: input_text
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - input_text
                                              x-apidog-enum:
                                                - value: input_text
                                                  name: ''
                                                  description: ''
                                            text:
                                              type: string
                                              description: Text content.
                                          required:
                                            - type
                                            - text
                                          x-apidog-orders:
                                            - type
                                            - text
                                          x-apidog-ignore-properties: []
                                        - type: object
                                          title: input_image
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - input_image
                                              x-apidog-enum:
                                                - value: input_image
                                                  name: ''
                                                  description: ''
                                            image_url:
                                              type: string
                                              description: >-
                                                Image address. A publicly reachable URL,
                                                or a
                                                `data:image/{format};base64,{encoded}`
                                                string.
                                            detail:
                                              type: string
                                              description: >-
                                                Image understanding precision. Higher
                                                values provide more detail but may
                                                increase latency.
                                              enum:
                                                - auto
                                                - low
                                                - high
                                                - xhigh
                                              x-apidog-enum:
                                                - value: auto
                                                  name: ''
                                                  description: ''
                                                - value: low
                                                  name: ''
                                                  description: ''
                                                - value: high
                                                  name: ''
                                                  description: ''
                                                - value: xhigh
                                                  name: ''
                                                  description: ''
                                          required:
                                            - type
                                            - image_url
                                          x-apidog-orders:
                                            - type
                                            - image_url
                                            - detail
                                          x-apidog-ignore-properties: []
                                        - type: object
                                          title: output_text
                                          description: >-
                                            An assistant answer replayed in a
                                            multi-turn conversation.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - output_text
                                              x-apidog-enum:
                                                - value: output_text
                                                  name: ''
                                                  description: ''
                                            text:
                                              type: string
                                              description: Text content.
                                          required:
                                            - type
                                            - text
                                          x-apidog-orders:
                                            - type
                                            - text
                                          x-apidog-ignore-properties: []
                                description: >-
                                  Message content. Either a plain string, or an
                                  array of text and image parts.
                            required:
                              - role
                              - content
                            x-apidog-orders:
                              - type
                              - role
                              - content
                            x-apidog-ignore-properties: []
                          - type: object
                            title: function_call
                            description: >-
                              A function call the model made in a previous turn.
                              Paired with `function_call_output` through
                              `call_id`.
                            properties:
                              type:
                                type: string
                                enum:
                                  - function_call
                                x-apidog-enum:
                                  - value: function_call
                                    name: ''
                                    description: ''
                              call_id:
                                type: string
                                description: >-
                                  Call identifier. Pass back the `call_id` from
                                  the previous output verbatim.
                              name:
                                type: string
                                description: Name of the function the model called.
                              arguments:
                                type: string
                                description: Function arguments, as a JSON string.
                            required:
                              - type
                              - call_id
                              - name
                              - arguments
                            x-apidog-orders:
                              - type
                              - call_id
                              - name
                              - arguments
                            x-apidog-ignore-properties: []
                          - type: object
                            title: function_call_output
                            description: >-
                              The result of running a function, returned to the
                              model.
                            properties:
                              type:
                                type: string
                                enum:
                                  - function_call_output
                                x-apidog-enum:
                                  - value: function_call_output
                                    name: ''
                                    description: ''
                              call_id:
                                type: string
                                description: >-
                                  Call identifier. Must match the `call_id` of
                                  the corresponding `function_call`.
                              output:
                                type: string
                                description: Function execution result, as text.
                            required:
                              - type
                              - call_id
                              - output
                            x-apidog-orders:
                              - type
                              - call_id
                              - output
                            x-apidog-ignore-properties: []
                      minItems: 1
                instructions:
                  type: string
                  description: >-
                    System instructions for the model, inserted as a system
                    message ahead of `input`.
                reasoning:
                  type: object
                  description: Reasoning configuration for the model.
                  properties:
                    effort:
                      type: string
                      description: >-
                        Reasoning effort level. Higher values provide more
                        thorough reasoning but may increase latency. `none`
                        turns thinking off (same as `thinking.type:
                        "disabled"`). `minimal` keeps thinking brief. Defaults
                        to reasoning being enabled.
                      enum:
                        - none
                        - minimal
                        - low
                        - medium
                        - high
                        - xhigh
                        - max
                      x-apidog-enum:
                        - value: none
                          name: ''
                          description: ''
                        - value: minimal
                          name: ''
                          description: ''
                        - value: low
                          name: ''
                          description: ''
                        - value: medium
                          name: ''
                          description: ''
                        - value: high
                          name: ''
                          description: ''
                        - value: xhigh
                          name: ''
                          description: ''
                        - value: max
                          name: ''
                          description: ''
                  x-apidog-orders:
                    - effort
                  x-apidog-ignore-properties: []
                thinking:
                  type: object
                  description: >-
                    Thinking configuration. An alternative to `reasoning.effort`
                    — configure either one, not both.
                  properties:
                    type:
                      type: string
                      description: 'Thinking behavior: `enabled` (default) or `disabled`.'
                      enum:
                        - enabled
                        - disabled
                      default: enabled
                      x-apidog-enum:
                        - value: enabled
                          name: ''
                          description: ''
                        - value: disabled
                          name: ''
                          description: ''
                  x-apidog-orders:
                    - type
                  x-apidog-ignore-properties: []
                tools:
                  type: array
                  description: >-
                    Optional tools that the model may call. Only the `function`
                    type is supported.
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        description: Tool type. Fixed as `function`.
                        enum:
                          - function
                        x-apidog-enum:
                          - value: function
                            name: ''
                            description: ''
                      name:
                        type: string
                        description: >-
                          Function name. Returned verbatim when the model calls
                          it.
                      description:
                        type: string
                        description: >-
                          What the function does. Helps the model decide when to
                          call it.
                      parameters:
                        type: object
                        description: >-
                          Function parameter definition, as a JSON Schema
                          object.
                        properties: {}
                        x-apidog-orders: []
                        x-apidog-ignore-properties: []
                    required:
                      - type
                      - name
                      - parameters
                    x-apidog-orders:
                      - type
                      - name
                      - description
                      - parameters
                    x-apidog-ignore-properties: []
                tool_choice:
                  description: >-
                    Tool selection behavior. When function tools are configured
                    in `tools`, set this to `auto` so the model can decide when
                    to call them. Use `required` to force a call, or an object
                    to pin one specific function. Defaults to `none` when
                    `tools` is absent.
                  oneOf:
                    - type: string
                      description: A preset selection strategy.
                      enum:
                        - none
                        - auto
                        - required
                      x-apidog-enum:
                        - value: none
                          name: ''
                          description: ''
                        - value: auto
                          name: ''
                          description: ''
                        - value: required
                          name: ''
                          description: ''
                    - type: object
                      description: Pin one specific function.
                      properties:
                        type:
                          type: string
                          description: Tool type. Fixed as `function`.
                          enum:
                            - function
                          x-apidog-enum:
                            - value: function
                              name: ''
                              description: ''
                        name:
                          type: string
                          description: >-
                            Function name. Returned verbatim when the model
                            calls it.
                      required:
                        - type
                        - name
                      x-apidog-orders:
                        - type
                        - name
                      x-apidog-ignore-properties: []
                text:
                  type: object
                  description: Output format configuration.
                  properties:
                    format:
                      type: object
                      description: The format the answer must follow.
                      properties:
                        type:
                          type: string
                          description: >-
                            Format type. `text` returns plain text,
                            `json_object` constrains the answer to JSON, and
                            `json_schema` validates it against a schema of your
                            own.
                          enum:
                            - text
                            - json_object
                            - json_schema
                          x-apidog-enum:
                            - value: text
                              name: ''
                              description: ''
                            - value: json_object
                              name: ''
                              description: ''
                            - value: json_schema
                              name: ''
                              description: ''
                        name:
                          type: string
                          description: Schema name. Required when `type` is `json_schema`.
                        description:
                          type: string
                          description: >-
                            Optional description of the schema, to help the
                            model produce the expected output.
                        schema:
                          type: object
                          description: >-
                            The JSON Schema the answer must follow. Required
                            when `type` is `json_schema`.
                          properties: {}
                          x-apidog-orders: []
                          x-apidog-ignore-properties: []
                        strict:
                          type: boolean
                          description: >-
                            Whether to validate the answer strictly against the
                            schema. Only applies to `json_schema`.
                      required:
                        - type
                      x-apidog-orders:
                        - type
                        - name
                        - description
                        - schema
                        - strict
                      x-apidog-ignore-properties: []
                  required:
                    - format
                  x-apidog-orders:
                    - format
                  x-apidog-ignore-properties: []
              required:
                - model
                - input
              x-apidog-orders:
                - model
                - stream
                - input
                - instructions
                - reasoning
                - thinking
                - tools
                - tool_choice
                - text
              x-apidog-ignore-properties: []
            example:
              model: deepseek-v4-1-flash
              stream: false
              input:
                - role: user
                  content:
                    - type: input_text
                      text: What is in this image?
                    - type: input_image
                      image_url: https://example.com/demo.png
      responses:
        '200':
          description: 'Request successful. '
          content:
            text/event-stream:
              schema:
                type: string
                description: >-
                  Streaming responses are sent as Server-Sent Events (SSE) with
                  `Content-Type: text/event-stream`.


                  **Standard output**


                  - **Text delta event**: `event: response.output_text.delta`
                    - `data.delta`: The incremental text content in the stream
                    - `data.type`: Event type, always `response.output_text.delta`
                  - **Completion event**: `event: response.completed`
                    - `data.response.output`: The full list of output items, including reasoning and message
                    - `data.response.usage`: Token usage information, such as `input_tokens` and `output_tokens`

                  **Reasoning**


                  - **Reasoning summary delta event**: `event:
                  response.reasoning_summary_text.delta`
                    - `data.delta`: The incremental reasoning summary content in the stream
                    - `data.type`: Event type, always `response.reasoning_summary_text.delta`

                  **Function Calling**


                  - **Function call arguments delta event**: `event:
                  response.function_call_arguments.delta`
                    - `data.delta`: Incremental string content of the function call arguments
                    - `data.type`: Event type, always `response.function_call_arguments.delta`
                  - **Completion event**: `event: response.completed`
                    - `data.response.output`: Contains a `function_call` item with `call_id`, `name` and `arguments`

                  The stream ends with a response.completed event
                  (response.failed or response.incomplete on failure).
              example: |-
                {
                    "id": "resp_xxx",
                    "object": "response",
                    "created_at": 1790128600,
                    "model": "deepseek-v4-1-flash",
                    "status": "completed",
                    "output": [
                        {
                            "type": "reasoning",
                            "id": "rs_xxx",
                            "status": "completed",
                            "summary": [
                                {
                                    "type": "summary_text",
                                    "text": "The user is asking what is in the image. It shows a cat sitting on a windowsill."
                                }
                            ]
                        },
                        {
                            "type": "message",
                            "id": "msg_xxx",
                            "role": "assistant",
                            "status": "completed",
                            "content": [
                                {
                                    "type": "output_text",
                                    "text": "The image shows a cat sitting on a windowsill.",
                                    "annotations": []
                                }
                            ]
                        }
                    ],
                    "usage": {
                        "input_tokens": 38,
                        "input_tokens_details": {
                            "cached_tokens": 0
                        },
                        "output_tokens": 36,
                        "output_tokens_details": {
                            "reasoning_tokens": 35
                        },
                        "total_tokens": 74
                    },
                    "credits_consumed": 0.01
                }
          headers: {}
          x-apidog-name: ''
        '400':
          description: Bad Request - Invalid request parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        examples:
                          - Invalid request parameters
                      type:
                        type: string
                        examples:
                          - invalid_request_error
                      param:
                        type: string
                        nullable: true
                      code:
                        type: string
                        nullable: true
                    x-apidog-orders:
                      - message
                      - type
                      - param
                      - code
                    x-apidog-ignore-properties: []
                x-apidog-orders:
                  - error
                x-apidog-ignore-properties: []
          headers: {}
          x-apidog-name: ''
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        examples:
                          - Invalid or missing API key
                      type:
                        type: string
                        examples:
                          - authentication_error
                      param:
                        type: string
                        nullable: true
                      code:
                        type: string
                        nullable: true
                    x-apidog-orders:
                      - message
                      - type
                      - param
                      - code
                    x-apidog-ignore-properties: []
                x-apidog-orders:
                  - error
                x-apidog-ignore-properties: []
          headers: {}
          x-apidog-name: ''
        '429':
          description: Rate Limited - Too many requests
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        examples:
                          - Too many requests
                      type:
                        type: string
                        examples:
                          - rate_limit_error
                      param:
                        type: string
                        nullable: true
                      code:
                        type: string
                        nullable: true
                    x-apidog-orders:
                      - message
                      - type
                      - param
                      - code
                    x-apidog-ignore-properties: []
                x-apidog-orders:
                  - error
                x-apidog-ignore-properties: []
          headers: {}
          x-apidog-name: ''
        '500':
          description: Server error.
          content:
            application/json:
              schema:
                type: object
                properties: {}
                x-apidog-orders: []
                x-apidog-ignore-properties: []
          headers: {}
          x-apidog-name: Error
      security:
        - BearerAuth: []
          x-apidog:
            schemeGroups:
              - id: kn8M4YUlc5i0A0179ezwx
                schemeIds:
                  - BearerAuth
            required: true
            use:
              id: kn8M4YUlc5i0A0179ezwx
            scopes:
              kn8M4YUlc5i0A0179ezwx:
                BearerAuth: []
      x-apidog-folder: docs/en/Market/Chat  Models/Deepseek
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/1184766/apis/api-44082505-run
components:
  schemas: {}
  securitySchemes:
    BearerAuth:
      type: bearer
      scheme: bearer
      bearerFormat: API Key
      description: >-
        All API requests require a Bearer Token. Add the header `Authorization:
        Bearer YOUR_API_KEY` to authenticate requests.
    BearerAuth1:
      type: bearer
      scheme: bearer
      bearerFormat: API Key
      description: >-
        所有 API 请求都需要 Bearer Token。请在请求头中添加 `Authorization: Bearer YOUR_API_KEY`
        进行身份验证。
servers:
  - url: https://api.kie.ai
    description: 正式环境
security:
  - BearerAuth: []
    x-apidog:
      schemeGroups:
        - id: kn8M4YUlc5i0A0179ezwx
          schemeIds:
            - BearerAuth
      required: true
      use:
        id: kn8M4YUlc5i0A0179ezwx
      scopes:
        kn8M4YUlc5i0A0179ezwx:
          BearerAuth: []

```
