Skip to content

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- or claude- 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 Authorization header, but on this platform we recommend using Authorization: Bearer sk-xxx or the platform's required auth method.

Common request parameters

ParameterTypeRequiredDescription
modelstringyesModel name, e.g. claude-3-5-sonnet-20240620
messagesarrayyesMessage array; elements include role and content. content supports text or file objects
messages[].content[].typestringnoe.g. text / image / document
messages[].content[].sourceobjectnoFile resource; type indicates base64 or url; data or url contains file content or address
messages[].content[].cache_controlobjectnoCache control (e.g. ephemeral) to cache PDFs within session and save tokens
temperaturenumbernoSampling temperature
top_pnumbernoNucleus sampling threshold
max_tokensnumbernoMax generated tokens
streambooleannoStream responses
toolsobjectnoFunction call definitions (see Claude docs)
thinkingobjectnoThinking 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 }
}