Dreamer-ready. Images and Box questions aren’t yet up to our standards to call ready for production, but we’re excited for dreamers and builders to play with them. Use them to build prototypes and try ideas. The request format, the answers, and the limits on this page can change between releases, and accuracy will change as we update the models. Tell us what you build, and what breaks, on Discord.To use images or Box questions, send the
TypeSafe-Danger-Zone-Images: true header with each request that contains an image or a Box question. See Turning on images.left and right are fractions of the width, and top and bottom are fractions of the height, so the same answer works at any image size.


Request structure
A Box question has two fields:type: Always"box".instructions: What to find, and in which image. It doesn’t have to be a question: “the coffee mug inphoto” is enough.
criteria. This request finds a mug in a kitchen photo, sent as a file part with the images header:
Response structure
type: The type of TypeSafe question.box: The four edges,top,bottom,left, andright, each from 0 to 1.leftis less thanright, andtopis less thanbottom.confidence: A number from 0 to 1. Higher means the model is more sure of its answer. See Using confidence.
Reading a Box
To draw the box or crop to it, multiply each edge by the image’s width or height in pixels:Using confidence
How you act on a Box’s confidence is up to your application. A common pattern is to pick a threshold and treat answers below it with more care. There is no recommended threshold yet, so tune it on your own images. When confidence is below your threshold, you can:- Ask again on a better image. Send a larger version of the image, or crop to the region around the box at a higher resolution and ask the same Box question on the crop. Writing Box questions covers finding a small target in a large image.
- Pad the box before cropping. When a crop must not cut off any part of the target, move each edge outward before you crop.
edges as in the code above.
Writing Box questions
Name the target and the image. “The coffee mug inphoto” names what to find and where. When the request has several images, the path in backticks identifies which one to search.
The target can be a picture. Put the reference for the target image directly in the instructions:
photo”. When you can’t tell them apart in words, add a Choice with the options none, one, and several next to the Box. When the answer is several, split the image into regions and ask again on each.
Crop large images before looking for small things. A target a few dozen pixels wide in a very large image can be missed. Find the region first, for example with a Choice that has tiles of the image as its options. Then ask the Box question on that tile, and convert its edges back to fractions of the full image.
