Skip to main content
POST
/
v1
/
chat
/
completions
claude-3-5-haiku-20241022 (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: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-5-haiku-20241022",
    "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-3-5-haiku-20241022",
  "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

ParameterTypeRequiredDefaultDescription
modelstring✅ Yesclaude-3-5-haiku-20241022The model to use for file analysis. Must be claude-3-5-haiku-20241022 or another Claude model with file analysis capabilities.
messagesarray✅ Yes-Array of message objects for the conversation. Each message contains: - role: user, assistant, or system - content: Array of content objects supporting: - type: “text”: Text prompt with text field - type: “file”: File input with file object containing: - filename: Name of the file - file_data: URL to file or base64 encoded data Supported file formats: PDF, DOCX, XLSX, TXT, CSV, JSON, XML, HTML Maximum file size: 20MB Example structure: json [ { "role": "user", "content": [ { "type": "text", "text": "Summarize the contents of this document" }, { "type": "file", "file": { "filename": "document.pdf", "file_data": "https://example.com/document.pdf" } } ] } ]
max_tokensinteger❌ No1000Maximum number of tokens to generate in the response
streamboolean❌ NofalseWhether to stream the response
temperaturenumber❌ No1.0Sampling temperature between 0 and 2. Higher values make output more random.

Messages Array Structure

Each message object in the messages array should have the following structure:
FieldTypeRequiredDescription
rolestring✅ YesThe role of the message. Can be: user, assistant, or system
contentarray/string✅ YesThe content of the message

Content Array Structure (when content is an array)

FieldTypeRequiredExampleDescription
typestring✅ YestextThe type of content
textstring✅ Yes"The positive prompt for the generation."The text content when type is text