Images and vision

Send images alongside text to multimodal models on sference: request shapes, the detail quality tiers, how images are downscaled, limits, and billing.

Images and vision

Vision-capable catalog models accept images alongside text. Send a screenshot, a scanned document, a chart, or a product photo and ask about it: the same request shape works on /v1/chat/completions, /v1/responses, and /v1/messages.

Capability comes from the catalog, not the model name

Send an image to a text-only model and the request fails — the platform does not silently drop it. Check GET /v1/models: each entry carries a capabilities.image_input.supported flag. Route image requests to a model where it is true. The live list is on Models.

Sending an image

Base64 data URL

The portable form — works everywhere, no upload step:

import base64, os
from openai import OpenAI

client = OpenAI(base_url="https://api.sference.com/v1", api_key=os.environ["SFERENCE_API_KEY"])

with open("invoice.png", "rb") as f:
    b64 = base64.b64encode(f.read()).decode()

response = client.chat.completions.create(
    model="zai-org/GLM-5.3-Flash",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What is the total on this invoice?"},
            {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}},
        ],
    }],
)

Remote URL

If the image is already reachable over HTTPS, pass the URL directly — sference fetches it server-side:

{"type": "image_url", "image_url": {"url": "https://example.com/chart.png"}}

Responses API

On /v1/responses, images are content parts of an input item:

response = client.responses.create(
    model="zai-org/GLM-5.3-Flash",
    input=[{
        "role": "user",
        "content": [
            {"type": "input_text", "text": "Summarize this chart."},
            {"type": "input_image", "image_url": f"data:image/png;base64,{b64}"},
        ],
    }],
)

Anthropic Messages API

On /v1/messages, images are Anthropic content blocks:

{
    "role": "user",
    "content": [
        {"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": b64}},
        {"type": "text", "text": "What does this show?"},
    ],
}

Quality tiers: the detail field

Every image is normalized server-side before the model sees it, and the detail field on the image part selects the resolution tier it is normalized to. detail is per image, not per request — one request can mix tiers.

detailStored resolutionBest for
lowlongest side ≤ 384 pxthumbnails, presence checks, coarse classification
auto (default)≤ 2 MP (2,097,152 pixels)documents, screenshots, charts — the right default for almost everything
high≤ 16 MP (16,777,216 pixels)dense OCR, fine print, detailed diagrams, large UI screenshots
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}", "detail": "high"}}

On /v1/responses, put detail on the input_image part itself:

{"type": "input_image", "image_url": f"data:image/png;base64,{b64}", "detail": "low"}

Anything other than low, high, or auto is a 400. The Anthropic Messages API has no detail concept — images sent through /v1/messages always normalize at the auto tier.

Higher tiers cost more input tokens and add encoder latency, so pick the smallest tier that still answers the question. As a rough guide, an image bills on the order of a few hundred input tokens at low, ~1–2k at the auto cap, and up to ~10–15k at the high cap, depending on the model's vision encoder.

How sference downscales images

Resolution is never rejected. Any decodable image larger than its tier cap is downscaled at ingest; anything already inside the cap passes through byte-for-byte. The normalization pipeline:

  1. EXIF orientation is applied first. Phone photos carry rotation in metadata; the model always sees the upright raster.
  2. Downscale to the tier cap, preserving aspect ratio, with Lanczos resampling. Images are never upscaled — a 500 px image at high stays 500 px.
  3. Re-encode only when something changed. An image that is already inside its tier cap, in a directly servable format (PNG, JPEG, WebP, GIF), with no EXIF rotation is stored and served exactly as sent — no generation loss. Images that were rotated, downscaled, or transcoded are re-encoded as JPEG (quality 90), or PNG when the raster carries transparency.

Two consequences worth knowing:

  • Pre-downscale to skip the work. If you resize to your target tier before sending, your bytes pass through untouched and you control the resampling. Sending a 20 MP photo at auto just spends upload bandwidth — the model receives the same 2 MP raster either way.
  • The model sees the stored raster, not your original. Token count and what the encoder can resolve both follow from the post-normalization resolution. If small text is illegible in the answer, step the tier up from auto to high before assuming the model can't read it.

Limits

  • Formats: PNG, JPEG, WebP, GIF, HEIC/HEIF (the iPhone camera default — transcoded to JPEG/PNG at ingest). Animated formats are read as their first frame; the model never sees motion. Convert anything else (TIFF, BMP, SVG) before sending.
  • Size: 20 MB per image, measured on the bytes you send.
  • Count: 16 images per request.
  • Resolution ceiling: rasters above 100 MP are rejected outright as a resource guard — everything below that is downscaled, not rejected.
  • Remote URLs: HTTPS on the default port only, no credentials in the URL, and the host must resolve to a public IP address (private and loopback ranges are refused). Redirects are followed up to 3 hops and every hop is re-validated; the fetch times out after 10 seconds.
  • Throughput: 20 images per second per team across all requests; over that, intake returns 429. The API does not send rate-limit headers. There is no general per-account request limit.
  • Responses API: input_image.file_id is not supported — pass image_url.

Cost

Images bill as input tokens at the model's normal input rate — there is no separate image surcharge. Because the token count scales with the stored resolution, image-heavy workloads are sensitive to the tier you pick: low where it suffices is an order of magnitude cheaper than high. See Pricing.

Common patterns

Document extraction. Screenshot or scan → vision model at high → structured output with a schema for the fields you need. This is the highest-value use of vision in production: invoices, receipts, forms, IDs.

UI and screenshot understanding. Feed a screenshot to an agent so it can reason about layout without a browser tool. Note that coding models in the catalog are text-only — see Claude Code for how that is handled in an agent loop.

Chart and table reading. Works well at auto; ask for the values explicitly rather than "describe this", and request JSON if you intend to compute on them.

Quality control. Compare two images, or an image against a spec, with a yes/no or enum answer. low is usually enough when the question is coarse.