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

# Claude via OpenAI Format — PDF Analysis and Thinking

> Use Claude models at POST /v1/chat/completions with any OpenAI-compatible SDK. Supports PDF analysis, extended thinking, image inputs, and streaming.

KiosAPI lets you call Claude models using the standard OpenAI request format — the same endpoint, headers, and SDK you already use for GPT models. You send requests to `/v1/chat/completions` with your Claude model name, and PDFs and other files are supported by passing structured objects in the `content` array of each message.

<Tip>
  If you need prompt caching, use the **Claude native format** instead — the OpenAI-compatible format does not support PDF caching. See the [Claude (Native)](/api-reference/chat/claude-native) page for details.
</Tip>

## Request

**POST** `https://kiosapi.com/v1/chat/completions`

### Headers

| Header          | Required | Description        |
| --------------- | -------- | ------------------ |
| `Content-Type`  | Yes      | `application/json` |
| `Authorization` | Yes      | `Bearer sk-xxx`    |

### Request Body

<ParamField body="model" type="string" required>
  Claude model name (e.g. `claude-sonnet-4-6`).
</ParamField>

<ParamField body="messages" type="array" required>
  Array of message objects forming the conversation.

  <Expandable title="messages properties">
    <ParamField body="messages[].role" type="string" required>
      Role of the message author: `user` or `assistant`.
    </ParamField>

    <ParamField body="messages[].content" type="string | array" required>
      The message content. Pass a plain string for text-only messages, or an array of content objects for multimodal input such as PDFs and images.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="max_tokens" type="number">
  Maximum number of tokens to generate in the response.
</ParamField>

<ParamField body="temperature" type="number">
  Sampling temperature between 0 and 2.
</ParamField>

<ParamField body="stream" type="boolean">
  Set to `true` to stream the response using server-sent events.
</ParamField>

<ParamField body="thinking" type="object">
  Enable extended thinking. Available on `claude-3-7-sonnet` only.

  <Expandable title="thinking properties">
    <ParamField body="thinking.type" type="string">
      Must be `"enabled"` to activate extended thinking.
    </ParamField>

    <ParamField body="thinking.budget_tokens" type="integer">
      Maximum tokens the model may use for internal reasoning. Minimum `1024`; must be less than `max_tokens`.
    </ParamField>
  </Expandable>
</ParamField>

### Content Types for PDF and File Analysis

When passing `content` as an array, each element uses one of the following types:

| Type        | Fields                            | Description                             |
| ----------- | --------------------------------- | --------------------------------------- |
| `text`      | `text`                            | Plain text prompt                       |
| `file`      | `file.filename`, `file.file_data` | PDF file passed as a URL or base64 data |
| `file_url`  | `file_url.url`                    | File URL (supports images and PDFs)     |
| `image_url` | `image_url.url`                   | Image URL (base64 data URI or web URL)  |

<Tip>
  For PDF files, Claude recommends base64 encoding for faster results. Use the format `data:application/pdf;base64,JVBERi0xLjQK...`.
</Tip>

### Examples

<Tabs>
  <Tab title="cURL (Chat)">
    ```bash theme={null}
    curl https://kiosapi.com/v1/chat/completions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxx" \
      -d '{
        "model": "claude-sonnet-4-6",
        "messages": [
          {
            "role": "user",
            "content": "Hello, who are you?"
          }
        ],
        "max_tokens": 1688,
        "temperature": 0.5,
        "stream": false
      }'
    ```
  </Tab>

  <Tab title="cURL (PDF)">
    ```bash theme={null}
    curl https://kiosapi.com/v1/chat/completions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxx" \
      -d '{
        "model": "claude-sonnet-4-6",
        "messages": [
          {
            "role": "user",
            "content": [
              {
                "type": "text",
                "text": "Summarize this document"
              },
              {
                "type": "file_url",
                "file_url": {
                  "url": "https://example.com/document.pdf"
                }
              }
            ]
          }
        ],
        "max_tokens": 1000,
        "stream": false
      }'
    ```
  </Tab>

  <Tab title="Python (PDF Analysis)">
    ```python theme={null}
    import openai

    openai.api_key = "sk-xxx"
    openai.base_url = "https://kiosapi.com/v1/"

    response = openai.chat.completions.create(
        model="claude-sonnet-4-6",
        messages=[
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "Summarize this document"},
                    {
                        "type": "file",
                        "file": {
                            "filename": "document.pdf",
                            "file_data": "https://example.com/document.pdf"
                        }
                    }
                ]
            }
        ],
        max_tokens=1000,
        stream=False
    )

    print(response.choices[0].message.content)
    ```
  </Tab>

  <Tab title="Python (Extended Thinking)">
    ```python theme={null}
    response = openai.chat.completions.create(
        model="claude-3-7-sonnet-20250219",
        messages=[{"role": "user", "content": "Solve this complex problem..."}],
        max_tokens=8000,
        thinking={
            "type": "enabled",
            "budget_tokens": 4000
        }
    )
    ```
  </Tab>
</Tabs>

## Response

```json theme={null}
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1724972230,
  "model": "claude-sonnet-4-6",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm Claude, an AI assistant..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 38,
    "total_tokens": 50
  }
}
```
