Resize an image for a vision model

Resize an image to the largest size a given vision model still benefits from, and report what it costs that model in tokens before and after. Every provider downscales oversized input before counting tokens, so this alone saves bytes and upload latency rather than tokens. Pass max_tokens to trade resolution for tokens: that lever is continuous on Claude, unavailable on OpenAI (cost follows the aspect ratio alone), and on Gemini reaches only a flat 258. An image already within budget is returned untouched and free (X-Pig-Billed: 0).

post/v1/optimize_for_vision

Request

  • Base URL: https://api.pictomancer.ai (the document declares no server; this is the origin it was published from)
  • URL: https://api.pictomancer.ai/v1/optimize_for_vision
  • Auth: none declared

Request body

sourcestring required

Image source: a public URL (https://...) or a base64-encoded string (optionally as a data URI like data:image/png;base64,...).

target_modelstring required

Vision model the image is being prepared for, e.g. claude-opus-5, gpt-4o, gemini-2.5-pro. Unknown ids are rejected rather than guessed: the wrong limits would silently resize to the wrong size.

max_tokensinteger nullable

Optional cap on what the image may cost the target model. Without it the image is resized to the model's own ceiling, which saves bytes and upload latency but no tokens, because every provider already downscales oversized input before counting. Set a budget to trade resolution for tokens. The response reports the cost actually achieved: on OpenAI it cannot be lowered by resizing at all, and on Gemini only down to a flat 258.

formatstring nullable

Output format: jpeg, png, webp, tiff, gif, or avif. If omitted, the original format is preserved.

qinteger nullable

Quality (1-100). Maps to libvips Q parameter.

Response

Processed image binary

unknown required

Changes

No recorded changes to this operation across all 1 revision of this API.