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

# DeepSeek R1

> Create a chat completion for given messages with streaming support using DeepSeek's R1 model, optimized for advanced reasoning and problem-solving tasks



## OpenAPI

````yaml /openapi-specs/playground/deepseek-r1.yaml POST /chat/completions
openapi: 3.1.0
info:
  title: DeepSeek R1 API
  description: >-
    DeepSeek R1 Language Model API for advanced reasoning, conversational AI,
    and text generation tasks
  version: 1.0.0
servers:
  - url: https://http.llm.model-cluster.on-prem.clusters.yotta-uat.cluster.s9t.link
    description: Production LLM Proxy Server
security:
  - BearerAuth: []
tags:
  - name: Chat Completion
    description: DeepSeek R1 language model chat completion services
paths:
  /chat/completions:
    post:
      tags:
        - Chat Completion
      summary: Create chat completion with DeepSeek R1
      description: >-
        Create a chat completion for given messages with streaming support using
        DeepSeek's R1 model, optimized for advanced reasoning and
        problem-solving tasks
      operationId: createChatCompletionDeepSeekR1
      parameters:
        - in: header
          name: id
          schema:
            type: string
            default: 018037b8-90fe-47f6-b131-33de9fbe79ab
          required: true
          description: Model UUID for the request (DeepSeek R1 model identifier)
          example: 018037b8-90fe-47f6-b131-33de9fbe79ab
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                messages:
                  type: array
                  description: Array of messages in the conversation
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                        description: The role of the message sender
                      content:
                        type: string
                        description: The content of the message
                    required:
                      - role
                      - content
                model:
                  type: string
                  description: Model identifier for DeepSeek R1
                  enum:
                    - deepseek-r1
                  default: deepseek-r1
                stream:
                  type: boolean
                  description: Whether to stream the response
                  default: false
                temperature:
                  type: number
                  description: >-
                    Sampling temperature (0.0 to 2.0). Controls randomness in
                    generation
                  minimum: 0
                  maximum: 2
                  default: 0.7
                max_tokens:
                  type: integer
                  description: Maximum number of tokens to generate
                  minimum: 1
                  maximum: 4096
                  default: 1024
                top_p:
                  type: number
                  description: >-
                    Nucleus sampling parameter for controlling response
                    diversity
                  minimum: 0
                  maximum: 1
                  default: 1
                top_k:
                  type: integer
                  description: Top-k sampling parameter for vocabulary selection
                  minimum: 1
                  maximum: 100
                  default: 50
                stop:
                  type: array
                  description: Sequences where the API will stop generating further tokens
                  items:
                    type: string
                  maxItems: 4
                  nullable: true
                frequency_penalty:
                  type: number
                  description: Penalty for frequent tokens to reduce repetition
                  minimum: -2
                  maximum: 2
                  default: 0
                presence_penalty:
                  type: number
                  description: Penalty for new tokens to encourage topic diversity
                  minimum: -2
                  maximum: 2
                  default: 0
                repetition_penalty:
                  type: number
                  description: Penalty for repeating tokens (DeepSeek-specific parameter)
                  minimum: 0.1
                  maximum: 2
                  default: 1
                do_sample:
                  type: boolean
                  description: Whether to use sampling for generation
                  default: true
                seed:
                  type: integer
                  description: Random seed for reproducible outputs
                  nullable: true
                system_prompt:
                  type: string
                  description: >-
                    System prompt to set model behavior (alternative to system
                    message)
                  nullable: true
              required:
                - messages
                - model
            examples:
              database_query:
                summary: Database operation question
                value:
                  model: deepseek-r1
                  messages:
                    - role: user
                      content: >-
                        How do I delete a team member from an org given user and
                        org tables?
                  stream: true
                  max_tokens: 1024
                  temperature: 0.7
                  top_p: 1
              reasoning_task:
                summary: Complex reasoning problem
                value:
                  model: deepseek-r1
                  messages:
                    - role: system
                      content: >-
                        You are an expert problem solver with advanced reasoning
                        capabilities.
                    - role: user
                      content: >-
                        Solve this step by step: A company has 3 departments.
                        Department A has twice as many employees as B, and C has
                        10 more than A. If the total is 85 employees, how many
                        are in each department?
                  stream: false
                  temperature: 0.3
                  max_tokens: 2048
                  top_p: 0.9
              code_generation:
                summary: Code generation task
                value:
                  model: deepseek-r1
                  messages:
                    - role: user
                      content: >-
                        Write a Python function to implement binary search with
                        detailed comments
                  stream: true
                  temperature: 0.5
                  max_tokens: 1536
                  top_p: 0.95
              mathematical_reasoning:
                summary: Mathematical problem solving
                value:
                  model: deepseek-r1
                  messages:
                    - role: user
                      content: >-
                        Prove that the square root of 2 is irrational using a
                        proof by contradiction
                  stream: false
                  temperature: 0.2
                  max_tokens: 2048
                  top_p: 0.9
              multi_turn_reasoning:
                summary: Multi-turn reasoning conversation
                value:
                  model: deepseek-r1
                  messages:
                    - role: user
                      content: >-
                        I need to optimize a database query that's running
                        slowly.
                    - role: assistant
                      content: >-
                        I'd be happy to help optimize your database query. Could
                        you provide the query and tell me what database system
                        you're using?
                    - role: user
                      content: >-
                        It's PostgreSQL. The query joins 3 tables and takes 30
                        seconds: SELECT * FROM users u JOIN orders o ON u.id =
                        o.user_id JOIN products p ON o.product_id = p.id WHERE
                        u.created_at > '2024-01-01'
                  stream: true
                  temperature: 0.4
                  max_tokens: 1024
      responses:
        '200':
          description: Successful chat completion
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ChatCompletionResponse'
                  - $ref: '#/components/schemas/ChatCompletionChunk'
            text/event-stream:
              schema:
                type: string
                description: Server-sent events for streaming responses
              example: >
                data:
                {"id":"chatcmpl-deepseek-r1-abc123","object":"chat.completion.chunk","created":1699014493,"model":"deepseek-r1","choices":[{"index":0,"delta":{"content":"To
                delete"},"finish_reason":null}]}


                data:
                {"id":"chatcmpl-deepseek-r1-abc123","object":"chat.completion.chunk","created":1699014493,"model":"deepseek-r1","choices":[{"index":0,"delta":{"content":"
                a team member"},"finish_reason":null}]}
        '400':
          description: Bad Request - Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                invalid_model:
                  summary: Invalid model specified
                  value:
                    error:
                      message: Invalid model specified. Expected 'deepseek-r1'
                      type: invalid_request_error
                      code: invalid_model
                token_limit_exceeded:
                  summary: Token limit exceeded
                  value:
                    error:
                      message: max_tokens cannot exceed 4096
                      type: invalid_request_error
                      code: invalid_parameter
                      param: max_tokens
                empty_messages:
                  summary: Empty messages array
                  value:
                    error:
                      message: messages array cannot be empty
                      type: invalid_request_error
                      code: invalid_parameter
                      param: messages
        '401':
          description: Unauthorized - Invalid or missing authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too Many Requests - Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: Bad Gateway - DeepSeek model service unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Service Unavailable - Model temporarily overloaded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ChatCompletionResponse:
      type: object
      description: Response for non-streaming chat completion
      properties:
        id:
          type: string
          description: Unique identifier for the completion
          example: chatcmpl-deepseek-r1-abc123
        object:
          type: string
          enum:
            - chat.completion
          description: Object type
          example: chat.completion
        created:
          type: integer
          description: Unix timestamp of when the completion was created
          example: 1699014493
        model:
          type: string
          description: The model used for completion
          example: deepseek-r1
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
                description: Index of the choice
                example: 0
              message:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - assistant
                    description: Role of the message sender
                    example: assistant
                  content:
                    type: string
                    description: Generated text content
                    example: >-
                      To delete a team member from an organization, you'll need
                      to perform a DELETE operation. Here's how you can approach
                      this...
                required:
                  - role
                  - content
              finish_reason:
                type: string
                enum:
                  - stop
                  - length
                  - content_filter
                  - tool_calls
                description: Reason for finishing the generation
                example: stop
            required:
              - index
              - message
              - finish_reason
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
              description: Number of tokens in the prompt
              example: 18
            completion_tokens:
              type: integer
              description: Number of tokens in the completion
              example: 156
            total_tokens:
              type: integer
              description: Total number of tokens used
              example: 174
          required:
            - prompt_tokens
            - completion_tokens
            - total_tokens
        system_fingerprint:
          type: string
          description: System fingerprint for the model version
          example: deepseek-r1-v1.0
          nullable: true
    ChatCompletionChunk:
      type: object
      description: Response chunk for streaming chat completion
      properties:
        id:
          type: string
          description: Unique identifier for the completion
          example: chatcmpl-deepseek-r1-abc123
        object:
          type: string
          enum:
            - chat.completion.chunk
          description: Object type
          example: chat.completion.chunk
        created:
          type: integer
          description: Unix timestamp of when the completion was created
          example: 1699014493
        model:
          type: string
          description: The model used for completion
          example: deepseek-r1
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
                description: Index of the choice
                example: 0
              delta:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - assistant
                    description: Role of the message sender (only in first chunk)
                    example: assistant
                  content:
                    type: string
                    description: Generated text content chunk
                    nullable: true
                    example: ' a team member'
              finish_reason:
                type: string
                enum:
                  - stop
                  - length
                  - content_filter
                  - tool_calls
                description: Reason for finishing the generation (only in last chunk)
                nullable: true
                example: null
            required:
              - index
              - delta
        system_fingerprint:
          type: string
          description: System fingerprint for the model version
          example: deepseek-r1-v1.0
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error message
              example: Invalid model specified
            type:
              type: string
              description: Error type classification
              example: invalid_request_error
              enum:
                - invalid_request_error
                - authentication_error
                - rate_limit_error
                - server_error
                - model_error
            code:
              type: string
              description: Specific error code
              example: invalid_model
            param:
              type: string
              description: Parameter that caused the error (if applicable)
              example: model
              nullable: true
          required:
            - message
            - type
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token for authentication - Use your API token as the Bearer token

````