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

# Anthropic Messages



## OpenAPI

````yaml https://api.deepinfra.com/openapi.json post /anthropic/v1/messages
openapi: 3.1.0
info:
  title: DeepInfra API
  description: >-
    The DeepInfra API provides serverless AI inference, custom model
    deployments, and GPU rentals.
  version: 1.0.0
servers:
  - url: https://api.deepinfra.com
security: []
tags:
  - name: Chat Completions
    description: OpenAI and Anthropic-compatible chat completion endpoints for LLMs.
  - name: Text Completions
    description: OpenAI-compatible text completion endpoints.
  - name: Embeddings
    description: Generate text embeddings for search and RAG.
  - name: Image Generation
    description: Generate, edit, and create variations of images.
  - name: Audio
    description: OpenAI-compatible speech synthesis, transcription, and translation.
  - name: Text to Speech
    description: ElevenLabs-compatible TTS endpoints and voice management.
  - name: Inference
    description: Native DeepInfra inference API for models and deployments.
  - name: Dedicated Models
    description: Deploy and manage private model instances with autoscaling.
  - name: GPU Rentals
    description: Rent dedicated GPU containers.
  - name: Models
    description: Browse, search, and manage AI models.
  - name: Files & Batches
    description: File uploads and batch processing.
  - name: LoRA Adapters
    description: Create, manage, and query LoRA adapter models.
  - name: Agents
    description: Manage agent-framework instances (OpenClaw and friends).
  - name: Sandboxes
    description: Create and manage isolated sandbox environments.
  - name: Account
    description: User profile, team management, rate limits, and GPU pool limits.
  - name: Authentication
    description: API tokens, SSH keys, scoped JWTs, and login flows.
  - name: Billing
    description: Payment methods, usage tracking, and billing.
  - name: Logs & Metrics
    description: Query inference logs, deployment logs, and usage metrics.
  - name: Utilities
    description: Feedback submission and CLI version.
paths:
  /anthropic/v1/messages:
    post:
      tags:
        - Chat Completions
      summary: Anthropic Messages
      operationId: anthropic_messages_anthropic_v1_messages_post
      parameters:
        - name: anthropic-version
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Anthropic-Version
        - name: anthropic-beta
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Anthropic-Beta
        - name: x-deepinfra-source
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Deepinfra-Source
        - name: x-deepinfra-service-tier
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Per-request service tier (`priority` or `flex`) for clients that
              cannot set the `service_tier` body field. The body field wins when
              both are present; unrecognized values ride the default tier.
            title: X-Deepinfra-Service-Tier
          description: >-
            Per-request service tier (`priority` or `flex`) for clients that
            cannot set the `service_tier` body field. The body field wins when
            both are present; unrecognized values ride the default tier.
        - name: xi-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Xi-Api-Key
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnthropicMessagesIn'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    AnthropicMessagesIn:
      properties:
        service_tier:
          anyOf:
            - $ref: '#/components/schemas/ServiceTier'
            - type: 'null'
          description: >-
            The service tier used for processing the request. 'priority'
            processes the request with higher priority (premium rate); 'flex'
            processes it at lower priority for a discount, served only when
            spare capacity exists and may be retried/timed out under load. Both
            apply only to models that support the respective tier. For
            compatibility, 'auto' is treated as 'priority' and 'standard_only'
            as 'default'.
        fail_fast:
          type: boolean
          title: Fail Fast
          description: >-
            If true, the request is rejected immediately with HTTP 429 when the
            model has no spare capacity, instead of waiting in the queue.
            Opt-in; the default (false) keeps standard queueing behavior.
          default: false
        models:
          anyOf:
            - items:
                type: string
              type: array
              maxItems: 4
              minItems: 1
            - type: 'null'
          title: Models
          description: >-
            Ordered list of up to 4 fallback models. The request is attempted on
            each model in order: when a model rejects it for lack of capacity
            (HTTP 429 model-busy / flex no-capacity), the next model is tried
            server-side. The first model that accepts serves the request; the
            response's model field and billing reflect that model, at that
            model's pricing. Models before the last are attempted without
            queueing (as if fail_fast were set); the last model honors the
            request's own fail_fast value. When models is set, the model field
            is ignored. Entries must be plain model names (no deploy_id:,
            custom_hostport, or :revision specifiers); duplicate entries are
            ignored, keeping the first occurrence.
        model:
          type: string
          title: Model
        max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Tokens
        messages:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Messages
        system:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/AnthropicSystemContent'
              type: array
            - type: 'null'
          title: System
        stop_sequences:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Stop Sequences
        stream:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Stream
          default: false
        temperature:
          anyOf:
            - type: number
            - type: 'null'
          title: Temperature
          default: 1
        top_p:
          anyOf:
            - type: number
            - type: 'null'
          title: Top P
        top_k:
          anyOf:
            - type: integer
            - type: 'null'
          title: Top K
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
        tools:
          anyOf:
            - items:
                $ref: '#/components/schemas/AnthropicTool'
              type: array
            - type: 'null'
          title: Tools
        tool_choice:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Tool Choice
        thinking:
          anyOf:
            - $ref: '#/components/schemas/AnthropicThinkingConfig'
            - type: 'null'
        prompt_cache_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Prompt Cache Key
      type: object
      required:
        - model
        - messages
      title: AnthropicMessagesIn
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ServiceTier:
      type: string
      enum:
        - default
        - priority
        - flex
      title: ServiceTier
    AnthropicSystemContent:
      properties:
        type:
          type: string
          const: text
          title: Type
        text:
          type: string
          title: Text
      type: object
      required:
        - type
        - text
      title: AnthropicSystemContent
    AnthropicTool:
      properties:
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        input_schema:
          additionalProperties: true
          type: object
          title: Input Schema
      type: object
      required:
        - name
        - input_schema
      title: AnthropicTool
    AnthropicThinkingConfig:
      properties:
        type:
          anyOf:
            - type: string
              enum:
                - enabled
                - disabled
                - adaptive
            - type: 'null'
          title: Type
        budget_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Budget Tokens
        enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Enabled
      type: object
      title: AnthropicThinkingConfig
      description: >-
        Anthropic `thinking` config: {type: enabled|disabled|adaptive,
        budget_tokens}.


        `enabled` is a legacy pre-spec field this endpoint used to accept; it
        only

        applies when `type` is absent.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.