Skip to main content
POST
/
v1
/
chat
/
completions
File Analysis
curl --request POST \
  --url https://gptproto.com/v1/chat/completions \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "<string>",
  "messages": [
    {}
  ],
  "max_tokens": 123,
  "stream": true,
  "temperature": 123
}'
{
  "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
  }
}

Overview

This endpoint provides file analysis functionality using Claude 3.5 Haiku. Upload files or provide file URLs to extract content, analyze data, summarize documents, or process structured information from various file formats including PDF, DOCX, TXT, and more.

Authentication

This endpoint requires authentication using a Bearer token.
Authorization
string
default:"sk-***********"
required
Your API key in the format: YOUR_API_KEY

Request Body

model
string
default:"claude-haiku-4-5-20251001"
required
The model to use for file analysis. Must be claude-haiku-4-5-20251001 or another Claude model with file analysis capabilities.
messages
array
required
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, HTMLMaximum file size: 20MBExample structure:
[
  {
    "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_tokens
integer
default:"1000"
Maximum number of tokens to generate in the response
stream
boolean
default:false
Whether to stream the response
temperature
number
default:"1.0"
Sampling temperature between 0 and 2. Higher values make output more random.

Request Example

curl -X POST "https://gptproto.com/v1/chat/completions" \
  -H "Authorization: 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
  }'

Response

id
string
Unique identifier for the chat completion
object
string
Object type, always “chat.completion”
created
integer
Unix timestamp of when the completion was created
model
string
The model used for generating the completion
choices
array
Array of completion choices
usage
object
Token usage statistics
{
  "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
  }
}