Claude (native format) — PDF Analysis
Short description: Claude's native request format supporting PDF/image uploads and cache controls, suitable for document parsing, summarization, and Q&A. Below are common fields and examples; see Claude's official docs for advanced options.
Overview
- Method:
POST - Path:
/v1/messages - Content-Type:
application/json
Supported models
- Models prefixed with
cld-orclaude-are supported, as well as some compatible variants (e.g.claude-3-5-sonnet-20240620).
Authentication
- Claude's native format may not strictly require an
Authorizationheader, but on this platform we recommend usingAuthorization: Bearer sk-xxxor the platform's required auth method.
Common request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | yes | Model name, e.g. claude-3-5-sonnet-20240620 |
| messages | array | yes | Message array; elements include role and content. content supports text or file objects |
| messages[].content[].type | string | no | e.g. text / image / document |
| messages[].content[].source | object | no | File resource; type indicates base64 or url; data or url contains file content or address |
| messages[].content[].cache_control | object | no | Cache control (e.g. ephemeral) to cache PDFs within session and save tokens |
| temperature | number | no | Sampling temperature |
| top_p | number | no | Nucleus sampling threshold |
| max_tokens | number | no | Max generated tokens |
| stream | boolean | no | Stream responses |
| tools | object | no | Function call definitions (see Claude docs) |
| thinking | object | no | Thinking mode controls (e.g. budget_tokens; supported by some models) |
Note: If enabling thinking, ensure the chosen model supports it and that budget_tokens and max_tokens settings satisfy constraints.
Examples
Simple text request (curl)
bash
curl -X POST "https://api.gpt.ge/v1/messages" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-sonnet-20240620",
"messages": [ { "role": "user", "content": [ { "type": "text", "text": "Hello, who are you?" } ] } ],
"max_tokens": 1688,
"temperature": 0.5
}'PDF analysis example (curl, base64)
bash
curl -X POST "https://api.gpt.ge/v1/messages" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-sonnet-20240620",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Please summarize the key points of this PDF" },
{ "type": "document", "source": { "type": "base64", "data": "JVBERi0xLjQKJ...", "media_type": "application/pdf" }, "cache_control": { "type": "ephemeral" } }
]
}
],
"max_tokens": 6000
}'Tip: For large files (>20MB) prefer passing a url and set source.type to url.
JavaScript example
javascript
fetch('https://api.gpt.ge/v1/messages', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer sk-xxxx' },
body: JSON.stringify({
model: 'claude-3-5-sonnet-20240620',
messages: [{ role: 'user', content: [{ type: 'text', text: 'Please summarize this PDF' }, { type: 'document', source: { type: 'base64', data: 'JVBERi0x...' } }] }]
})
}).then(r => r.json()).then(console.log)Response example (200)
json
{
"id": "resp-claude-1234",
"type": "message",
"role": "assistant",
"content": [ { "type": "text", "text": "PDF key points: ..." } ],
"model": "claude-3-5-sonnet-20240620",
"stop_reason": "stop",
"usage": { "input_tokens": 120, "output_tokens": 430 }
}