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

# Chat

> Use DeerAPI to call the Chat endpoint with request details, response details, examples, and an OpenAPI playground.

## Overview

Use this endpoint to call the Chat workflow through DeerAPI. The API reference on this page shows the request schema, response schema, authentication requirements, and runnable examples for the configured endpoint.

## Before you start

Use the DeerAPI base URL and pass your API Key in the `Authorization` header:

```text theme={null}
https://api.deerapi.com
```

```text theme={null}
Authorization: Bearer $DEERAPI_KEY
```

## Model selection

Choose a current model ID from the [live pricing page](https://api.deerapi.com/pricing). Model availability changes over time, so avoid copying a model ID from an old project without checking the live list first.

## Implementation notes

* Use the OpenAPI playground for the exact request fields accepted by this endpoint.
* Keep API Keys on the server side when you build production applications.
* Log the request ID from failed calls so support can investigate the request.
* Retry `429`, `500`, and `503` responses with exponential backoff.


## OpenAPI

````yaml /api/openapi/text/openai/post-chat.openapi.json POST /v1/chat/completions
openapi: 3.1.0
info:
  title: Chat Completions API
  version: 1.0.0
servers:
  - url: https://api.deerapi.com
security:
  - bearerAuth: []
paths:
  /v1/chat/completions:
    post:
      summary: Chat Completions
      operationId: chat_completions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Use this field according to the endpoint schema.
              additionalProperties: true
              required:
                - model
                - messages
              properties:
                model:
                  type: string
                  description: Use this field according to the endpoint schema.
                  default: gpt-5.4
                messages:
                  type: array
                  description: Use this field according to the endpoint schema.
                  items:
                    type: object
                    required:
                      - role
                      - content
                    properties:
                      role:
                        type: string
                        description: Use this field according to the endpoint schema.
                        enum:
                          - system
                          - user
                          - assistant
                          - tool
                          - developer
                      content:
                        type:
                          - string
                          - array
                        description: Use this field according to the endpoint schema.
                        items:
                          type: object
                          properties:
                            type:
                              type: string
                              description: Use this field according to the endpoint schema.
                            text:
                              type: string
                              description: Use this field according to the endpoint schema.
                            image_url:
                              type: object
                              description: Use this field according to the endpoint schema.
                              properties:
                                url:
                                  type: string
                                  description: >-
                                    Use this field according to the endpoint
                                    schema.
                            input_audio:
                              type: object
                              description: Use this field according to the endpoint schema.
                              properties:
                                data:
                                  type: string
                                  description: >-
                                    Use this field according to the endpoint
                                    schema.
                                format:
                                  type: string
                                  description: >-
                                    Use this field according to the endpoint
                                    schema.
                      tool_call_id:
                        type: string
                        description: Use this field according to the endpoint schema.
                      name:
                        type: string
                        description: Use this field according to the endpoint schema.
                  default:
                    - role: system
                      content: You are a helpful assistant.
                    - role: user
                      content: Hello!
                stream:
                  type: boolean
                  description: Use this field according to the endpoint schema.
                temperature:
                  type: number
                  description: Use this field according to the endpoint schema.
                  minimum: 0
                  maximum: 2
                top_p:
                  type: number
                  description: Use this field according to the endpoint schema.
                  minimum: 0
                  maximum: 1
                max_completion_tokens:
                  type: integer
                  description: Use this field according to the endpoint schema.
                max_tokens:
                  type: integer
                  description: Use this field according to the endpoint schema.
                  deprecated: true
                presence_penalty:
                  type: number
                  description: Use this field according to the endpoint schema.
                frequency_penalty:
                  type: number
                  description: Use this field according to the endpoint schema.
                stop:
                  description: Use this field according to the endpoint schema.
                tools:
                  type: array
                  description: Use this field according to the endpoint schema.
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        description: Use this field according to the endpoint schema.
                      function:
                        type: object
                        description: Use this field according to the endpoint schema.
                        properties:
                          name:
                            type: string
                            description: Use this field according to the endpoint schema.
                          description:
                            type: string
                            description: Use this field according to the endpoint schema.
                          parameters:
                            type: object
                            description: Use this field according to the endpoint schema.
                tool_choice:
                  description: Use this field according to the endpoint schema.
                response_format:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    type:
                      type: string
                      description: Use this field according to the endpoint schema.
                    json_schema:
                      type: object
                      description: Use this field according to the endpoint schema.
                modalities:
                  type: array
                  description: Use this field according to the endpoint schema.
                  items:
                    type: string
                    enum:
                      - text
                      - audio
                audio:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    voice:
                      type: string
                      description: Use this field according to the endpoint schema.
                    format:
                      type: string
                      description: Use this field according to the endpoint schema.
                stream_options:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    include_usage:
                      type: boolean
                      description: Use this field according to the endpoint schema.
                metadata:
                  type: object
                  description: Use this field according to the endpoint schema.
                reasoning_effort:
                  type: string
                  description: Use this field according to the endpoint schema.
                  enum:
                    - none
                    - minimal
                    - low
                    - medium
                    - high
                    - xhigh
                'n':
                  type: integer
                  description: Use this field according to the endpoint schema.
                  minimum: 1
                  maximum: 128
                logprobs:
                  type: boolean
                  description: Use this field according to the endpoint schema.
                top_logprobs:
                  type: integer
                  description: Use this field according to the endpoint schema.
                  minimum: 0
                  maximum: 20
                logit_bias:
                  type: object
                  description: Use this field according to the endpoint schema.
                  additionalProperties: true
                parallel_tool_calls:
                  type: boolean
                  description: Use this field according to the endpoint schema.
                prediction:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    type:
                      type: string
                    content:
                      type: string
                store:
                  type: boolean
                  description: Use this field according to the endpoint schema.
                safety_identifier:
                  type: string
                  description: Use this field according to the endpoint schema.
                service_tier:
                  type: string
                  description: Use this field according to the endpoint schema.
                  enum:
                    - auto
                    - default
                    - flex
                    - priority
                verbosity:
                  type: string
                  description: Use this field according to the endpoint schema.
                  enum:
                    - low
                    - medium
                    - high
                web_search_options:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    search_context_size:
                      type: string
                      description: Use this field according to the endpoint schema.
                    user_location:
                      type: object
                      description: Use this field according to the endpoint schema.
                prompt_cache_key:
                  type: string
                  description: Use this field according to the endpoint schema.
                prompt_cache_retention:
                  type: string
                  description: Use this field according to the endpoint schema.
                  enum:
                    - in-memory
                    - 24h
                user:
                  type: string
                  description: Use this field according to the endpoint schema.
                  deprecated: true
              default:
                model: gpt-5.4
                messages:
                  - role: system
                    content: You are a helpful assistant.
                  - role: user
                    content: Hello!
            examples:
              Default:
                summary: Default
                value:
                  model: gpt-5.4
                  messages:
                    - role: system
                      content: You are a helpful assistant.
                    - role: user
                      content: Hello!
              Structured_Output:
                summary: Chat Completions API
                value:
                  model: gpt-5-mini
                  messages:
                    - role: user
                      content: Hello!
                  response_format:
                    type: json_schema
                    json_schema:
                      name: doc_snippet
                      schema:
                        type: object
                        properties:
                          title:
                            type: string
                          summary:
                            type: string
                        required:
                          - title
                          - summary
                        additionalProperties: false
              Streaming_Response:
                summary: Chat Completions API
                value:
                  model: gpt-5-mini
                  messages:
                    - role: system
                      content: You are a helpful assistant.
                    - role: user
                      content: Hello!
                  stream: true
              Function_Calling:
                summary: Chat Completions API
                value:
                  model: gpt-4.1
                  messages:
                    - role: user
                      content: Hello!
                  tools:
                    - type: function
                      function:
                        name: get_weather
                        description: Use this field according to the endpoint schema.
                        parameters:
                          type: object
                          properties:
                            city:
                              type: string
                              description: Use this field according to the endpoint schema.
                          required:
                            - city
                  tool_choice: auto
            example:
              model: gpt-5.4
              messages:
                - role: system
                  content: You are a helpful assistant.
                - role: user
                  content: Hello!
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - object
                  - created
                  - model
                  - system_fingerprint
                  - choices
                  - usage
                properties:
                  id:
                    type: string
                    description: Use this field according to the endpoint schema.
                  object:
                    type: string
                    description: Use this field according to the endpoint schema.
                  created:
                    type: integer
                    description: Use this field according to the endpoint schema.
                  model:
                    type: string
                    description: Use this field according to the endpoint schema.
                  system_fingerprint:
                    type: string
                    description: Use this field according to the endpoint schema.
                  service_tier:
                    type: string
                    description: Use this field according to the endpoint schema.
                  choices:
                    type: array
                    description: Use this field according to the endpoint schema.
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                          description: Use this field according to the endpoint schema.
                        message:
                          type: object
                          description: Use this field according to the endpoint schema.
                          properties:
                            content:
                              type:
                                - string
                                - 'null'
                              description: Use this field according to the endpoint schema.
                            refusal:
                              type:
                                - string
                                - 'null'
                              description: Use this field according to the endpoint schema.
                            role:
                              type: string
                              description: Use this field according to the endpoint schema.
                            annotations:
                              type: array
                              description: Use this field according to the endpoint schema.
                              items:
                                type: object
                            tool_calls:
                              type: array
                              description: Use this field according to the endpoint schema.
                              items:
                                type: object
                        finish_reason:
                          type: string
                          description: Use this field according to the endpoint schema.
                  usage:
                    type: object
                    description: Use this field according to the endpoint schema.
                    required:
                      - completion_tokens
                      - completion_tokens_details
                      - prompt_tokens
                      - prompt_tokens_details
                      - total_tokens
                    properties:
                      completion_tokens:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      completion_tokens_details:
                        type: object
                        description: Use this field according to the endpoint schema.
                        properties:
                          reasoning_tokens:
                            type: integer
                            description: Use this field according to the endpoint schema.
                          audio_tokens:
                            type: integer
                            description: Use this field according to the endpoint schema.
                          accepted_prediction_tokens:
                            type: integer
                            description: Use this field according to the endpoint schema.
                          rejected_prediction_tokens:
                            type: integer
                            description: Use this field according to the endpoint schema.
                      prompt_tokens:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      prompt_tokens_details:
                        type: object
                        description: Use this field according to the endpoint schema.
                        properties:
                          cached_tokens:
                            type: integer
                            description: Use this field according to the endpoint schema.
                          audio_tokens:
                            type: integer
                            description: Use this field according to the endpoint schema.
                      total_tokens:
                        type: integer
                        description: Use this field according to the endpoint schema.
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |
            curl https://api.deerapi.com/v1/chat/completions \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $DEERAPI_KEY" \
              -d '{
                "model": "gpt-5.4",
                "messages": [
                  {
                    "role": "system",
                    "content": "You are a helpful assistant."
                  },
                  {
                    "role": "user",
                    "content": "Hello!"
                  }
                ]
              }'
        - lang: Python
          label: requests
          source: |
            import os
            import requests

            url = "https://api.deerapi.com/v1/chat/completions"
            headers = {
                "Authorization": "Bearer " + os.environ["DEERAPI_KEY"],
                "Content-Type": "application/json",
            }
            payload = {
              "model": "gpt-5.4",
              "messages": [
                {
                  "role": "system",
                  "content": "You are a helpful assistant."
                },
                {
                  "role": "user",
                  "content": "Hello!"
                }
              ]
            }

            response = requests.post(url, headers=headers, json=payload)
            print(response.json())
        - lang: JavaScript
          label: fetch
          source: >
            const response = await
            fetch("https://api.deerapi.com/v1/chat/completions", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.DEERAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "model": "gpt-5.4",
                "messages": [
                  {
                    "role": "system",
                    "content": "You are a helpful assistant."
                  },
                  {
                    "role": "user",
                    "content": "Hello!"
                  }
                ]
              }),
            });


            console.log(await response.json());
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Use a DeerAPI API Key as a Bearer token.

````