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

# Vision

> Send images with text to vision-capable models through Yelu Chat Completions using URLs or data URIs.

Vision-capable models can analyze images alongside text. In Chat Completions, send a user message whose `content` is an array containing `text` and `image_url` parts.

## Analyze an image URL

Set `IMAGE_URL` to an HTTPS URL that the selected provider can fetch without authentication. For private content, prefer a short-lived signed URL or an inline data URI, subject to request-size limits.

<CodeGroup>
  ```bash Curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl https://api.yelu.ai/v1/chat/completions \
    -H "Authorization: Bearer $YELU_API_KEY" \
    -H "Content-Type: application/json" \
    -d "{
      \"model\": \"gpt-4o-mini\",
      \"messages\": [{
        \"role\": \"user\",
        \"content\": [
          {\"type\": \"text\", \"text\": \"Describe the image and list any visible text.\"},
          {\"type\": \"image_url\", \"image_url\": {\"url\": \"$IMAGE_URL\", \"detail\": \"auto\"}}
        ]
      }],
      \"max_completion_tokens\": 300
    }"
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const response = await fetch('https://api.yelu.ai/v1/chat/completions', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.YELU_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'gpt-4o-mini',
      messages: [{
        role: 'user',
        content: [
          { type: 'text', text: 'Describe the image and list any visible text.' },
          { type: 'image_url', image_url: { url: process.env.IMAGE_URL, detail: 'auto' } },
        ],
      }],
      max_completion_tokens: 300,
    }),
  });
  if (!response.ok) throw new Error(await response.text());
  console.log((await response.json()).choices[0].message.content);
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os
  import requests

  response = requests.post(
      "https://api.yelu.ai/v1/chat/completions",
      headers={"Authorization": f"Bearer {os.environ['YELU_API_KEY']}"},
      json={
          "model": "gpt-4o-mini",
          "messages": [{
              "role": "user",
              "content": [
                  {"type": "text", "text": "Describe the image and list any visible text."},
                  {"type": "image_url", "image_url": {"url": os.environ["IMAGE_URL"], "detail": "auto"}},
              ],
          }],
          "max_completion_tokens": 300,
      },
      timeout=120,
  )
  response.raise_for_status()
  print(response.json()["choices"][0]["message"]["content"])
  ```
</CodeGroup>

## Inline image data

Encode local images as a `data:` URL when the request stays within gateway and provider limits:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...
```

Use the correct media type, remove unnecessary metadata, resize images before encoding, and remember that base64 increases payload size by roughly one third.

## Detail controls

When supported, `detail` can be:

* `low` for faster, lower-cost coarse inspection;
* `high` for detailed inspection and small text;
* `auto` to let the model choose.

## Reliability and privacy

* Confirm the model supports vision before routing production traffic.
* Validate media type, byte size, pixel dimensions, and URL scheme.
* Block internal and link-local destinations if your server accepts user-supplied URLs.
* Use short-lived signed URLs and least-privilege object access.
* Remove sensitive metadata and redact images when required.
* Do not rely on vision output alone for identity, medical, safety, or compliance decisions.
* Ask for structured evidence such as observed text and regions, then validate it in application code.

<Note>
  Image input consumes model context and can be priced separately. Downscale to the resolution needed for the task and consult the account-specific pricing shown in the Yelu dashboard.
</Note>
