claude-opus-4-7 (File Analysis)
POST
/
v1
/
chat
/
completions
claude-opus-4-7 (File Analysis)
curl --request POST \
--url https://gptproto.com/v1/chat/completionsimport requests
url = "https://gptproto.com/v1/chat/completions"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://gptproto.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://gptproto.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://gptproto.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://gptproto.com/v1/chat/completions")
.asString();require 'uri'
require 'net/http'
url = URI("https://gptproto.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_bodyAuthentication
- Sign up for a GPTProto account at https://gptproto.com
- Navigate to the API Keys section in your dashboard
- Generate a new API key (sk-xxxxx)
- Copy and securely store your API key For authentication details, please refer to the Authentication section.
Initiate Request
curl --location 'https://gptproto.com/v1/chat/completions' \
--header 'Authorization: GPTPROTO_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-opus-4-7",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please analyze this PDF document and provide a summary of its content"
},
{
"type": "file",
"file": {
"filename": "gptproto.pdf",
"file_data": "https://tos.gptproto.com/resource/gptproto.pdf"
}
}
]
}
],
"max_tokens": 1000,
"stream": false
}'
const axios = require('axios');
let data = JSON.stringify({
"model": "claude-opus-4-7",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please analyze this PDF document and provide a summary of its content"
},
{
"type": "file",
"file": {
"filename": "gptproto.pdf",
"file_data": "https://tos.gptproto.com/resource/gptproto.pdf"
}
}
]
}
],
"max_tokens": 1000,
"stream": false
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://gptproto.com/v1/chat/completions',
headers: {
'Authorization': 'GPTPROTO_API_KEY',
'Content-Type': 'application/json'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import requests
import json
url = "https://gptproto.com/v1/chat/completions"
payload = json.dumps({
"model": "claude-opus-4-7",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please analyze this PDF document and provide a summary of its content"
},
{
"type": "file",
"file": {
"filename": "gptproto.pdf",
"file_data": "https://tos.gptproto.com/resource/gptproto.pdf"
}
}
]
}
],
"max_tokens": 1000,
"stream": False
})
headers = {
'Authorization': 'GPTPROTO_API_KEY',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://gptproto.com/v1/chat/completions"
method := "POST"
payload := strings.NewReader(`{
"model": "claude-opus-4-7",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please analyze this PDF document and provide a summary of its content"
},
{
"type": "file",
"file": {
"filename": "gptproto.pdf",
"file_data": "https://tos.gptproto.com/resource/gptproto.pdf"
}
}
]
}
],
"max_tokens": 1000,
"stream": false
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "GPTPROTO_API_KEY")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Response Example
Response Example
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1699896916,
"model": "claude-opus-4-6",
"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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | ✅ Yes | claude-opus-4-6 | The model to use for the request |
messages | array | ✅ Yes | [{"role": "user", "content": "What's the weather in NYC?"}] | Array of message objects for the conversation. Each message must have a role (user or assistant) and content. |
tools | array | ✅ Yes | - | Array of tool objects. For web search, must include the web_search tool configuration. |
stream | boolean | ❌ No | false | Whether to stream the response |
temperature | number | ❌ No | 1.0 | Amount of randomness injected into the response. Ranges from 0.0 to 1.0 |
top_p | number | ❌ No | 1.0 | Use nucleus sampling. Ranges from 0.0 to 1.0 |
max_tokens | integer | ❌ No | - | The maximum number of tokens to generate before stopping |
stop | array | ❌ No | - | Custom text sequences that will cause the model to stop generating |
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 | "What's the weather in NYC?" | The text content when type is text |
Tools Array Structure
For web search functionality, thetools array should contain a web search tool object:
| Field | Type | Required | Example | Description |
|---|---|---|---|---|
type | string | ✅ Yes | web_search | The type of tool. Must be web_search for web search |
max_uses | integer | ❌ No | 5 | Maximum number of times the web search tool can be used in a single request |
allowed_domains | array | ❌ No | ["example.com", "trusteddomain.org"] | Only include search results from these domains |
blocked_domains | array | ❌ No | ["untrustedsource.com"] | Never include search results from these domains |
Max Uses
Themax_uses parameter limits the number of searches performed. If Claude attempts more searches than allowed, the web search result will be an error with the max_uses_exceeded error code.
Domain Filtering
When using domain filters:- Domains should not include the HTTP/HTTPS scheme (use
example.cominstead ofhttps://example.com) - Subdomains are automatically included (
example.comcoversdocs.example.com) - Specific subdomains restrict results to only that subdomain (
docs.example.comreturns only results from that subdomain, not fromexample.comorapi.example.com) - Subpaths are supported (
example.com/blog) - You can use either
allowed_domainsorblocked_domains, but not both in the same request
Complete Tool Configuration Example
{
"type": "web_search_20250305",
"name": "web_search",
"max_uses": 5,
"allowed_domains": ["example.com", "trusteddomain.org"]
}
Error Codes
Common Error Codes
| Error Code | Error Name | Description |
|---|---|---|
| 401 | Unauthorized | API key is missing or invalid |
| 403 | Forbidden | Your API key doesn’t have permission to access this resource, or insufficient balance for the requested operation |
| 429 | Too Many Requests | You’ve exceeded your rate limit |
| 500 | Internal server error | An internal server error occurred |
| 503 | Content policy violation | Content blocked due to safety concerns (actual status code is 400) |

