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

# Claude (Format Asli) - Analisis PDF

> Gunakan model Claude melalui format Anthropic asli dengan dukungan caching

# Claude (Format Asli) - Analisis PDF

Format permintaan asli Claude mendukung cache cepat, yang secara signifikan dapat mengurangi biaya untuk konteks berulang.

> [!TIP]
>
> Format asli hanya mencantumkan parameter yang umum digunakan. Untuk detail parameter selengkapnya, baca [dokumentasi resmi Claude](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching).

## Model yang Didukung

Format asli Claude mendukung model dengan awalan `cld-` atau `claude-`, serta `kimi-k2-0711-preview`, `qwen3-coder-plus`, dan `glm-4.5+`.

## Permintaan

### Header

| Header | Wajib | Deskripsi |
| - | - | - |
| `Content-Type` | Ya | `application/json` |
| `x-api-key` | Ya | `sk-xxx` |
| `anthropic-version` | Ya | `2023-06-01` |

### Badan Permintaan

| Parameter | Tipe | Wajib | Deskripsi |
| - | - | - | - |
| `model` | string | Ya | Nama model Claude |
| `messages` | array | Ya | Array objek pesan |
| `messages[].role` | string | Ya | Peran: `user` atau `assistant` |
| `messages[].content` | string/array | Ya | Konten teks atau multimodal |
| `max_tokens` | number | Tidak | Token maksimum untuk dihasilkan |
| `temperature` | number | Tidak | Suhu pengambilan sampel (0-2) |
| `top_p` | number | Tidak | Pengambilan sampel inti |
| `top_k` | integer | Tidak | Pengambilan sampel teratas |
| `stream` | boolean | Tidak | Aktifkan streaming |
| `tools` | object | Tidak | Alat pemanggil fungsi |
| `thinking` | object | Tidak | Konfigurasi pemikiran yang diperluas |

### Jenis Konten untuk PDF/Analisis Gambar

| Jenis | Sub-tipe | Bidang | Deskripsi |
| - | - | - | - |
| `image` atau `document` | base64 | `source.type: "base64"`, `source.data`, `source.media_type` | File berkode Base64 |
| `image` atau `document` | url | `source.type: "url"`, `source.url` | URL berkas |
| `text` | - | `text` | Perintah teks |

### Kontrol Tembolok

Untuk file yang digunakan dalam beberapa pesan, tambahkan `cache_control` untuk menyimpan file dalam cache:

```json theme={null}
{
  "type": "document",
  "source": {
    "type": "base64",
    "data": "JVBERi0xLjQK...",
    "media_type": "application/pdf"
  },
  "cache_control": {
    "type": "ephemeral"
  }
}
```

### Contoh Permintaan - Obrolan

```bash theme={null}
curl https://kiosapi.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: sk-xxx" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {
        "role": "user",
        "content": "Hello, who are you?"
      }
    ],
    "max_tokens": 1688,
    "temperature": 0.5,
    "stream": false
  }'
```

### Contoh Python - Analisis PDF dengan Caching

```python theme={null}
import anthropic

client = anthropic.Anthropic(
    api_key="sk-xxx",
    base_url="https://kiosapi.com"
)

response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1000,
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Summarize this document"
                },
                {
                    "type": "document",
                    "source": {
                        "type": "url",
                        "url": "https://example.com/document.pdf"
                    },
                    "cache_control": {"type": "ephemeral"}
                }
            ]
        }
    ]
)

print(response.content[0].text)
```

### Contohnya adalah pemikiran yang diperluas

```python theme={null}
response = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=8000,
    thinking={
        "type": "enabled",
        "budget_tokens": 4000
    },
    messages=[{"role": "user", "content": "Solve this complex problem..."}]
)
```

## Respons

```json theme={null}
{
  "id": "msg_014AoBefsejHUjbdRntn7euw",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Hello! I'm Claude, an AI assistant. How can I help you today?"
    }
  ],
  "model": "claude-sonnet-4-6",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 12,
    "output_tokens": 38
  }
}
```

### Skema Respons

| Bidang | Tipe | Deskripsi |
| - | - | - |
| `id` | string | ID pesan |
| `type` | string | Selalu `message` |
| `role` | string | Selalu `assistant` |
| `content` | array | Blokir konten respons |
| `content[].type` | string | `text` |
| `content[].text` | string | Teks tanggapan |
| `model` | string | Model yang digunakan |
| `stop_reason` | string | `end_turn`, `max_tokens`, `tool_use` |
| `usage.input_tokens` | integer | Token masukan |
| `usage.output_tokens` | integer | Token keluaran |


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