Lunos logoLunos

Image Inputs

Use vision-capable models to inspect screenshots, classify photos, run OCR-style extraction, and answer visual questions.

Endpoint

POST /v1/chat/completions

Authentication

Authorization: Bearer YOUR_SECRET_KEY
Content-Type: application/json

Content format

{
  "type": "image_url",
  "image_url": {
    "url": "https://example.com/image.jpg"
  }
}

You can include multiple image blocks in one request. Put your text instruction first, then image blocks.

Request structure rules

  • Send image parts inside messages[].content[]
  • Use one user message with mixed content blocks when possible
  • For multiple images, add separate image_url entries
  • Per-request image count limits vary by model and provider

Image URL vs base64

  • Use URL for public images (usually lower payload and faster request handling)
  • Use base64 data URL for local/private images

Base64 example:

data:image/jpeg;base64,<BASE64_DATA>

Supported image MIME types

  • image/png
  • image/jpeg
  • image/webp
  • image/gif

Example request (URL)

cURL

curl -X POST "https://api.lunos.tech/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-2.5-flash",
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "Extract all visible product names and prices." },
          { "type": "image_url", "image_url": { "url": "https://example.com/menu.png" } }
        ]
      }
    ]
  }'

Python

import requests

response = requests.post(
    "https://api.lunos.tech/v1/chat/completions",
    headers={
        "Authorization": "Bearer YOUR_SECRET_KEY",
        "Content-Type": "application/json",
    },
    json={
        "model": "google/gemini-2.5-flash",
        "messages": [
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "Extract all visible product names and prices."},
                    {"type": "image_url", "image_url": {"url": "https://example.com/menu.png"}},
                ],
            }
        ],
    },
)
print(response.json())
const response = await fetch("https://api.lunos.tech/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_SECRET_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "google/gemini-2.5-flash",
    messages: [
      {
        role: "user",
        content: [
          { type: "text", text: "Extract all visible product names and prices." },
          { type: "image_url", image_url: { url: "https://example.com/menu.png" } },
        ],
      },
    ],
  }),
});
console.log(await response.json());

Example request (multiple images)

cURL

curl -X POST "https://api.lunos.tech/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-2.5-flash",
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "Compare these two images and explain key differences." },
          { "type": "image_url", "image_url": { "url": "https://example.com/before.jpg" } },
          { "type": "image_url", "image_url": { "url": "https://example.com/after.jpg" } }
        ]
      }
    ]
  }'
import requests

payload = {
    "model": "google/gemini-2.5-flash",
    "messages": [
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Compare these two images and explain key differences."},
                {"type": "image_url", "image_url": {"url": "https://example.com/before.jpg"}},
                {"type": "image_url", "image_url": {"url": "https://example.com/after.jpg"}},
            ],
        }
    ],
}
response = requests.post(
    "https://api.lunos.tech/v1/chat/completions",
    headers={
        "Authorization": "Bearer YOUR_SECRET_KEY",
        "Content-Type": "application/json",
    },
    json=payload,
)
print(response.json())

TypeScript

const payload = {
  model: "google/gemini-2.5-flash",
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "Compare these two images and explain key differences." },
        { type: "image_url", image_url: { url: "https://example.com/before.jpg" } },
        { type: "image_url", image_url: { url: "https://example.com/after.jpg" } },
      ],
    },
  ],
};

const response = await fetch("https://api.lunos.tech/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_SECRET_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});
console.log(await response.json());

Compatibility with legacy client format

Lunos accepts both image_url and imageUrl keys from clients, but the canonical format is:

{ "type": "image_url", "image_url": { "url": "..." } }

Lunos checklist

  • Confirm the selected model includes image in inputModalities
  • Keep image dimensions reasonable for lower latency
  • Keep text prompt specific about output format (summary, JSON fields, OCR lines)
  • Send clear textual instructions with the image for consistent output