images, and judgments can read them beside the text. Brussle stores each image once, puts a reference to it in the document and names it in every evaluation that read it, so you can always see the image behind an answer.
Images help where text does, when the answer depends on other documents (a claim photo checked against its policy, a product photo against the listing it belongs to, a page scan against its previous version). Only some engines read images. Judge images says which, and what a judgment can do with them.
Send an image
Put images in the document’simages, beside attributes and state. Each name holds one image or a list of images:
POST /v1/namespaces/acme%2Fclaims
- Each image is a PNG, a JPEG or a WebP, as a base64 data URL (
data:image/png;base64,,data:image/jpeg;base64,ordata:image/webp;base64,). Writeimage/jpeg, notimage/jpg. - Send the base64 in the standard alphabet, on one line. Brussle refuses line breaks with
invalid_image. - Brussle does not fetch links, so it refuses an image sent as a URL with
invalid_image. - A name is 1 to 128 of
A-Z,a-z,0-9,_and-, as an attribute name is (limits and errors lists every rule). - The write’s response does not hold the references, so get the document to read them.
Tie an image to your data
state is your JSON, stored and read back as you wrote it. Brussle never treats anything in it as an image, whatever its shape, and an image cannot sit inside state or inside another structure.
To tie an image to a part of your data, you give the image a name and write that name in state. Here, message 17 of a claim has a photo:
POST /v1/namespaces/acme%2Fclaims
state.messages and images.msg_17 gets the message and the image. The engine gets each image with a short label that names its path (images.msg_17, for example), and the label counts toward the context’s tokens.
What the document holds
A get of the document holds a reference in place of each data URL, and a list stays a list:digestnames the image, and the same image always has the same digest.type,widthandheightdescribe the image as Brussle stored it.- A get always returns
images, with{}for a document with no images. - A query returns each row’s
imageswhen you send"include": {"images": true}, and the documents of the labelling queue also hold theirimages.
- Brussle shrinks an image that is too large. If an image covers more than 2,048 tiles of 32 × 32 pixels, Brussle scales it down until it fits, keeping its aspect ratio and its format, turning it the right way up and dropping its metadata.
- Brussle stores an image that fits exactly as you sent it, metadata included (the EXIF location of a photo, for example). An engine that reads images gets those bytes. Remove any metadata you do not want stored or sent before you write the image.
- What Brussle stores is what the engine reads. The stored image is the only copy. An evaluation names the image by its digest, so you can see the image an answer read until you erase it. Keep your originals if you need them at full size.
- Brussle stores each image once. Many documents can name it, so a write that sends an image the namespace already holds stores nothing new.
- Sending the same image again changes nothing. The same image gives the same reference, so a
patchthat sends a document’s images again makes no new revision and judges nothing again.
Write back a document that you read
A write can send the reference itself, as a get returns it. To write back a document you read, send itsimages as you read them. Brussle stores nothing again and bills each reference as its JSON only.
POST /v1/namespaces/acme%2Fclaims
- An
upsertreplaces the whole document, its images included, so an upsert withoutimagesleaves the document with no images. Send the references to keep them. - A reference can put an image into another document without sending the image again.
- References work in their own namespace only. Each namespace has its own images, so Brussle refuses a reference from another namespace with
unknown_image. Send the image itself instead.
images, and refuses a data URL with invalid_image. Write the image to a document first, then use the reference that the document returns.
Change or remove an image
images changes the way state does:
- A
patchchanges only the names it sends. Each name it sends replaces that name, and the other names stay. nullremoves a name, as in{"patch": [{"id": "claim_1042", "images": {"photos": null}}]}.- To add an image to a list, patch the name with the whole list (the references of the images you keep, and the new image).
appendnever adds an image. It adds JSON values to arrays instateonly.
patch merges.
Read an image
GET /namespaces/{ns}/images/{digest} returns the image’s bytes, where {digest} is the reference’s digest (sha256:e0db47..., for example). You can send the colon as it is or as %3A. In both SDKs, ns.image(digest) returns the image’s bytes and its type.
- Any key that can read the namespace can read its images. Read a tenant’s images on the tenant’s namespace, not on a template prefix.
- The bytes under a digest never change, so the response has
Cache-Control: private, max-age=31536000, immutable, and you can keep it. - An unknown digest gets
not_found, and a digest that is notsha256:and 64 lowercase hex digits getsinvalid_request. An erased image getsimage_erased.
Billing
- A write’s
bytes_writtencounts each image as its reference, plus the bytes of each image the write stores for the first time. A write that sends back the references you read adds only their JSON. - Each stored image counts in the namespace’s stored bytes once, however many documents name it.
- Reading an image is billed as
bytes_scanned(the image’s size, and at least what a document get costs).
Erase an image
An image stays as long as the namespace does. Deleting a document keeps its images, because the document’s evaluations still name them. Deleting the namespace deletes them. To delete one image for good, you erase it.DELETE /namespaces/{ns}/images/{digest} erases one image from the namespace, where {digest} is the reference’s digest. In the SDKs, it is ns.erase_image(digest) in Python and ns.eraseImage(digest) in TypeScript.
DELETE /v1/namespaces/acme%2Fclaims/images/sha256:e0db47...
- Brussle deletes the stored image’s bytes before the request returns, and its storage keeps no earlier version and no deleted copy of them.
- Brussle never serves the image again. From then on,
GET /namespaces/{ns}/images/{digest}returnsimage_erased(status 410), withdetails.erased_at. - References stay. Documents and evaluations keep the image’s reference (its digest,
type,widthandheight), and a read adds"erased": trueto the reference, in a document’simagesand in an evaluation’s context. An evaluation never held the image’s bytes. - Judging goes on without the image. When Brussle judges a document again, the context names the image as
{"digest": "sha256:...", "omitted": "erased"}and the engine reads the rest of the context. A read of that evaluation also adds"erased": trueto it. An erasure alone does not judge a document again, although a judging call that already started when you erased the image can still send it. - Replays skip the image. The calibration replay after an engine change, the replay after you change the engine and recipe tuning skip each stored context that sent the image to the engine. They send nothing and bill nothing for it, and the fit uses the other outcomes.
- Storage billing stops. The image’s bytes leave the namespace’s stored bytes when you erase it, so the next hourly measure of storage does not count them. The write that stored the image stays billed.
- An erasure is final in the namespace. Brussle refuses a write that sends the image’s bytes again with
image_erased(withdetails.idanddetails.path) and stores nothing. A write can still send the reference, with or without"erased": true, so you can write back a document as you read it. To remove the reference,patchits name tonullor send the list without it. - Erasing again changes nothing and returns the first erasure. A digest that the namespace never held gets
not_found. - One namespace at a time. An erasure deletes the image in this namespace only. Another namespace that holds the same image (another tenant of a template, for example) keeps its own copy, so erase it there too. Erase a tenant’s image on the tenant’s namespace, not on a template prefix.
- Erasing needs a key that can write the namespace. Your organization’s audit log records each erasure as
image.erase.
- Copies outside Brussle. An erasure does not touch an image that you or your users already read, a copy in a browser’s cache included, and the image route lets a client keep an image for a year.
- What an engine’s provider received. When an engine that reads images judged the image, its provider received it, and that provider’s own terms govern what it keeps (see where your data goes).
- Text. You cannot erase text from the evaluation log in this way.
Limits and errors
When an image breaks a rule, Brussle refuses the whole write and stores none of its images. The error’s
details.path names the image (images.photo or images.pages[2], for example), and details.id names the document. For a document with more than 16 images, details.path names the 17th image, with the names in alphabetical order. A bad image name has only details.path. Brussle refuses a write that sends more than 16 images for one document before it reads any image, and a null name (which a patch uses to remove an image) does not count.
An upsert over the 1 MB state limit also stores none of its images. A write refused for a reason that depends on the document it changes (a patch that makes 17 images, for example) can leave the images it sent stored, and you do not pay for them. The next write that names such an image pays for its bytes, once.
Images do not count toward the 1 MB of state, although a write is still at most 64 MB, counting the data URLs. Base64 makes an image about a third larger, so one write holds at most two images of 20 MB (see limits).