> ## 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.

# Vision Image Analysis via Chat Completions — KiosAPI

> Send images to vision-capable models via POST /v1/chat/completions. Supports public image URLs, web links, and inline base64-encoded data URIs.

Vision-capable models like `gpt-4o` can analyze images you pass directly inside the `messages` array of a standard chat completions request. You send images the same way you send text — by including them as content objects within a user message — and the model returns a natural-language description, answer, or analysis. Both public web URLs and base64-encoded data URIs are supported, so you can reference hosted images or embed raw image data without any separate upload step.

## Request

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

### Headers

| Header          | Value              | Description               |
| --------------- | ------------------ | ------------------------- |
| `Content-Type`  | `application/json` | Required for all requests |
| `Authorization` | `Bearer sk-xxx`    | Your KiosAPI key          |

### Request Body

<ParamField body="model" type="string" required>
  A vision-capable model ID, e.g. `gpt-4o`. Not all models support image input — check the model's documentation before sending image content.
</ParamField>

<ParamField body="messages" type="array" required>
  An array of message objects. For vision requests, include at least one `user` message whose `content` is an array of text and image objects.

  <Expandable title="messages[]">
    <ParamField body="messages[].role" type="string" required>
      For vision requests, use `"user"`.
    </ParamField>

    <ParamField body="messages[].content" type="array" required>
      An array of content part objects. Each object must have a `type` field. Vision requests combine `text` parts and `image_url` parts in the same array.
    </ParamField>
  </Expandable>
</ParamField>

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

<ParamField body="temperature" type="number">
  Sampling temperature between `0` and `2`. Higher values produce more varied output.
</ParamField>

<ParamField body="stream" type="boolean">
  When `true`, the response is streamed back as server-sent events. Defaults to `false`.
</ParamField>

### Content Part Types

Each object in the `content` array must specify a `type`. The supported types for vision requests are:

| Type        | Required Fields | Description                                                             |
| ----------- | --------------- | ----------------------------------------------------------------------- |
| `text`      | `text`          | A plain-text prompt or instruction accompanying the image               |
| `image_url` | `image_url.url` | An image to analyze — accepts both base64 data URIs and public web URLs |

<Tip>
  `image_url.url` accepts both public web URLs (e.g. `https://example.com/image.png`) and base64 data URIs. Base64 format: `data:image/png;base64,iVBOR...`
</Tip>

### Examples

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl https://kiosapi.com/v1/chat/completions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxx" \
      -d '{
        "model": "gpt-4o",
        "messages": [
          {
            "role": "user",
            "content": [
              {
                "type": "text",
                "text": "What is in this image?"
              },
              {
                "type": "image_url",
                "image_url": {
                  "url": "https://example.com/image.png"
                }
              }
            ]
          }
        ],
        "max_tokens": 300
      }'
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import openai

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

    response = openai.chat.completions.create(
        model="gpt-4o",
        messages=[
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "What is in this image?"},
                    {
                        "type": "image_url",
                        "image_url": {"url": "https://example.com/image.png"}
                    }
                ]
            }
        ],
        max_tokens=300,
    )

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

## Response

A successful request returns a standard chat completion object. The model's analysis or description of the image appears in `choices[0].message.content`.

```json theme={null}
{
  "id": "chatcmpl-A7ETdn5hnbTjpw9dtRifjMFZYcdFW",
  "object": "chat.completion",
  "created": 1726287309,
  "model": "gpt-4o-2024-05-13",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "This image shows a cartoon-style portrait of an elderly man...",
        "refusal": null
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 265,
    "completion_tokens": 46,
    "total_tokens": 311
  },
  "system_fingerprint": "fp_992d1ea92d"
}
```

<Note>
  Vision requests consume significantly more `prompt_tokens` than text-only requests because image content is tokenized as pixel patches. Monitor your `usage.prompt_tokens` accordingly when processing large or high-resolution images.
</Note>
