> ## 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.

# Anthropic Messages

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

## Overview

Use this endpoint to call the Anthropic Messages 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/anthropic/post-anthropic-messages.openapi.json POST /v1/messages
openapi: 3.1.0
info:
  title: Anthropic Claude API
  version: 1.0.0
servers:
  - url: https://api.deerapi.com
security:
  - bearerAuth: []
paths:
  /v1/messages:
    post:
      summary: Anthropic Claude
      operationId: anthropic_claude
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Use this field according to the endpoint schema.
              additionalProperties: true
              required:
                - model
                - messages
                - max_tokens
              properties:
                model:
                  type: string
                  description: Use this field according to the endpoint schema.
                  default: claude-sonnet-4-6
                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:
                          - user
                          - assistant
                      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.
                            source:
                              type: object
                              description: Use this field according to the endpoint schema.
                              additionalProperties: true
                            tool_use_id:
                              type: string
                              description: Use this field according to the endpoint schema.
                            content:
                              description: Use this field according to the endpoint schema.
                            cache_control:
                              type: object
                              description: Use this field according to the endpoint schema.
                              additionalProperties: true
                          additionalProperties: true
                    additionalProperties: true
                  default:
                    - role: user
                      content: >-
                        Summarize the benefits of retry logic for production API
                        clients.
                max_tokens:
                  type: integer
                  description: Use this field according to the endpoint schema.
                  default: 1024
                cache_control:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    type:
                      type: string
                      description: Use this field according to the endpoint schema.
                      enum:
                        - ephemeral
                    ttl:
                      type: integer
                      description: Use this field according to the endpoint schema.
                  additionalProperties: true
                container:
                  type: string
                  description: Use this field according to the endpoint schema.
                inference_geo:
                  type: string
                  description: Use this field according to the endpoint schema.
                context_management:
                  type:
                    - object
                    - 'null'
                  description: Use this field according to the endpoint schema.
                  additionalProperties: true
                mcp_servers:
                  type: array
                  description: Use this field according to the endpoint schema.
                  items:
                    type: object
                    additionalProperties: true
                metadata:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    user_id:
                      type: string
                      description: Use this field according to the endpoint schema.
                  additionalProperties: true
                output_config:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    effort:
                      type: string
                      description: Use this field according to the endpoint schema.
                      enum:
                        - low
                        - medium
                        - high
                    format:
                      type: object
                      description: Use this field according to the endpoint schema.
                      additionalProperties: true
                  additionalProperties: true
                service_tier:
                  type: string
                  description: Use this field according to the endpoint schema.
                  enum:
                    - auto
                    - standard_only
                stop_sequences:
                  type: array
                  description: Use this field according to the endpoint schema.
                  items:
                    type: string
                stream:
                  type: boolean
                  description: Use this field according to the endpoint schema.
                system:
                  type:
                    - string
                    - array
                  description: Use this field according to the endpoint schema.
                temperature:
                  type: number
                  description: Use this field according to the endpoint schema.
                  minimum: 0
                  maximum: 1
                thinking:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    type:
                      type: string
                      description: Use this field according to the endpoint schema.
                      enum:
                        - enabled
                        - disabled
                    budget_tokens:
                      type: integer
                      description: Use this field according to the endpoint schema.
                  additionalProperties: true
                tool_choice:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    type:
                      type: string
                      description: Use this field according to the endpoint schema.
                      enum:
                        - auto
                        - any
                        - tool
                        - none
                    name:
                      type: string
                      description: Use this field according to the endpoint schema.
                    disable_parallel_tool_use:
                      type: boolean
                      description: Use this field according to the endpoint schema.
                  additionalProperties: true
                tools:
                  type: array
                  description: Use this field according to the endpoint schema.
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        description: Use this field according to the endpoint schema.
                      type:
                        type: string
                        description: Use this field according to the endpoint schema.
                      description:
                        type: string
                        description: Use this field according to the endpoint schema.
                      input_schema:
                        type: object
                        description: Use this field according to the endpoint schema.
                    additionalProperties: true
                top_k:
                  type: integer
                  description: Use this field according to the endpoint schema.
                top_p:
                  type: number
                  description: Use this field according to the endpoint schema.
                  minimum: 0
                  maximum: 1
              default:
                model: claude-sonnet-4-6
                messages:
                  - role: user
                    content: >-
                      Summarize the benefits of retry logic for production API
                      clients.
                max_tokens: 1024
            examples:
              Default:
                summary: Anthropic Claude API
                value:
                  max_tokens: 1024
                  system: You are a concise technical assistant.
                  messages:
                    - content: >-
                        Summarize the benefits of retry logic for production API
                        clients.
                      role: user
                  model: claude-sonnet-4-6
              Prompt_Caching:
                summary: Anthropic Claude API
                value:
                  model: claude-sonnet-4-6
                  max_tokens: 1024
                  system:
                    - type: text
                      text: >-
                        Summarize the benefits of retry logic for production API
                        clients.
                      cache_control:
                        type: ephemeral
                  messages:
                    - role: user
                      content: >-
                        Summarize the benefits of retry logic for production API
                        clients.
              Thinking_Control:
                summary: Anthropic Claude API
                value:
                  model: claude-sonnet-4-6
                  max_tokens: 16000
                  thinking:
                    type: enabled
                    budget_tokens: 10000
                  messages:
                    - role: user
                      content: >-
                        Summarize the benefits of retry logic for production API
                        clients.
              Streaming_Response:
                summary: Anthropic Claude API
                value:
                  model: claude-sonnet-4-6
                  messages:
                    - role: user
                      content: >-
                        Summarize the benefits of retry logic for production API
                        clients.
                  max_tokens: 256
                  stream: true
              Web fetch:
                summary: Web fetch
                value:
                  model: claude-sonnet-4-6
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: >-
                        Summarize the benefits of retry logic for production API
                        clients.
                  tools:
                    - type: web_fetch_20260309
                      name: web_fetch
                      max_uses: 5
                      use_cache: auto
              Web Search:
                summary: Web Search
                value:
                  model: claude-sonnet-4-6
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: >-
                        Summarize the benefits of retry logic for production API
                        clients.
                  tools:
                    - type: web_search_20250305
                      name: web_search
                      max_uses: 5
              Effort_Control:
                summary: Anthropic Claude API
                value:
                  model: claude-sonnet-4-6
                  max_tokens: 4096
                  output_config:
                    effort: low
                  messages:
                    - role: user
                      content: >-
                        Summarize the benefits of retry logic for production API
                        clients.
            example:
              max_tokens: 1024
              system: You are a concise technical assistant.
              messages:
                - content: >-
                    Summarize the benefits of retry logic for production API
                    clients.
                  role: user
              model: claude-sonnet-4-6
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - type
                  - role
                  - model
                  - content
                  - stop_reason
                  - usage
                properties:
                  id:
                    type: string
                    description: Use this field according to the endpoint schema.
                  type:
                    type: string
                    description: Use this field according to the endpoint schema.
                    enum:
                      - message
                  role:
                    type: string
                    description: Use this field according to the endpoint schema.
                    enum:
                      - assistant
                  container:
                    type: object
                    description: Use this field according to the endpoint schema.
                    properties:
                      id:
                        type: string
                        description: Use this field according to the endpoint schema.
                      expires_at:
                        type: string
                        description: Use this field according to the endpoint schema.
                  model:
                    type: string
                    description: Use this field according to the endpoint schema.
                  content:
                    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.
                          enum:
                            - text
                            - thinking
                            - tool_use
                        text:
                          type: string
                          description: Use this field according to the endpoint schema.
                        thinking:
                          type: string
                          description: Use this field according to the endpoint schema.
                        signature:
                          type: string
                          description: Use this field according to the endpoint schema.
                        id:
                          type: string
                          description: Use this field according to the endpoint schema.
                        name:
                          type: string
                          description: Use this field according to the endpoint schema.
                        input:
                          type: object
                          description: Use this field according to the endpoint schema.
                        citations:
                          type: array
                          description: Use this field according to the endpoint schema.
                          items:
                            type: object
                            additionalProperties: true
                  stop_reason:
                    type: string
                    description: Use this field according to the endpoint schema.
                    enum:
                      - end_turn
                      - max_tokens
                      - stop_sequence
                      - tool_use
                      - pause_turn
                      - refusal
                  stop_sequence:
                    type:
                      - string
                      - 'null'
                    description: Use this field according to the endpoint schema.
                  usage:
                    type: object
                    description: Use this field according to the endpoint schema.
                    required:
                      - input_tokens
                      - output_tokens
                    properties:
                      input_tokens:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      output_tokens:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      cache_creation_input_tokens:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      cache_read_input_tokens:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      cache_creation:
                        type: object
                        description: Use this field according to the endpoint schema.
                        properties:
                          ephemeral_5m_input_tokens:
                            type: integer
                            description: Use this field according to the endpoint schema.
                          ephemeral_1h_input_tokens:
                            type: integer
                            description: Use this field according to the endpoint schema.
                      inference_geo:
                        type: string
                        description: Use this field according to the endpoint schema.
                      server_tool_use:
                        type: object
                        description: Use this field according to the endpoint schema.
                        properties:
                          web_search_requests:
                            type: integer
                            description: Use this field according to the endpoint schema.
                          web_fetch_requests:
                            type: integer
                            description: Use this field according to the endpoint schema.
                      service_tier:
                        type: string
                        description: Use this field according to the endpoint schema.
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |
            curl https://api.deerapi.com/v1/messages \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $DEERAPI_KEY" \
              -d '{
                "max_tokens": 1024,
                "system": "You are a concise technical assistant.",
                "messages": [
                  {
                    "content": "Summarize the benefits of retry logic for production API clients.",
                    "role": "user"
                  }
                ],
                "model": "claude-sonnet-4-6"
              }'
        - lang: Python
          label: requests
          source: |
            import os
            import requests

            url = "https://api.deerapi.com/v1/messages"
            headers = {
                "Authorization": "Bearer " + os.environ["DEERAPI_KEY"],
                "Content-Type": "application/json",
            }
            payload = {
              "max_tokens": 1024,
              "system": "You are a concise technical assistant.",
              "messages": [
                {
                  "content": "Summarize the benefits of retry logic for production API clients.",
                  "role": "user"
                }
              ],
              "model": "claude-sonnet-4-6"
            }

            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/messages",
            {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.DEERAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "max_tokens": 1024,
                "system": "You are a concise technical assistant.",
                "messages": [
                  {
                    "content": "Summarize the benefits of retry logic for production API clients.",
                    "role": "user"
                  }
                ],
                "model": "claude-sonnet-4-6"
              }),
            });


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

````