Skip to main content
POST
/
v1
/
chat
/
completions
claude-haiku-4-5-20251001 (file analysis)
curl --request POST \
  --url https://api.example.com/v1/chat/completions
Claude’s openai format for the file analysis API.
curl -X POST "https://gptproto.com/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-4-5-20251001",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Please analyze this PDF document and provide a summary of its content"
          },
          {
            "type": "file",
            "file": {
              "filename": "api-doc.pdf",
              "file_data": "https://www.bt.cn/data/api-doc.pdf"
            }
          }
        ]
      }
    ],
    "max_tokens": 1000,
    "stream": false
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699896916,
  "model": "claude-haiku-4-5-20251001",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "# Document Analysis Summary\n\n## Key Information:\n- Document Type: Technical API Documentation\n- Total Pages: 35\n- Version: 2.0\n\n## Main Topics:\n1. **Authentication**: The API uses Bearer token authentication with API keys\n2. **Endpoints**: Contains 12 main API endpoints for different operations\n3. **Rate Limiting**: Implements tiered rate limiting based on subscription level\n4. **Error Handling**: Comprehensive error codes and handling strategies\n\n## Key Sections:\n\n### Getting Started\n- Quick start guide for new developers\n- Authentication setup instructions\n- First API call examples in multiple languages\n\n### API Reference\n- Detailed endpoint documentation\n- Request/response formats\n- Parameter descriptions and constraints\n\n### Best Practices\n- Recommended usage patterns\n- Performance optimization tips\n- Security considerations\n\n### Code Examples\n- Python, JavaScript, Go, and cURL examples\n- Common use case implementations\n- Error handling patterns\n\n## Important Notes:\n- All requests must include valid API key\n- Rate limits: 100 requests/minute for free tier, 1000/minute for premium\n- Support for both JSON and XML response formats\n- Webhook notifications available for asynchronous operations"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 3500,
    "completion_tokens": 285,
    "total_tokens": 3785
  }
}

Parameters

ParameterTypeRequiredDefaultRangeDescription
modelstring✅ Yesclaude-haiku-4-5-20251001-The model identifier. Use claude-haiku-4-5-20251001 for this model
messagesarray✅ Yes--Input messages for the conversation. Each message must have a role (user/assistant/system) and content. Content can include text blocks or file blocks. Supported formats: PDF, DOCX, XLSX, TXT, CSV, JSON, XML, HTML. Max file size: 20MB. See Messages Structure below for details
max_tokensinteger❌ No10241-64000Maximum number of tokens to generate. The model may stop before reaching this limit
temperaturenumber❌ No1.00.0-2.0Controls randomness in output. Use lower values (closer to 0.0) for analytical tasks, higher values for creative tasks
top_pnumber❌ No1.00.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
streamboolean❌ Nofalse-Whether to stream the response incrementally using server-sent events
stopstring/array❌ NonullMax 4 sequencesUp to 4 sequences where the API will stop generating further tokens
presence_penaltynumber❌ No0-2.0-2.0Penalty for tokens based on whether they appear in the text so far. Positive values increase model’s likelihood to talk about new topics
frequency_penaltynumber❌ No0-2.0-2.0Penalty for tokens based on their frequency in the text so far. Positive values decrease model’s likelihood to repeat the same line

Messages Structure

Basic structure with file (URL):
{
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": "Please analyze this document"
    },
    {
      "type": "file",
      "file": {
        "filename": "document.pdf",
        "file_data": "https://example.com/document.pdf"
      }
    }
  ]
}
With Base64:
{
  "type": "file",
  "file": {
    "filename": "document.pdf",
    "file_data": "data:application/pdf;base64,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, assistant, or system
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

File Content Block

FieldTypeRequiredRangeDescription
typestring✅ Yes-Must be file
fileobject✅ Yes-The file object containing filename and file_data

File Object Structure

FieldTypeRequiredRangeDescription
filenamestring✅ Yes-The name of the file (e.g., document.pdf)
file_datastring✅ Yes-URL to the file or base64-encoded data with data URI scheme (e.g., data:application/pdf;base64,<base64_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.