Skip to main content
POST
/
v1
/
messages
claude-opus-4-5-20251101 (file analysis)
curl --request POST \
  --url https://api.example.com/v1/messages
Claude’s official format for the file analysis API.
curl -X POST "https://gptproto.com/v1/messages" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "claude-opus-4-5-20251101",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Please analyze this PDF document and provide a summary of its content"
        },
        {
          "type": "document",
          "source": {
            "type": "url",
            "url": "https://www.bt.cn/data/api-doc.pdf"
          }
        }
      ]
    }
  ]
}'
{
  "error": {
    "type": "authentication_error",
    "message": "Invalid API key"
  }
}

Parameters

ParameterTypeRequiredDefaultRangeDescription
modelstring✅ Yesclaude-opus-4-5-20251101-The model identifier. Use claude-opus-4-5-20251101 for this model
messagesarray✅ Yes--Input messages for the conversation. Each message must have a role (user/assistant) and content. Content can include text blocks or document blocks with base64 or URL sources. Supported formats: PDF, DOCX, XLSX, TXT, CSV, JSON, XML, HTML. Max file size: 20MB. See Messages Structure below for details
max_tokensinteger✅ Yes-1-64000Maximum number of tokens to generate. The model may stop before reaching this limit
temperaturenumber❌ No1.00.0-1.0Controls randomness in output. Use lower values (closer to 0.0) for analytical tasks, higher values (closer to 1.0) for creative tasks. Note: Even at 0.0, results are not fully deterministic
top_pnumber❌ No-0.0-1.0Nucleus sampling threshold. Controls diversity by considering only tokens with cumulative probability up to top_p. Recommended for advanced use only. Do not use with temperature
top_kinteger❌ No->0Only sample from the top K options for each token. Removes low probability responses. Recommended for advanced use only
streamboolean❌ Nofalse-Whether to stream the response incrementally using server-sent events
stop_sequencesarray❌ No-Max 8191 sequencesCustom text sequences that will cause the model to stop generating. Each sequence must contain non-whitespace characters

Messages Structure

Basic structure:
{
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": "Please analyze this document"
    },
    {
      "type": "document",
      "source": {
        "type": "url",
        "url": "https://example.com/document.pdf"
      }
    }
  ]
}
With Base64:
{
  "type": "document",
  "source": {
    "type": "base64",
    "media_type": "application/pdf",
    "data": "JVBERi0xLjQK..."
  }
}

Messages Array Structure

Each message object in the messages array should have the following structure:
FieldTypeRequiredRangeDescription
rolestring✅ Yes-The role of the message. Can be: user or assistant
contentarray/string✅ Yes-The content of the message. Can be a string or an array of content blocks

Content Block Structure

When content is an array, each element can be one of the following types:

Text Content Block

FieldTypeRequiredRangeDescription
typestring✅ Yes-Must be text
textstring✅ Yes-The text content

Document Content Block

FieldTypeRequiredRangeDescription
typestring✅ Yes-Must be document
sourceobject✅ Yes-The document source (base64 or URL)

Document Source Structure (URL)

FieldTypeRequiredRangeDescription
typestring✅ Yes-Must be url
urlstring✅ Yes-The URL of the document file

Document Source Structure (Base64)

FieldTypeRequiredRangeDescription
typestring✅ Yes-Must be base64
media_typestring✅ Yes-The MIME type of the document (e.g., application/pdf, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
datastring✅ Yes-Base64-encoded document data

Supported Document Formats

FormatMIME TypeExtension
PDFapplication/pdf.pdf
Wordapplication/vnd.openxmlformats-officedocument.wordprocessingml.document.docx
Excelapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet.xlsx
Plain Texttext/plain.txt
CSVtext/csv.csv
JSONapplication/json.json
XMLapplication/xml or text/xml.xml
HTMLtext/html.html
Note: Maximum file size is 20MB.