POST
/
v1
/
messages
curl -X POST https://www.anyfast.ai/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-4-5-20251001",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "document",
            "source": {
              "type": "base64",
              "media_type": "application/pdf",
              "data": "<BASE64_PDF_DATA>"
            },
            "cache_control": {"type": "ephemeral"}
          },
          {
            "type": "text",
            "text": "Which model has the highest human preference win rates across each use-case?"
          }
        ]
      }
    ]
  }'
{
  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Based on the document, the model with the highest human preference win rates..."
    }
  ],
  "model": "claude-haiku-4-5-20251001",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 2500,
    "output_tokens": 200
  }
}
Official documentation: https://docs.anthropic.com/en/docs/build-with-claude/pdf-support
Use Claude models to read and analyze PDF documents by providing base64-encoded PDF data.

Overview

This endpoint allows you to send base64-encoded PDF documents to Claude for analysis. This is useful when you have local PDF files that need to be processed without hosting them at a URL.

Authentication

All requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY

Request Parameters

model
string
required
The model to use. Recommended: claude-haiku-4-5-20251001.
max_tokens
integer
required
The maximum number of tokens to generate.
messages
array
required
Messages array with document content blocks.

Document Content Format

{
  "type": "document",
  "source": {
    "type": "base64",
    "media_type": "application/pdf",
    "data": "JVBERi0xLjcK..."
  },
  "cache_control": {
    "type": "ephemeral"
  }
}
curl -X POST https://www.anyfast.ai/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-4-5-20251001",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "document",
            "source": {
              "type": "base64",
              "media_type": "application/pdf",
              "data": "<BASE64_PDF_DATA>"
            },
            "cache_control": {"type": "ephemeral"}
          },
          {
            "type": "text",
            "text": "Which model has the highest human preference win rates across each use-case?"
          }
        ]
      }
    ]
  }'
{
  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Based on the document, the model with the highest human preference win rates..."
    }
  ],
  "model": "claude-haiku-4-5-20251001",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 2500,
    "output_tokens": 200
  }
}