> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gptproto.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude-3-7-Sonnet-20250219 - File Analysis - openai

> Claude-3-7-Sonnet-20250219 — File Analysis (openai). GPTProto API reference.

Claude's openai format for the file analysis API.

```bash cURL (with URL) theme={null}
curl -X POST "https://gptproto.com/v1/chat/completions" \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-7-sonnet-20250219",
    "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
  }'
```

```bash cURL (with Base64) theme={null}
curl -X POST "https://gptproto.com/v1/chat/completions" \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-7-sonnet-20250219",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "Please analyze this PDF document and extract the key information, main topics, and summary"
          },
          {
            "type": "file",
            "file": {
              "filename": "document.pdf",
              "file_data": "data:application/pdf;base64,JVBERi0xLjQKJeLjz9MK..."
            }
          }
        ]
      }
    ],
    "max_tokens": 2000,
    "stream": false
  }'
```

```python Python (with URL) theme={null}
import requests
import json

url = "https://gptproto.com/v1/chat/completions"
headers = {
    "Authorization": "YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {
    "model": "claude-3-7-sonnet-20250219",
    "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 = requests.post(url, headers=headers, json=data)
result = response.json()
print(json.dumps(result, indent=2))
```

```python Python (with Base64) theme={null}
import requests
import json
import base64

url = "https://gptproto.com/v1/chat/completions"
headers = {
    "Authorization": "YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Read and encode file
with open("document.pdf", "rb") as file:
    base64_file = base64.b64encode(file.read()).decode('utf-8')

data = {
    "model": "claude-3-7-sonnet-20250219",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Please analyze this PDF document and extract the key information, main topics, and summary"
                },
                {
                    "type": "file",
                    "file": {
                        "filename": "document.pdf",
                        "file_data": f"data:application/pdf;base64,{base64_file}"
                    }
                }
            ]
        }
    ],
    "max_tokens": 2000,
    "stream": False
}

response = requests.post(url, headers=headers, json=data)
result = response.json()
print(json.dumps(result, indent=2))
```

```javascript JavaScript (with URL) theme={null}
const url = "https://gptproto.com/v1/chat/completions";
const headers = {
  "Authorization": "YOUR_API_KEY",
  "Content-Type": "application/json"
};

const data = {
  "model": "claude-3-7-sonnet-20250219",
  "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
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(data)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error("Error:", error));
```

```javascript JavaScript (with Base64) theme={null}
const url = "https://gptproto.com/v1/chat/completions";
const headers = {
  "Authorization": "YOUR_API_KEY",
  "Content-Type": "application/json"
};

// Read and encode file
const fs = require('fs');
const base64File = fs.readFileSync('document.pdf').toString('base64');

const data = {
  "model": "claude-3-7-sonnet-20250219",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Please analyze this PDF document and extract the key information, main topics, and summary"
        },
        {
          "type": "file",
          "file": {
            "filename": "document.pdf",
            "file_data": `data:application/pdf;base64,${base64File}`
          }
        }
      ]
    }
  ],
  "max_tokens": 2000,
  "stream": false
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(data)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error("Error:", error));
```

```go Go (with URL) theme={null}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    url := "https://gptproto.com/v1/chat/completions"

    payload := map[string]interface{}{
        "model": "claude-3-7-sonnet-20250219",
        "messages": []map[string]interface{}{
            {
                "role": "user",
                "content": []map[string]interface{}{
                    {
                        "type": "text",
                        "text": "Please analyze this PDF document and provide a summary of its content",
                    },
                    {
                        "type": "file",
                        "file": map[string]string{
                            "filename":  "api-doc.pdf",
                            "file_data": "https://www.bt.cn/data/api-doc.pdf",
                        },
                    },
                },
            },
        },
        "max_tokens": 1000,
        "stream":     false,
    }

    jsonData, _ := json.Marshal(payload)
    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Authorization", "YOUR_API_KEY")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```go Go (with Base64) theme={null}
package main

import (
    "bytes"
    "encoding/base64"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
    "os"
)

func main() {
    url := "https://gptproto.com/v1/chat/completions"

    // Read and encode file
    fileData, _ := os.ReadFile("document.pdf")
    base64File := base64.StdEncoding.EncodeToString(fileData)

    payload := map[string]interface{}{
        "model": "claude-3-7-sonnet-20250219",
        "messages": []map[string]interface{}{
            {
                "role": "user",
                "content": []map[string]interface{}{
                    {
                        "type": "text",
                        "text": "Please analyze this PDF document and extract the key information, main topics, and summary",
                    },
                    {
                        "type": "file",
                        "file": map[string]string{
                            "filename":  "document.pdf",
                            "file_data": "data:application/pdf;base64," + base64File,
                        },
                    },
                },
            },
        },
        "max_tokens": 2000,
        "stream":     false,
    }

    jsonData, _ := json.Marshal(payload)
    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Authorization", "YOUR_API_KEY")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```json 200 - Success theme={null}
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699896916,
  "model": "claude-3-7-sonnet-20250219",
  "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
  }
}
```

```json 401 - Invalid signature theme={null}
{
  "error": {
    "message": "Invalid signature",
    "type": "401"
  }
}
```

```json 403 - Insufficient balance theme={null}
{
  "error": {
    "message": "Insufficient balance",
    "type": "403"
  }
}
```

```json 500 - Internal server error theme={null}
{
  "error": {
    "message": "Internal server error",
    "type": "500"
  }
}
```

```json 503 - Content policy violation theme={null}
{
  "error": {
    "message": "Input may not meet the guidelines. Please adjust and try again.",
    "type": "503"
  }
}
```

## Parameters

| Parameter | Type | Required | Default | Description |
| - | - | - | - | - |
| `model` | string | ✅ Yes | `claude-3-7-sonnet-20250219` | The model to use for file analysis. Must be `claude-3-7-sonnet-20250219` or another Claude model with file analysis capabilities. |
| `messages` | array | ✅ 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_tokens` | integer | ❌ No | `1000` | Maximum number of tokens to generate in the response |
| `stream` | boolean | ❌ No | `false` | Whether to stream the response |
| `temperature` | number | ❌ No | `1.0` | Sampling 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:

| Field | Type | Required | Description |
| - | - | - | - |
| `role` | string | ✅ Yes | The role of the message. Can be: `user`, `assistant`, or `system` |
| `content` | array/string | ✅ Yes | The content of the message |

### Content Array Structure (when content is an array)

| Field | Type | Required | Example | Description |
| - | - | - | - | - |
| `type` | string | ✅ Yes | `text` | The type of content |
| `text` | string | ✅ Yes | `"The positive prompt for the generation."` | The text content when type is `text` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.