Claude-Opus-4-20250514-Thinking - File Analysis - openai
Claude-Opus-4-20250514-Thinking — File Analysis (openai). GPTProto API reference.
POST
/
v1
/
chat
/
completions
claude-opus-4-20250514-thinking (file analysis)
curl --request POST \
--url https://api.example.com/v1/chat/completionsimport requests
url = "https://api.example.com/v1/chat/completions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v1/chat/completions"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/chat/completions")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyClaude’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-opus-4-20250514-thinking",
"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
}'
curl -X POST "https://gptproto.com/v1/chat/completions" \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-20250514-thinking",
"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
}'
import requests
import json
url = "https://gptproto.com/v1/chat/completions"
headers = {
"Authorization": "YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "claude-opus-4-20250514-thinking",
"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))
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-opus-4-20250514-thinking",
"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))
const url = "https://gptproto.com/v1/chat/completions";
const headers = {
"Authorization": "YOUR_API_KEY",
"Content-Type": "application/json"
};
const data = {
"model": "claude-opus-4-20250514-thinking",
"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));
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-opus-4-20250514-thinking",
"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));
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-opus-4-20250514-thinking",
"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))
}
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-opus-4-20250514-thinking",
"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))
}
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1699896916,
"model": "claude-opus-4-20250514-thinking",
"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
}
}
{
"error": {
"message": "Invalid signature",
"type": "401"
}
}
{
"error": {
"message": "Insufficient balance",
"type": "403"
}
}
{
"error": {
"message": "Internal server error",
"type": "500"
}
}
{
"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-opus-4-20250514-thinking | The model to use for file analysis. Must be claude-opus-4-20250514-thinking 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 themessages 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 |
Claude-Opus-4-20250514-Thinking - Web Search
Previous
Claude-Opus-4-20250514-Thinking - Text To Text - openai
Next
⌘I

