Edition 1.0-draft. This is a living document. Until the first tagged edition the draft changes freely and is identified by its date; from then on the edition stamp identifies the vocabulary and fixture set that the Agent Skill [AGENT-SKILLS] and the conformance suite refer to.
1. Introduction
This section is informative.
A JAI document is an image compressed into words: a natural-language description and, optionally, a few rendering parameters, from which a generative model reconstructs the picture. The description is the code; the model is the decoder. Unlike two JPEG decoders, two generative decoders can produce visibly different pictures from the same document; a good description narrows the difference to what the description leaves open.
The simplest JAI document is a sentence:
Parameters follow the description, separated by semicolons:
The same document has a JSON form and a compressed file form, and all three are the same document:
data-jai attribute or the body of a data:image/jai URL:
A magical castle;model=flux;style=animeJSON form:
File form: the JSON above as a single gzip member, in a file named{ "jai" : 1 , "prompt" : "A magical castle" , "model" : "flux" , "style" : "anime" }
castle.jai, served as image/jai.
1.1. Motivation
This section is informative.
1.1.1. A description is compression
Every image format trades bits for distortion. JPEG discards detail the eye will not miss; JAI keeps only what a person would say about the picture and discards the rest. In rate–distortion terms it operates at a very low rate under a semantic rather than a pixel distortion measure: a typical document is 50 to 500 bytes for an image of any resolution, against tens of kilobytes to megabytes for a raster, and its distortion is judged in meaning and appearance (does the result show the same things, arranged and lit the same way). Like other generative codecs, it trades pixel fidelity for realism, the rate–distortion–perception trade-off [BLAU-MICHAELI].
This works because the decoder carries a prior. A generative model has learned what harbours, castles and dusk light look like, so the code only has to say which ones, where and how. Speech coding has relied on the same idea for decades: a vocoder transmits the parameters of a model of the voice instead of the waveform, and a CELP encoder chooses its excitation by running the decoder inside the encoder and keeping the closest result. JAI encoding uses the same analysis by synthesis (§ 10 Encoding images), with one difference: a CELP encoder knows the decoder exactly, while a JAI encoder does not know which model the reader will use, so it optimises for a set of likely decoders: an image encoder describes an image, renders the description with the target models, compares the renders with the original, and revises the description until they match as closely as time and budget allow. A document can carry a core description shared by all models plus small per-model refinements, so that each decoder in its preference list reconstructs the image as well as it can.
The rate–distortion trade-off is the author’s to choose: a sentence for a decorative image, a few precise paragraphs for one whose look matters.
1.1.2. Where it matters
JAI is designed for a world where generating an image is cheap and local, and moving one is not.
-
Readable without seeing. A JAI image is text first. A vision-impaired reader’s screen reader speaks the author’s own description, by default the same words the model draws from, so the text alternative is always present and describes the picture (§ 11.3.2 Accessibility). A text-only AI agent reads and writes images directly, with no vision model, and can search, translate, diff and edit them in the medium it already uses.
-
Links with little bandwidth and enough compute. Ships, aircraft, spacecraft crews, satellite connections with data caps, rural networks and disaster zones can carry a few hundred bytes where they cannot carry a photograph. A receiver with a GPU reconstructs the picture. This suits illustrative and situational images, not measurements: where the pixels are the data, send the pixels (§ 1.2 What JAI is and is not).
-
Local generation. Image generation is moving onto commodity GPUs and recent phones, in seconds or less with distilled models. If browsers come to decode
image/jainatively, a browser could choose the JAI source in a<picture>element and fetch the raster only when rendering fails (§ 11.1 Carriers), so pages get lighter with no change to their markup. Today’s viewers still download the raster (§ 11.3 Viewer requirements). -
An audience of one. Because the reader’s own decoder produces the pixels, the reader can ask for them differently: adapted to their culture, softened for sensitive content, adjusted for their eyesight, in the language of the text inside the image, or simply in a mood or style they enjoy, while the author’s description stays the same (§ 11.3.3 Personalisation).
-
Longevity and resolution independence. A description does not age with its codec and has no fixed resolution. Rendered next year by a better model, or at a higher resolution, the same document yields a better picture, much as vector graphics outlive the screens they were drawn for.
-
Declared provenance. A JAI document says it is a description, and renderers label their output as generated (§ 13.10 Provenance). The format never claims that a render records an event, even when the description was encoded from a photograph.
Today, rendering usually runs on hosted providers through an API key. That is the stage this edition is published in: good for demonstrations and for personal renders, and the reason the security section spends so much care on consent, budgets and what leaves the browser (§ 13 Security and privacy considerations). The format does not depend on it.
1.2. What JAI is and is not
This section is informative.
JAI describes visual intent, not pixels. It does not specify a neural network, a sampler, a provider, or exact output. A decoder produces an image consistent with the description, not the image; the encoder can only reduce the distortion, never remove it. Decoding is non-deterministic across decoders, versions, hardware and time. With hosted providers, as today, it may also take seconds, cost money, and be refused by a provider’s content policy, and it has side effects that no other image format has: it transmits the document, and possibly an input image, to a renderer, under the account of the person viewing it.
Every JAI document also has a textual rendering that is instant, free and
always available: its description, the prompt values joined with line
breaks. A user agent that will not render pixels presents that instead.
Where exact pixels matter more than size, such as evidence, medical images,
diagrams and screenshots of text, ship the raster. JAI can still travel
alongside it as the editable, searchable source: HTML’s <picture> element
carries both (§ 11.1 Carriers).
1.3. Audiences
This section is informative.
This specification is written for six audiences: people and AI agents who write JAI; authoring tools that convert images to JAI or validate it; library developers implementing parsers and serialisers; extension developers adding parameters or renderers; browser and extension developers implementing discovery, rendering and replacement; and renderer developers turning a JAI document into a picture. Sections § 5 Text form through § 7 File form, media type and decoding are the parts a library developer needs; § 8 Standard parameters and § 9 Rendering are for renderer developers; § 11 HTML integration is for browser, extension and web developers; and § 15 Writing JAI by hand is a plain-language primer for authors.
2. Conformance
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. The same words in lower case have their ordinary English meaning.
Everything in this specification is normative except sections marked informative, examples, notes, and the appendices so marked.
2.1. Conformance classes
This specification defines requirements for the following classes. An implementation may belong to several.
- conforming document
-
A JAI document in any of its forms that satisfies every requirement placed on documents and authors (§ 4 Data model, § 5 Text form, § 6 JSON form, § 7 File form, media type and decoding, § 8 Standard parameters, § 11 HTML integration).
- parser
-
Converts the text form to a document (§ 5.4 Parsing).
- JSON reader
-
Converts the JSON form to a document (§ 6.3 Reading).
- decoder
-
Converts the bytes of a
.jaifile or animage/jairesource, and the body of adata:image/jaiURL, to a document (§ 7.4 Decoding, § 7.5 data: URLs). A decoder contains a parser and a JSON reader. - serialiser
-
Produces the canonical text form, the canonical URL form and the canonical JSON form of a document (§ 5.5 Canonical text serialisation, § 7.5 data: URLs, § 6.4 Canonical JSON).
- encoder
-
Produces the file form (§ 7.2 Encoding). An encoder contains a serialiser.
- validator
-
Reports advisory diagnostics about a document or its carrier (§ 14 Diagnostics).
- interpreter
-
Derives the interpreted parameters of a document from its values (§ 8.1 Interpretation). Every renderer and every viewer contains an interpreter.
- renderer
-
Produces an image from a document (§ 9 Rendering).
- viewer
-
Software acting for a user that discovers JAI documents in content, decides whether and when to render them, and presents the result: a browser, a browser extension, an image viewer (§ 11 HTML integration, § 11.3 Viewer requirements, § 13 Security and privacy considerations).
- authoring tool
-
Software that produces or edits JAI documents on behalf of an author.
2.2. Determinism
Parsing, reading and decoding are total and deterministic: for every input, including malformed input, a conforming implementation produces a document (possibly empty) and a set of diagnostics, and two conforming implementations produce the same document and the same parser-level diagnostics for the same input. Error recovery is therefore specified, not left to implementations. Nothing in this specification may throw, abort or produce a partial result on malformed input. The guarantee covers inputs within the minimum bounds of § 13.1 Untrusted input and bounds; beyond them, an implementation that applies its bound yields the empty document with the diagnostic named there.
2.3. Conformance test suite
The repository at github.com/gnistai/jai
holds machine-readable fixtures under tests/ (§ 14.1 Conformance fixtures). The fixtures
are normative: where the fixtures and the prose of this specification
disagree, the fixtures are correct and the prose has a bug. An implementation
may claim conformance for a class when it passes every fixture of that class
("JAI 1.0-draft conforming parser").
| Conformance class | Fixture classes it must pass |
|---|---|
| parser | parse (documents and diagnostics)
|
| JSON reader | json
|
| decoder | parse, json, decode, url
|
| serialiser | serialize (text, url, json, identity), and roundtrip except the file form
|
| encoder | as serialiser, plus the file form of roundtrip
|
| interpreter | interpret
|
| viewer | html, and everything required of a decoder and an interpreter
|
| validator | the advisories and no_advisories of every case
|
Renderers, authoring tools and conforming documents have no fixtures in this edition.
3. Terminology
- document
-
An instance of the data model (§ 4 Data model): a map from keys to lists of values, describing one image.
- key
-
The name of a parameter: an ASCII string matching the key grammar.
- value
-
One string assigned to a key. A key may have several values, in order.
- parameter
-
A key together with its values.
- standard key
-
One of the ten keys defined in § 8 Standard parameters.
- prompt
-
The values of the key
prompt: the description of the image. - description
-
The textual rendering of a document: its prompt values joined with U+000A LINE FEED, in order. Qualified keys are not part of it. It is what readers see as fallback text and accessible names.
- model description
-
What one model receives: the description followed by the values of the qualified
promptkeys that match the selected model, joined with U+000A LINE FEED (§ 8.3 Per-model refinements). Without matching refinements it equals the description. - text form
-
The human-readable serialisation of a document, used in
data-jaiattributes anddata:image/jaiURLs (§ 5 Text form):A magical castle;style=anime. - JSON form
-
The JSON serialisation of a document, the content of the file form (§ 6 JSON form).
- file form
-
The gzip-compressed JSON form (§ 7 File form, media type and decoding); the content of a
.jaifile. - canonical form
-
The unique text form or JSON form a serialiser produces for a document (§ 5.5 Canonical text serialisation, § 6.4 Canonical JSON).
- identity
-
The SHA-256 digest of a document’s canonical JSON form (§ 6.5 Identity).
- JAI whitespace
-
Exactly the 25 code points that have the Unicode
White_Spaceproperty: U+0009 TAB, U+000A LF, U+000B VT, U+000C FF, U+000D CR, U+0020 SPACE, U+0085 NEL, U+00A0 NO-BREAK SPACE, U+1680 OGHAM SPACE MARK, U+2000 to U+200A inclusive, U+2028 LINE SEPARATOR, U+2029 PARAGRAPH SEPARATOR, U+202F NARROW NO-BREAK SPACE, U+205F MEDIUM MATHEMATICAL SPACE and U+3000 IDEOGRAPHIC SPACE. No other code point is whitespace for the purposes of this specification. U+FEFF is not whitespace. - trim
-
To remove every leading and trailing JAI whitespace code point from a string.
String.prototype.trim(JavaScript),str.strip()(Python),String.trim()(Java) and the regular-expression class\seach remove a different set of code points, and none of them removes exactly this set; Go’sstrings.TrimSpacehappens to match. Implementations use the list. - ASCII lowercase
-
The string with every code point in the range U+0041 (A) to U+005A (Z) replaced by the code point 32 greater, and no other change [INFRA].
- ASCII case-insensitive
-
Two strings match ASCII case-insensitively when their ASCII lowercase forms are identical [INFRA]. Implementations MUST NOT use locale-sensitive case mapping or Unicode case folding anywhere in this specification: under those, U+0130 (İ), U+0131 (ı) and U+212A (KELVIN SIGN) would match ASCII letters.
- scalar value string
-
A string of Unicode scalar values, that is, a string containing no surrogate code points [INFRA].
- author
-
Whoever wrote a document.
- publisher
-
The site or channel that delivers a document to a user. On a site that accepts user content the author and the publisher are different parties.
- user
-
The person on whose behalf a viewer renders a document, and under whose renderer account the pixels are produced.
- original image
-
Pixels that accompany a document in its carrier: the
<img>element’s own image in HTML, or the image named by thesourcekey (§ 8.1.7 source). - carrier
-
A place in a host format where a document is found (§ 11.1 Carriers).
- provider
-
A service that runs a model for a renderer.
- layout box
-
The box HTML lays out for an element, from its attributes and CSS.
- advisory
-
Of a parameter: a preference the author expresses, which a renderer or viewer honours when it can and ignores, with a diagnostic, when it cannot; an advisory value never selects anything the user has not configured and never overrides a user setting.
4. Data model
A document is an ordered map from keys to lists of one or more values. The order of values within a key is significant; the relative order of distinct keys is not significant and carries no meaning.
A document describes exactly one image.
4.1. Keys
The key grammar is, in ABNF [RFC5234]:
key = name [ "/" target ] name = segment * ( "." segment ) target = segment segment = ALPHANUM * ( ALPHANUM / "_" / "-" ) ALPHANUM = %x61-7A / DIGIT ; a-z, 0-9
A key is a name, a non-empty sequence of segments separated by single full
stops, optionally followed by / and a target, one segment. Each segment
starts with a lowercase ASCII letter or digit and continues with lowercase
ASCII letters, digits, _ and -. A key with a target, such as
prompt/flux, is a qualified key: it holds refinements for
the models that target names (§ 8.3 Per-model refinements). Only the names
prompt, style and avoid take a target in this edition; parsers, JSON
readers and serialisers keep other qualified keys unchanged, and validators
report them with invalid-qualifier.
Keys are compared for equality after ASCII lowercase conversion: readers convert every key they receive to ASCII lowercase before anything else, so a document never contains two keys that differ only in case.
Keys without a . are reserved for this specification (§ 12 Extensibility).
The key jai is reserved and is never a parameter: in the JSON form the
member named jai identifies the object as a JAI document (§ 6.2 The jai marker);
in the text form an assignment to jai is dropped (§ 5.4 Parsing).
constructor is a valid key, and __proto__, while
not a valid key, is a valid JSON member name.
4.2. Values
A value is a non-empty scalar value string that does not begin or end with JAI whitespace and does not contain U+000D CARRIAGE RETURN or U+0000 NULL.
Every reader of every form applies the following value normalisation to each candidate value before it enters the document, in this order:
-
Replace every surrogate code point with U+FFFD REPLACEMENT CHARACTER.
-
Replace every U+000D U+000A pair, and then every remaining U+000D, with U+000A.
-
Replace every U+0000 with U+FFFD. (Other control characters are kept as content; validators report them, see § 14 Diagnostics.)
-
Trim the string.
-
If the result is empty, discard the candidate and emit the diagnostic
empty-value; otherwise the result is the value.
Values are strings and only strings. Numbers, booleans and structured data
exist only as their spelling (strength=0.6, seed=42); this is what
makes the text form able to represent every document.
No Unicode normalisation is applied anywhere in this specification. Two
strings are the same value if and only if they consist of the same sequence
of code points; canonically equivalent texts (for example NFC and NFD
spellings of the same word, or U+037E GREEK QUESTION MARK and ;) are
different values and yield different identities. Parsers MUST NOT
normalise their input.
4.3. Standard keys and repetition
A document may assign any number of values to any key; the data model does not
know which keys are single-valued. The standard keys aspect, mode,
strength, seed, source and preview are single-valued at
interpretation: an interpreter uses the last value and reports
repeated-single (§ 8.1 Interpretation). Parsers and serialisers
keep every value; identity and round-tripping depend on all of them.
5. Text form
The text form is a string. It is used in two places: the data-jai
attribute (§ 11.1 Carriers) and the body of a data:image/jai URL
(§ 7.5 data: URLs). Both already say that they hold JAI, so the text form has no
marker of its own.
5.1. Grammar
*This grammar is informative; the algorithm in § 5.4 Parsing is normative.*
jai-text = OWS [ text-segment * ( ";" text-segment ) ] [ ";" ] text-segment = assignment / prose assignment = OWS key-ci OWS "=" value ; key-ci: the key grammar, ASCII case-insensitive prose = value value = * ( escape / vchar ) escape = "\" ( ";" / "=" / "\" ) vchar = <any scalar value except ";" and "\" >/ "\" <not followed by ";" ,"=" or "\" >OWS = * ( <JAI whitespace >)
A segment is an assignment if it matches assignment; otherwise it is prose.
A \ that does not begin an escape is an ordinary character.
5.2. Structure
-
Segments are separated by unescaped
;. A segment whose text before its first unescaped=is, after trimming, a key is an assignment of the rest of the segment to that key. Every other segment is prose. -
The first prose segment is the prompt. Any later prose segment is a continuation: it belongs to the most recently assigned value, with the
;that preceded it restored. This is what lets ordinary semicolons appear in descriptions without escaping. -
Empty segments and segments consisting only of JAI whitespace are ignored, so a trailing
;and a doubled;;are harmless. -
Three escape sequences exist:
\;is a literal semicolon,\=a literal equals sign,\\a literal backslash. A backslash before any other character is itself literal, soC:\Usersneeds no escaping. -
Keys are ASCII case-insensitive;
Style=animeandstyle=animeare the same assignment. Values are never case-converted. -
Whitespace around keys, around
=and at the ends of values is ignored; whitespace inside values is preserved.
| Input | Document |
|---|---|
A magical castle
| prompt = A magical castle
|
A magical castle;style=anime;model=flux;model=sdxl
| prompt = A magical castle; style = anime; model = flux, sdxl
|
prompt=A magical castle
| prompt = A magical castle
|
model=flux;prompt=A magical castle
| model = flux; prompt = A magical castle
|
A wizard stands in a doorway; behind him, a dragon sleeps;model=flux
| prompt = A wizard stands in a doorway; behind him, a dragon sleeps; model = flux
|
A castle ; style = anime ;
| prompt = A castle; style = anime
|
source=data:image/webp;base64,UklGRkI=;style=anime
| source = data:image/webp;base64,UklGRkI=; style = anime (base64,… is not an assignment)
|
; my key=value
| prompt = my key=value (my key contains a space and is not a key; the leading ; yields empty-segment)
|
http://example.org/?a=b
| prompt = http://example.org/?a=b (: and ? are not key characters)
|
Draw a graph\; y=2x
| prompt = Draw a graph; y=2x
|
E\=mc2 explained
| prompt = E=mc2 explained
|
5.2.1. Sharp edges
This section is informative.
The assignment rule is deliberately simple, and five consequences are worth knowing. Validators report each of them (§ 14 Diagnostics).
-
A description that begins with a word, an equals sign and more text is an assignment:
E=mc2 explainedassignsmc2 explainedto the keye. Writeprompt=E=mc2 explainedorE\=mc2 explained. -
Prose after an assignment continues that assignment, not the prompt:
style=anime;A castlehas no prompt and the styleanime;A castle. Write the description first, or introduce it withprompt=. A new line does not start a parameter either; one-parameter-per-line layouts need;at the line ends. -
Whitespace is allowed around
=, soA chalkboard; e = mc2 written on itassigns toe. Writee \= mc2. -
A
data:URL whose media type carries parameters (;charset=utf-8,;name=a.png) contains;key=and is split there. Escape those semicolons (data:image/svg+xml\;charset=utf-8,…); the canonical serialiser does so. A plaindata:…;base64,URL needs nothing, becausebase64,…is not an assignment. -
A word (which may contain
.),/, a word and=, at the start of the text or after a semicolon, is a qualified key:A ratio; a/b=cassignsctoa/b, and1/2=half on a chalkboardassigns to1/2and leaves no prompt. Writea/b\=c, or start withprompt=.
5.3. Escaping arbitrary text
An authoring tool or template that places text it did not write into a
document MUST protect it. The function escape-prose(s) replaces
every \ with \\, then every ; with \; and every = with \=. For any
string s whose value normalisation is s itself, the segment
prompt=escape-prose(s) parses as exactly one prompt value equal to s, and
key=escape-prose(s) as one value of key.
The prompt= is part of the recipe: without it, text placed after another
parameter would continue that parameter’s value, and a leading U+FEFF would be
removed by the parser.
data-jai="prompt=Red mug\; model\=XZ-200\; colour\=red;style=product photo"parses to prompt =
Red mug; model=XZ-200; colour=red and style =
product photo. Without escaping, model and colour would have become
parameters and the prompt would have been cut short.
5.4. Parsing
The text parsing algorithm takes a string input and returns a document and a list of diagnostics. Transport decoding (percent-decoding, HTML attribute decoding) has already happened (§ 11.2 Transport decoding); the algorithm never decodes anything.
-
Let diagnostics be an empty list and doc an empty document.
-
Replace every surrogate code point in input with U+FFFD.
-
While input begins with U+FEFF, remove it.
-
Replace every U+000D U+000A pair in input, then every remaining U+000D, with U+000A.
-
Split input into raw segments: scan left to right; a
\followed by any code point consumes both code points as part of the current raw segment; an unescaped;ends the current raw segment and starts a new one; the end of the input ends the last raw segment. Raw segments keep their escape sequences and their whitespace. -
Let pending be an empty list of (key, raw text) pairs and let current be null.
-
For each raw segment raw, in order:
-
If raw is empty or consists only of JAI whitespace: unless raw is the last raw segment, append
empty-segmentto diagnostics; in either case continue with the next raw segment. (A trailing delimiter is allowed and not diagnosed; an interior empty segment is ignored with a diagnostic.) -
Let eq be the index of the first
=in raw that is not preceded by a\that is part of an escape sequence, determined by the same left-to-right scan as step 5. -
If eq exists and the trimmed text of raw before eq matches the key grammar after ASCII lowercase conversion:
-
Let key be that ASCII-lowercased text and rest the text of raw after eq.
-
If key is
jai: appendreserved-keyto diagnostics; set current to a discarded pair that is not in pending; continue. -
Append the pair (key, rest) to pending and set current to it.
-
-
Otherwise, if current is null: append the pair (
prompt, raw) to pending and set current to it. -
Otherwise: append
;followed by raw to the raw text of current. (If current is the discarded pair, the text is dropped with it.)
-
-
For each pair (key, text) in pending, in order:
-
Let unescaped be text with every escape sequence
\;,\=,\\replaced by its second character, scanning left to right so that\\;(two backslashes, then a semicolon) yields\followed by an unescaped;. -
Apply value normalisation to unescaped. If it yields a value, append that value to the list for key in doc; otherwise the diagnostic
empty-valuehas been emitted.
-
-
Return doc and diagnostics.
Trimming happens once, in step 8, so interior spacing around restored
semicolons is preserved exactly as typed (A wizard ; behind stays
A wizard ; behind), except that an ignored empty or whitespace-only segment
disappears together with one delimiter (A; ;b becomes A;b; write
A\; \;b to keep it).
The result is deterministic for every input and the algorithm runs in time linear in the length of the input.
| Input | Document | Diagnostics |
|---|---|---|
;;
| empty | empty-segment ×2
|
A castle;style=
| prompt = A castle
| empty-value
|
k=;a
| k = ;a (the empty assignment was continued)
| |
jai=1;prompt=x
| prompt = x
| reserved-key
|
A castle;jai=2;more
| prompt = A castle (more continued the dropped assignment)
| reserved-key
|
jai:A castle
| prompt = jai:A castle
| |
a\=b
| prompt = a=b
| |
A; ;b
| prompt = A;b
| empty-segment
|
a\\;style=x
| prompt = a\; style = x
| |
a\;style=x
| prompt = a;style=x
| |
mode=transform;style=anime
| mode = transform; style = anime (a document without a prompt is valid)
|
5.5. Canonical text serialisation
A serialiser takes a document whose keys and values satisfy § 4 Data model and produces one string. Serialisers MUST reject or normalise input that does not satisfy the data model (keys not lowercase, values not normalised).
-
Let segments be an empty list.
-
For each value v of the key
prompt, in order: if it is the first prompt value, v does not match the assignment pattern (optional JAI whitespace, a key, optional JAI whitespace,=, matched ASCII case-insensitively at the start of v), and v does not begin with U+FEFF (which the parser removes), append escape-value(v) to segments; otherwise appendprompt=followed by escape-value(v). -
For each qualified key whose name is
prompt, in ascending order of key by code point, for each of its values v in order: append the key,=, and escape-value(v) to segments. -
For each remaining key, in ascending order of key by code point, for each of its values v in order: append the key,
=, and escape-value(v) to segments. -
Join segments with
;and return the result.
escape-value(v) is one left-to-right pass over v that inserts a
\ before:
-
a
\that is immediately followed by;,=or\, or that is the last code point of v (the serialiser, or a later concatenation, will place a delimiter after it); -
a
;that is the first code point of v, or that is followed by optional JAI whitespace and then either the end of v, another;, or a key (matched ASCII case-insensitively) followed by optional JAI whitespace and=.
Each decision looks at the original v, never at text already escaped. As an
ECMAScript regular expression, with WS standing for the JAI whitespace
class and KEY for the key grammar (case-insensitively):
v. replace( /\\(?=[;=\\]|$)|^;|;(?=WS*(?:$|;|KEY WS*=))/gi , m=> '\\' + m)
WS and KEY are placeholders for the class and the pattern to substitute.
Implementations that escape in two passes MUST escape backslashes first. =
is never escaped by the serialiser; the prompt= form protects the one place
where it matters.
This escaping is deterministic and regular; it escapes a superset of the characters that would be significant and is not the shortest possible encoding. The canonical form of ordinary prose stays readable:
| Document | Canonical text |
|---|---|
prompt = A wizard stands; behind him, a dragon; model = flux
| A wizard stands; behind him, a dragon;model=flux
|
prompt = E=mc2 explained
| prompt=E=mc2 explained
|
prompt = ;-) a smiley
| \;-) a smiley
|
prompt = ends with backslash\; style = x
| ends with backslash\\;style=x
|
prompt = a;;b
| a\;;b
|
prompt = A list; item=1
| A list\; item=1
|
prompt = C:\Users\me
| C:\Users\me
|
style = anime; prompt = A castle; model = flux, sdxl
| A castle;model=flux;model=sdxl;style=anime
|
Parsing the canonical text of a document yields that document, and serialising the result yields the same text (the canonical form is a fixed point). The conformance suite checks both properties.
5.6. Bidirectional text
This section is informative.
The structure of the text form is left-to-right: keys and delimiters are
ASCII. Authoring tools that show a document should display the canonical text
in a left-to-right container and each value with dir="auto" or
unicode-bidi: isolate, so that an Arabic or Hebrew prompt does not reorder
the delimiters around it. Trailing punctuation of a right-to-left prompt may
display beside the following ;key=; parsing is unaffected. Validators report
explicit bidirectional controls and invisible formatting characters inside
values (§ 14 Diagnostics).
6. JSON form
The JSON form is a JSON object [RFC8259].
6.1. Shape
-
The object MUST contain a member named
jaiwhose value is the JSON number1(§ 6.2 The jai marker). -
Every other member maps a key to either a JSON string (one value) or a JSON array of JSON strings (one or more values, in order). A string is equivalent to a one-element array.
-
Member names MUST be valid keys (lowercase). A conforming document contains no two members whose names are equal after ASCII lowercasing.
-
Member values are subject to value normalisation when read, so a conforming document contains no empty strings, no empty arrays and no strings that begin or end with JAI whitespace.
-
An empty array contributes no values and is not diagnosed by readers; validators MAY report it.
-
A member whose value is an object, or an array containing anything other than strings, is reserved for future revisions of this specification (§ 12 Extensibility). Conforming documents of this edition contain none.
6.2. The jai marker
The member jai identifies a JSON object as a JAI document and gives the
file form its decompressed signature: the bytes {"jai":1 followed by , or
} (§ 6.4 Canonical JSON).
Its value is the JSON number 1 (so 1.0 is accepted, because it is the same
number).
This specification does not expect to assign another value to the marker: revisions add keys and reserved member shapes, and never change the meaning of existing ones. An incompatible future format would use a different member name or media type.
Readers behave as follows:
-
value 1: proceed;
-
member absent: proceed with the diagnostic
missing-marker; -
any other integer (including 0 and negative integers): proceed best-effort with the diagnostic
unsupported-version; a viewer MUST NOT render such a document automatically; -
any other value (
"1",true,null,1.5): proceed as for 1 with the diagnosticinvalid-marker.
The text form carries no marker: it is only found where the carrier already says that it holds JAI (§ 5 Text form).
6.3. Reading
The JSON reading algorithm takes a JSON text and returns a document and diagnostics.
-
Parse the text as JSON [RFC8259]. A leading U+FEFF is not JSON whitespace and is not skipped. Texts that are not valid RFC 8259 JSON (including
NaN,Infinity, comments, trailing commas and a leading U+FEFF), and texts containing a number whose value, rounded to the nearest IEEE 754 binary64 value, is infinite (for example1e400) wherever it occurs, thejaimember included, yield the empty document with the diagnosticinvalid-json. If the top-level value is not an object, yield the empty document withinvalid-json. If arrays and objects are nested more than 32 deep anywhere in the text (the top-level object has depth 1), yield the empty document withinvalid-json. Implementations whose JSON parser recurses check this with a scan before parsing, skipping the contents of strings, so that no input exhausts the stack. -
Read the members into an insertion-ordered map keyed by the exact member name. A member name that repeats an earlier one replaces that member’s value in place and keeps the earlier position (this is what ECMAScript
JSON.parseand Pythonjson.loadsdo). Readers do not diagnose an exact repetition; validators MAY report it asduplicate-member. -
Handle the marker as in § 6.2 The jai marker, then remove it from the map.
-
For each remaining member, in map order:
-
Let name be the ASCII lowercase of the member name. If name does not match the key grammar, emit
invalid-keyand skip the member. If name isjai, emitduplicate-memberand skip it. -
Let items be the member value if it is an array, otherwise a one-element list containing the value.
-
For each item: a string is a candidate value; a number is converted to a candidate value by the ECMAScript
Number::toStringalgorithm applied to its IEEE 754 binary64 value, as RFC 8785 §3.2.2.3 specifies ([RFC8785]), with the diagnosticnumber-value;trueandfalsebecome the candidatestrueandfalsewithnumber-value;nullis skipped withempty-value; an object or an array is skipped withunsupported-member. -
Apply value normalisation to each candidate and append the resulting values, in order, to the list for name. If a member earlier in the map has a different name that also lowercases to name, emit
duplicate-keyfor name, once for this member, whether or not either member contributed values. The values of all such members are concatenated in map order.
-
-
Return the document and diagnostics.
"strength": 0.6 is forgiven, and so that it is the same in every language:
1.0 → 1, 1E2 → 100, 0.60 → 0.6, -0 → 0, 1e21 → 1e+21,
5e-324 → 5e-324. Integers beyond 253 lose precision in this
conversion; authors write such values as JSON strings (§ 8.1.6 seed
requires it). Python readers need parse_constant to reject NaN and Infinity
and a short emulation of Number::toString; the conformance suite pins the
cases.
| JSON | Document | Diagnostics |
|---|---|---|
{"jai":1,"prompt":" A castle "}
| prompt = A castle
| |
{"jai":1,"prompt":"a\r\nb"}
| prompt = a U+000A b
| |
{"jai":1,"Prompt":"a","prompt":"b"}
| prompt = a, b
| duplicate-key
|
{"jai":1,"strength":0.60,"acme.hdr":true}
| strength = 0.6; acme.hdr = true
| number-value ×2
|
{"jai":1,"seed":12345678901234567890}
| seed = 12345678901234567000
| number-value (precision lost)
|
{"jai":1,"prompt":["a",null,"",["b"],{"x":1}," c "]}
| prompt = a, c
| empty-value ×2, unsupported-member ×2
|
{"jai":"1","prompt":"x"}
| prompt = x
| invalid-marker
|
{"jai":2,"prompt":"x"}
| prompt = x
| unsupported-version
|
{"prompt":"x"}
| prompt = x
| missing-marker
|
{"jai":1,"__proto__":"x","prompt":"x"}
| prompt = x
| invalid-key
|
6.4. Canonical JSON
The canonical JSON form of a document is the following byte sequence, and every serialiser produces exactly it:
-
UTF-8 without a byte order mark; no whitespace outside strings.
-
Members in this order:
jai, thenpromptif present, then the qualified keys whose name ispromptin ascending code point order, then every other key in ascending code point order of the key. -
The value of
jaiis1. Every other member’s value is a JSON string when the key has one value and a JSON array of strings when it has several. -
Strings are serialised exactly as RFC 8785 §3.2.2.2 [RFC8785] specifies:
"as\",\as\\, U+0008, U+0009, U+000A, U+000C and U+000D as\b,\t,\n,\fand\r, every other code point below U+0020 as\ufollowed by four lowercase hexadecimal digits, and every other code point, including U+007F, U+2028, U+2029 and all non-ASCII, literally.
Because values are scalar value strings, canonical JSON never contains surrogate escapes.
jai, then prompt, then the qualified prompt/… members come
first, so that every file begins with the bytes {"jai":1 followed by , or
} after decompression and a reader can see the description first. An
implementation can run a JCS library and then move jai, prompt and the
prompt/… members, in that order, to the front; the string and number rules
are identical. Fixture ser-qualified-order catches the common mistake of
moving only jai and prompt. In JavaScript the
canonical form is JSON.stringify of an object built in this member order;
in Python, json.dumps(obj, ensure_ascii=False, separators=(',', ':')) with
members inserted in order; Go callers need SetEscapeHTML(false).
anime; prompt = A castle, with a moat; model = flux.
{ "jai" : 1 , "prompt" :[ "A castle" , "with a moat" ], "model" : "flux" , "style" : "anime" }
6.5. Identity
The identity of a document is the SHA-256 digest of its canonical JSON form, written as 64 lowercase hexadecimal digits.
Identity is syntactic: two documents are the same document if and only if
their canonical JSON forms are byte-identical. Documents that differ in any
member, including preview, vendor keys, or the spelling 16x9 versus
16:9, are different documents. Identity is the same whichever form or
carrier delivered the document, and whatever whitespace, key case or key
order the author used.
Identity names a document, not a render. A render cache key MUST include,
besides the identity, the renderer and its configuration, the selected model, any personalisation (§ 11.3.3 Personalisation), and the identity of
every image input the render used (an explicit source or the carrier’s
original image). See also § 13.7 Caches.
Identity is public information and MUST NOT be used as a capability or as a key into an allow- or deny-list.
7. File form, media type and decoding
7.1. File form
The file form of a document is exactly one gzip member [RFC1952] with
compression method 8 (deflate), followed by nothing, whose decompressed
content is the canonical JSON form. A .jai file contains the file form.
Decoders MUST reject, as described in § 7.4 Decoding:
-
bytes that do not begin with a gzip header (
1F 8B), a header shorter than 10 bytes, a compression method (CM) other than 8, or a member truncated anywhere (header fields, deflate data or trailer); -
a member whose reserved FLG bits are set;
-
a CRC32 or ISIZE that does not match the decompressed content;
-
any bytes after the end of the member, including a second member;
-
decompressed output exceeding the decoder’s bound (§ 13.1 Untrusted input and bounds), which is enforced on the decompressed byte count during inflation and never read from ISIZE;
-
a header with FLG.FHCRC set whose two header-CRC bytes are not the two least significant bytes of the CRC32 of all header bytes before them;
-
a deflate stream [RFC1951] that is invalid: a block of type 3; a stored block whose LEN is not the ones' complement of NLEN; more than 286 literal/length codes or more than 30 distance codes (HLIT + 257 > 286 or HDIST + 1 > 30); a code-length code that is over-subscribed or incomplete; a literal/length or distance code that is over-subscribed, or that is incomplete unless it consists of exactly one code of length 1 (a distance code with no codes at all is accepted); a literal/length code with no code for symbol 256; a repeat code 16 with no previous length, or code lengths that run past the HLIT + 257 + HDIST + 1 lengths announced; a code in the compressed data that is assigned no symbol, a length symbol 286 or 287, or a distance symbol 30 or 31; a distance greater than the number of bytes output so far; or a stream that ends before its final block ends. These are exactly the streams zlib’s inflate rejects, so
DecompressionStream, Node’szliband Python’szlibcan be used unmodified for the deflate data. Header and trailer checks are not always included: Go’scompress/gzip, for example, accepts reserved FLG bits, second members and trailing bytes, so Go implementations parse the header themselves, inflate withcompress/flate, and then check the trailer and the end of input.
The header fields FEXTRA, FNAME, FCOMMENT, MTIME, XFL and OS are read and
ignored; FNAME is never used as a file name. Byte equality of two .jai
files is not a conformance notion: the canonical form is defined at the JSON
level.
7.2. Encoding
An encoder produces the file form from a document. Encoders MUST write the canonical JSON form as the member content. Encoders SHOULD write MTIME as 0 and SHOULD NOT write FNAME or FCOMMENT, so that files carry no timestamps or file names and tests are reproducible.
gzip -n and the default settings of most library encoders already satisfy
this. A file produced by gzip -c castle.json > castle.jai from canonical
JSON is a conforming file whatever its header fields.
DecompressionStream), runtime, language
and CDN decodes natively; it undoes almost all of the base64 inflation of an
embedded preview; and it gives the format one encoding rule instead of
"compress when large". Contexts where the twenty extra bytes matter use the
text form in a data: URL instead (§ 7.5 data: URLs).
7.3. Media type and file extension
The media type of the file form is image/jai, and its file
extension is .jai. In a data: URL the same media type labels the text form
(§ 7.5 data: URLs). Media-type parameters have no meaning. The type attribute
value image/jai (§ 11.1 Carriers) is matched by its essence, ASCII case-insensitively, ignoring parameters.
image/jai is used unregistered, as image/webp was for a decade before
RFC 9649. Appendix Appendix A. Media type registration template carries the registration template; registration
in the standards tree requires an IETF or SDO process that the project intends
to pursue once the format is stable. Should the type be registered under a
different name, viewers will match both. JAI is unrelated to JPEG AI
(ISO/IEC 6048), whose registered types are image/jaii and image/jais.
Servers SHOULD send Content-Type: image/jai for .jai resources, and, as
for web fonts, SHOULD send Access-Control-Allow-Origin: * so that scripts on
other origins can read them; a .jai resource contains no user data. Servers
send the file’s bytes as they are. Compressing them again on the fly with
Content-Encoding: gzip is harmless, because fetch() removes that coding;
a server MUST NOT declare the file’s own gzip member as a content coding,
because the decoder would then receive JSON and reject it. Decoders apply
§ 7.4 Decoding to the bytes of any resource referenced from a JAI carrier
regardless of the served Content-Type (a text/html response carries no
document, § 11.1.2 Discovery), because static hosts commonly serve unknown
extensions as application/octet-stream.
7.4. Decoding
The decoding algorithm takes the bytes of a .jai file or of
an image/jai resource and returns a document and diagnostics. These bytes are
always the file form; the algorithm never tries another serialisation.
-
Decode exactly one gzip member under the decompression bound (§ 13.1 Untrusted input and bounds). If the bytes are not a gzip member, the member is malformed in any way listed in § 7.1 File form, bytes follow it, or the bound is exceeded, return the empty document with
malformed-container, discarding any partial output. -
If the decompressed content is not well-formed UTF-8 [ENCODING], return the empty document with
invalid-json. -
Run the JSON reading algorithm on the decoded text and return its result.
There is no autodetection of UTF-16 or other encodings, no charset handling
and no byte order mark removal: content that begins with U+FEFF is not JSON
(§ 6.3 Reading).
| Bytes | Result |
|---|---|
gzip member containing {"jai":1,"prompt":"A castle"}
| prompt = A castle
|
| the same followed by a second gzip member | empty, malformed-container
|
gzip member containing A castle
| empty, invalid-json
|
gzip member containing U+FEFF and then {"jai":1,"prompt":"A castle"}
| empty, invalid-json
|
{"jai":1,"prompt":"A castle"} (uncompressed)
| empty, malformed-container
|
A castle (uncompressed)
| empty, malformed-container
|
| the bytes of a PNG file | empty, malformed-container
|
7.5. data: URLs
A document may be embedded in a data: URL [RFC2397] with the media type
image/jai. Its body is the text form, percent-encoded:
The data: URL processor of the Fetch Standard [FETCH] returns the body as
bytes, base64-decoding a ;base64 body first. If it returns failure (no
,, or a ;base64 body that forgiving-base64 rejects), or the essence of its
MIME type is not image/jai, the URL carries no document. Otherwise:
-
If the bytes are longer than the decoder’s text bound (§ 13.1 Untrusted input and bounds), return the empty document with
undecodable. -
If they are not well-formed UTF-8 [ENCODING] or contain the byte 00, return the empty document with
undecodable. (The byte 00 never occurs in text a person or tool writes.) -
Run the text parsing algorithm on the decoded text.
The body is always the text form: a JSON object in it is prose, and a
;base64 body is read as text like any other. Media-type parameters have no
meaning, and validators report any of them, ;base64 included
(data-url-parameter).
The MIME type is parsed, as Fetch does, from the
serialised URL, in which the URL parser has percent-encoded non-ASCII and
control code points, so data:image/jai followed by U+00A0 is not
image/jai.
When a serialiser or encoder writes the text form into the body of a
data:image/jai, URL it MUST percent-encode every byte of the UTF-8 encoding
that is a C0 control, U+007F, an ASCII whitespace character (U+0020 as %20,
U+000A as %0A, U+0009 as %09), % (as %25), # (as %23), " (as %22), ' (as %27), < (as %3C),
> (as %3E), & (as %26, because HTML decodes character references in
attribute values), and a ,
that would be the last byte of the URL (as %2C); a body beginning with /
is written with %2F. Every other byte, including ;, =, ,, {, }, ?, /,
+ and non-ASCII, MAY remain literal. The
canonical URL form of a document is data:image/jai, followed by
its canonical text so encoded, so that the canonical URL form can be
placed in any quoted HTML attribute without further escaping.
srcset attribute silently discards the candidate;
an unencoded # ends the URL, so everything after it is lost; a literal %
followed by two hexadecimal digits is decoded as a byte. Line breaks have to be
%0A: every URL parser deletes raw tabs and line feeds. Percent-decoding is
a transport step performed once by the URL processor; %3B and %3D become
; and = and then parse as delimiters, exactly as if typed. Only \; and
\= protect prose (§ 5.3 Escaping arbitrary text).
8. Standard parameters
This edition defines ten standard keys. Each has a meaning a renderer can act on without knowing anything about a particular model. All of them are advisory in the sense of § 3 Terminology: a renderer honours what it can and reports what it cannot (§ 9.4 Renderer diagnostics); none of them can select, fetch or configure anything the user has not configured.
| Key | Values | Form | Meaning |
|---|---|---|---|
prompt
| many | text | What the image shows. The description is the values joined with U+000A, in order. |
style
| many | text | Visual treatment: anime, watercolor, 35mm film photo. All values apply.
|
avoid
| many | text | Things or qualities the image should not contain, one per value, stated positively (people, not no people).
|
model
| many | identifier | Ordered preference list of models or rendering packages. A selector, never a locator. |
aspect
| one | W:H, WxH, decimal, square, landscape, portrait
| Preferred aspect ratio. |
mode
| one | generate, transform, keep
| How the description relates to an original image. Default generate.
|
strength
| one | decimal 0 to 1, or percentage | In transform, how far the result may depart from the source: 0 unchanged, 1 unconstrained.
|
seed
| one | integer | Reproducibility hint, passed through when the model accepts one. |
source
| one | URL or data: URL of a raster image
| The image to transform. Takes precedence over the carrier’s own image. |
preview
| one | data: URL of a tiny raster image
| Placeholder shown while rendering. Never an input to generation. |
8.1. Interpretation
An interpreter derives the interpreted parameters of a
document from its values. Interpretation never modifies the document: the
serialiser writes values as the author wrote them, and 16x9 and 16:9
remain different documents with the same interpretation.
For each single-valued standard key (aspect, mode, strength, seed,
source, preview) that is present:
-
If the key has several values, let v be the last value and emit
repeated-singlefor the key; otherwise let v be its value. Appending a parameter to a shared default string is how an author overrides a single-valued key. This does not work forprompt,style,avoidandmodel, whose values accumulate; this edition has no way to clear an inherited value (;style=is dropped withempty-value), so keep those keys out of shared prefixes. -
If v begins and ends with the same ASCII quotation mark (
"or') and is at least two code points long, remove both and trim the result (validators reportquoted-value). Then, if v ends with., remove it. -
Match v against the key’s value grammar below, ASCII case-insensitively where keywords are involved. On failure emit
invalid-valuefor the key (forsource,invalid-image; forpreview,unsupported-preview), treat the key as absent, and, where the grammar suggests one, offer the corrected spelling in the diagnostic.
The values of prompt, style, avoid and model are used exactly as they
appear in the document: no quotation mark or full stop is removed, and
§ 8.2 Model matching receives the document’s values.
Interpreters MUST NOT use lenient or locale-aware number parsers; the
grammars below are ASCII and exact. Each decimal number is converted to the
nearest IEEE 754 binary64 value, and arithmetic on it (a percentage divided by
100, a ratio W/H) is binary64 arithmetic: 33.3% is 0.33299999999999996 and
0.1:0.3 is 0.33333333333333337. Fixtures compare these numbers exactly. Non-ASCII digits, full-width characters
and the decimal comma are invalid (an authoring tool offers 0,6 → 0.6,
16:9 → 16:9).
8.1.1. prompt, style, avoid
Any value is valid. The interpreted prompt is the description: the values
joined with a single U+000A in order. What a particular model receives is the
model description and the merged style and avoid values of
§ 8.3 Per-model refinements. prompt=a;prompt=b renders as the same
input as a single value a U+000A b but is a different document. Renderers
MAY normalise whitespace for their model.
style values are combined; all apply. avoid values are independent
items; avoid=text;avoid=people and avoid=text, people reach a negative
prompt identically but are different documents. Validators report an avoid
value that begins with no, not, without or never followed by
whitespace (negated-avoid), because negation inside a negative prompt
inverts the author’s intent on most models.
8.1.2. model
Any value is valid. Values are matched against the renderers the user has
configured as described in § 8.2 Model matching. A value promises nothing: the
same model value may select different models on different days or at
different providers, and a value the user has not configured selects
nothing.
Values are opaque identifiers. Validators MAY warn when a value looks like a
URL or a file path (model-looks-like-locator), because such values are
never fetched (§ 13.3 Selectors, never locators).
8.1.3. aspect
aspect = ratio / number / "square" / "landscape" / "portrait" ratio = number OWS ( ":" / "x" / %x00D7 / "/" ) OWS number ; ABNF strings are case-insensitive number = 1* DIGIT [ "." * DIGIT ] / "." 1* DIGIT
A ratio denotes width divided by height; 1920x1080 and 16:9 denote the
same ratio, 16/9. A bare number denotes the ratio itself (1.5). Both
numbers of a ratio MUST be greater than zero. A ratio whose quotient W/H, or a
bare number, is greater than 100 or less than 0.01 is invalid. square is 1:1. landscape and
portrait express intent (wider than tall, taller than wide) without a
number; renderers SHOULD treat them as 4:3 and 3:4 unless they have a
different default for the model. W:H with integers is the canonical
spelling for authoring tools to suggest.
Renderers use the nearest ratio they support and report adjusted-value
when the result differs materially from the request. The relationship between
aspect and an original image is defined in § 9.3 Size and aspect.
8.1.4. mode
One of generate, transform, keep, matched ASCII case-insensitively.
Semantics in § 9.1 Modes and the original image. Absent or invalid: generate.
8.1.5. strength
strength = number [ OWS "%" ]
A number from 0 to 1 inclusive, or a percentage from 0% to 100% which is
divided by 100 (60% is 0.6). A value outside the range is clamped to it
with adjusted-value. 0 means the source is unchanged, 1 means the source
constrains nothing. Renderers map this linearly onto the model’s own control;
a control that measures image influence rather than departure takes
1 − strength. strength has an effect only in transform mode; validators
report strength-without-transform otherwise, and interpreters report
nothing (ignored-value is reserved for aspect and source).
8.1.6. seed
One to twenty ASCII digits. Renderers pass the value through when it lies
within the model’s accepted range and otherwise reduce it deterministically
(for example modulo the range) with adjusted-value. A seed promises
nothing across renderers, model versions or hardware; a renderer that cannot
honour it reports unsupported-parameter, and one that runs a
non-deterministic mode reports seed-nondeterministic. Authors MUST write
seeds above 253 as strings in the JSON form (§ 6.3 Reading).
8.1.7. source
A URL, absolute or relative to the carrier’s base URL, or a data: URL,
resolving to a raster image of type image/png, image/jpeg, image/webp,
image/gif or image/avif. Other types, including SVG, HTML and
image/jai, are invalid (invalid-image): a document never contains another
document as an input.
An interpreter checks a source value without fetching it. A data: value
is invalid when the data: URL processor returns failure or the essence of its
MIME type is not one of the types above. Any other value that begins with a URL
scheme (an ASCII letter followed by ASCII letters, digits, +, - or .,
then :) is invalid unless the scheme is http or https, ASCII
case-insensitively. An invalid source is reported with invalid-image and
treated as absent, so it never also yields ignored-value. A valid value’s
type is known only when it is fetched; one that cannot be fetched, or does not
decode as one of these types, is not readable (§ 13.2 Permitted inputs).
A valid source is used only in transform mode (otherwise ignored-value). When
present it takes precedence over the carrier’s original image. A source
URL is fetched only with the privileges of the document that carries it, and
only after the consent that the render itself requires (§ 13.2 Permitted inputs).
A data: value makes the document as large as the image; a URL keeps it
small.
8.1.8. preview
A data: URL of a raster image of one of the types listed for source,
RECOMMENDED at most 64 pixels on the long side and at most 1 KiB. A viewer
shows it, scaled to the layout box, while a render is pending or when no
original image exists. It is never an input to generation and never fetched
from a network. Other values are ignored with unsupported-preview.
data: URL, and shows the image’s colour layout. Hash-based
placeholders such as ThumbHash [THUMBHASH] and BlurHash [BLURHASH] are
three to four times smaller but need decoder code; a later edition might admit
them as prefixed values without affecting this edition’s viewers.
8.2. Model matching
A renderer, or a viewer choosing among configured renderers, resolves the
model values as follows. Only models the user has configured and enabled take
part (§ 13.3 Selectors, never locators).
-
For each
modelvalue v in document order:-
If v matches, ASCII case-insensitively, the identifier or an alias of an eligible model, select that model.
-
Otherwise, unless the renderer pins versions: if the last
/-separated segment of v contains:or@after its first code point, let v′ be v with the text from the last such:or@to the end removed. If v′ matches as in step 1.1, select that model and reportversion-ignored. -
Otherwise, let the words of a string be its maximal runs of ASCII letters and digits, ASCII-lowercased. A known family occurs in a list of words when the words of its name, or of one of its spellings, appear there as a contiguous run, and it has at least one eligible model. Search the words of the last
/-separated segment of v; if no family occurs there, search the words of the whole of v. If several families occur in the same search, choose the one whose run starts earliest; at the same start, the one with the longer run; then the one the renderer lists first. Select that family’s default model and reportsubstituted-model.
-
-
If no value selected a model, including when the document has no
modelvalue, use the user’s default model and reportno-matching-model. -
A model is eligible if it is configured and enabled and, in
transformmode with an input image, accepts an image input. An input image exists when the carrier offers an original image or the interpretedsourceis valid; whether it can actually be read is decided later, by the renderer (§ 13.2 Permitted inputs).
An interpreter configured with no models does not perform model matching: it
selects no model, emits no model-matching code and merges no refinement. Step 2 uses the user’s
default model even when it is not eligible; in transform mode with an
input image it is then rendered as generate with mode-degraded
(§ 9.1 Modes and the original image).
The known families are the families the renderer lists, in its order,
followed by the family of every configured model not already listed, in
configuration order; a family’s name is always one of its spellings. The
default model of a family is the user’s default model if it is eligible and
belongs to that family, and otherwise the first eligible configured model of
that family.
flux (spellings flux) and sdxl (sdxl, stable diffusion xl): black-forest-labs/FLUX.1-dev → the words of the last segment are
flux, 1, dev → family flux. stable-diffusion-xl-base-1.0 → stable,
diffusion, xl, … → family sdxl. https://example.org/flux-schnell → last
segment flux-schnell → flux (and a validator warns that the value looks like
a URL). stability-ai/sdxl:7762fd07 → no exact match; without the version
:7762fd07 it is the exact id stability-ai/sdxl (version-ignored).
replicate:stability-ai/sdxl:7762fd07 → no exact match with or without the
version; the words of the last segment, sdxl and 7762fd07, give family
sdxl (substituted-model). replicate:flux → the segment replicate:flux
without :flux matches nothing, so nothing is removed; the words replicate,
flux give family flux.
Appendix Appendix B. Model family names lists family names informatively. There is no registry of models: a renderer advertises what it knows, and the user configures what the renderer may use.
8.3. Per-model refinements
A document can carry a core description that every model receives, plus refinements for particular models in qualified keys:
A girl holding a red balloon in a park at dusk;prompt/flux=The balloon floats high above her;prompt/imagen=The balloon is glossy;model=flux;model=imagen
The selected model is the model that § 8.2 Model matching
selects, or the configured model the user chose when a viewer lets the user
override the document’s preference. When the user chose, model matching is not
run and emits no code, but mode-degraded still applies
(§ 9.1 Modes and the original image). Once a model is selected, an interpreter forms the
values the model receives for prompt, style and avoid: the core values
of the key, followed by the values of every qualified key with that name whose
target matches the selected model, in ascending code point order of the
key. A target matches when it equals, ASCII case-insensitively, the
model’s family name, its identifier or one of its aliases. The model description is formed from the prompt values; the description stays
the core.
A target is a single key segment, so identifiers containing /, ., : or
@ can never be targets, and aliases exist only in each reader’s own
configuration. Targets SHOULD therefore be family names from Appendix
Appendix B. Model family names, and renderers that support a family listed there SHOULD use the
name listed there. A target that is an alias or an identifier reaches only
readers whose configuration uses that exact name.
Qualified keys never select a model: model remains the ordered preference
list, like a font stack, and the core values are the fallback that every model
receives. Qualified keys whose target does not match the selected model are unused,
without a diagnostic.
Because refinements follow the core, a model that reads only the start of its input, such as one with a 77-token text encoder, may never see them. Authors who refine for such a model keep the core short, with the essentials first.
A refinement can change what the image shows for that model, including
removing the core subject through avoid/<target>. Viewers therefore show the
refinements that apply wherever they show the core (§ 13.5 Consent, budgets and cancellation,
§ 13.8 Viewer UI hygiene), and renderers never forward a qualified key except through
this section (§ 13.4 Parameter forwarding).
An image encoder typically evolves the core first and then adds refinements for the models in its preference list.
8.4. Never document intent
The following are settings of the user’s renderer, never parameters of a document, and renderers MUST NOT let any key, standard or vendor, set them: output format, number of candidates, quality or speed tier, resolution beyond the layout box, safety and moderation settings, provider endpoint, credentials, and anything that affects billing. See § 13.4 Parameter forwarding.
9. Rendering
A renderer turns a document into an image. This section defines what every renderer MUST do with the interpreted parameters and what it MUST report; how it produces pixels is outside this specification.
Renderer checklist (informative):
-
compute the interpreted parameters (§ 8.1 Interpretation);
-
select the model (§ 8.2 Model matching);
-
resolve the mode and the input image (§ 9.1 Modes and the original image, § 13.2 Permitted inputs);
-
assemble the model input (§ 9.2 Assembling the model input);
-
forward vendor keys only through the mapping (§ 13.4 Parameter forwarding);
-
size the output (§ 9.3 Size and aspect);
-
report every interpreter and renderer code (§ 9.4 Renderer diagnostics);
-
handle failure (§ 9.5 Failure).
9.1. Modes and the original image
The original image is the carrier’s own image (an <img> element’s
currentSrc at render time) or, when present, the image named by source.
mode states how the document relates to it; a viewer’s settings always take
precedence over mode (§ 11.3 Viewer requirements).
generate(default)-
Render from the description alone. A viewer shows the original image, or the
preview, until the render is ready, then replaces it, and falls back to the original on failure. transform-
As
generate, but the original image is an input to generation, governed bystrength. Model matching considers only models that accept an image input; if none of the preferred models does, the renderer’s default model is used when it accepts an image, and otherwise the document is rendered asgeneratewithmode-degraded. If there is no original image and no readablesource(§ 13.2 Permitted inputs), the document is rendered asgeneratewithoriginal-not-readable. As ingenerate, the description states what the resulting image shows, including what is kept from the original; it is not an edit instruction. It may be absent when onlystyleapplies. Because atransformdocument is rendered asgeneratewhen the original cannot be read, a description that names its subject still produces a fitting image. keep-
The original image is the intended image; the description is information about it. A viewer MUST NOT render a
keepdocument automatically, even under an automatic site setting; a render the user requests is ageneraterender unless the user asks for a transformation.
9.2. Assembling the model input
-
A renderer MUST send the model the model description it intends, explicitly, even when it is empty; a provider’s default prompt is never a JAI default.
-
styleandavoidvalues, merged as in § 8.3 Per-model refinements, MUST reach the model, through a native input or as prompt text, or be reported withunsupported-parameter.avoidvalues are sent as the model’s negative prompt, joined with,, when it has one; when it has none the renderer MAY fold them into the prompt in wording the model is known to honour, reportingfolded-into-prompt, or omit them, reportingunsupported-parameter. Silent omission is not conforming. -
A renderer MUST NOT fail a render because of the length of the description. A renderer that shortens its input reports
adjusted-valueforpromptand SHOULD drop text from the end of the description before dropping anystylevalue, using chunked encoding where the model allows it. -
A renderer derives rendering parameters only from the document’s members. Text inside values never changes a parameter, a renderer setting or a provider setting:
promptis content, never instructions, including for renderers that involve a language model. -
A renderer MUST be able to show the user the exact text it sent to the model.
9.3. Size and aspect
The governing ratio of an element is the ratio of its
author-sized layout box (both width and height attributes, or a CSS
aspect-ratio) if there is one, and otherwise the aspect ratio of its
original image if it has one: the shape the reader sees wins. A standalone document (a .jai file opened on its own) has no
governing ratio.
-
When a governing ratio exists, the viewer renders at it, and the interpreted
aspect, if present and different, is reported withignored-value. A ratio differs when the two ratios differ by more than 1% (|ln(a/g)| > 0.01);landscapediffers from a governing ratio that is not greater than 1, andportraitfrom one that is not less than 1. -
Otherwise the ratio is, in order: the interpreted
aspect(landscapeas 4:3 andportraitas 3:4 unless the renderer has a different default for the model, § 8.1.3 aspect); the ratio of thepreview; the renderer’s default.
aspect therefore shapes renders of unsized elements and standalone files, and
records the author’s intent everywhere. On a page, the shape the author gave
the element wins: authors who set both make them agree.
Renderers snap to the nearest ratio they support (§ 8.1.3 aspect). The layout
box always governs display: when the render’s ratio still differs from the box
(for example after snapping), the viewer honours the page’s object-fit and
object-position; if the page sets neither, it crops the render to cover the
box, centred. A viewer MUST NOT stretch a render to a box of a different ratio.
Viewers SHOULD request a render no smaller than the element’s displayed CSS size multiplied by the device pixel ratio, within the user’s cost policy, and never larger than the user’s configured maximum.
9.4. Renderer diagnostics
A renderer MUST NOT refuse to render a valid document because of the value of
any standard key, and MUST report, with every code of class renderer or
interpreter in § 14 Diagnostics, every standard key it did not honour as
written. A viewer MUST make those reports available to the user.
9.5. Failure
A render fails when it produces no usable image: a provider or network error,
a refusal or content filter (including a blank or black frame), a timeout,
or a cancellation. On failure a viewer MUST restore the original image, or in
the absence of one the preview or the description, MUST NOT leave a
permanent placeholder, and MUST NOT retry with altered model input (the
description, refinements, style, avoid, the selected model or a
personalisation). A refusal is a normal outcome: viewers MUST NOT rewrite the
model input, or let a document cause it to be rewritten, to evade a refusal.
After a failure, a render with a different model or personalisation happens
only when the user explicitly requests it in viewer-owned UI, and a viewer
MUST NOT suggest a personalisation as a remedy for a refusal.
10. Encoding images
This section is informative.
An image encoder produces a document from an existing image. It is a tool, not a conformance class: its output is an ordinary document, and the encoder class above only concerns the file form. Nothing here constrains how an image encoder works; the section describes the approach that the compression view in § 1.1.1 A description is compression suggests, and the conventions that make encoded documents easy to recognise and reuse.
10.1. Analysis by synthesis
An image encoder searches for the description whose renders look most like the original, using the target models themselves as the decoder:
-
Measure the original. A vision model lists the main subjects with their bounding boxes, the prominent people with their boxes and what can be seen of them, the horizon’s height and shape, the camera, the light and the medium; the palette and lightness come from the pixels. This measurement is the yardstick for every render.
-
Describe. The vision model writes first descriptions of the original, following § 15 Writing JAI by hand: medium first, subject and counts, composition, light and colour, literal text in quotes.
-
Render. Each candidate is rendered with every target model and a few fixed seeds, so that differences between candidates come from the text and a lucky seed does not decide.
-
Measure the renders. Each render is measured the same way, looking for the original’s subjects by name. The fitness is computed from the differences (positions, sizes, people, horizon, palette, lightness), not judged: computed scores are stable between calls and comparable across runs. A candidate’s fitness blends its mean and its worst score across the target models, so that the core does not sacrifice one model.
-
Optimise from the history. An optimiser sees the original’s measurements and the best earlier candidates with their scores and their measured differences in words, largest first ("the Earth is 1.7× too tall and 7% of the frame too high; the ground is too bright"), and writes the next candidates. Seeing what was tried and what moved the numbers is what lets it make progress instead of repeating itself.
-
Refine per model. Models that still lag get short per-model refinements written the same way from their own measurements, kept only when they raise that model’s score.
-
Stop. At a target fitness, on a plateau, a time limit or the budget. Independent restarts can share the budget; the best by fitness wins.
People need more than boxes. Viewers look at people first and notice at once when a render changes who is in the picture, though not that a face differs in detail: what has to survive encoding is the same kind of person, not the same face. Each prominent person is therefore read for visible traits from closed lists, such as apparent age and gender, skin tone, hair, eye colour, the shape of the eyelids, nose, lips and face, clothing and pose, so that two readings compare word for word, and facial detail is read only where the face is clear. Render people pair with the original’s by place and look together. A person weighs more the taller they appear in the frame, a person of another kind counts as much as a missing one, and people together weigh at most as much as everything else measured, so that a crowd does not drown the composition. The descriptions name those features, never an ethnicity or nationality in their place: a group label pulls a render toward a stereotype of the group, the features toward this person. They name skin tone and hair colour for every person in whom they are visible, light skin as much as dark, because a model fills in its own default for whatever a description leaves out. A candidate that names a group or likens someone to a named person is not rendered at all, so the loop cannot select it. Nothing in the loop identifies anyone.
This resembles the loop a CELP speech coder runs, with a description in place of codebook indices and a generative model in place of the synthesis filter, except that the decoders are a set of likely models rather than one known decoder. The result is a code tuned to the decoders the author chose. Other models still receive the core description, which remains a faithful general description of the image.
The quality of an encoded document is bounded by its decoders: a model that cannot draw hands, legible text or exact counts will not do so because the description is better. Holistic similarity scores (image embeddings, a vision model’s 0 to 100 rating) are poor guides: embeddings rate every render of the right subject alike, and ratings drift between calls, so an evolutionary loop driven by them selects almost at random. Measured differences fed back as numbers are what make the loop converge.
10.2. Output conventions
These conventions keep encoded documents portable and editable, as if a person had written them by hand:
-
promptholds the core description, complete enough for any model;prompt/<target>(and, rarely,style/<target>oravoid/<target>) holds the per-model refinements. Refinements are descriptions, never instructions (§ 9.2 Assembling the model input). The target is the model’s family name (§ 8.3 Per-model refinements); when two target models share a family, the encoder refines neither, or the family as a whole, rather than using names other readers do not have. -
modellists the target models, best-scoring first, so that viewers that have several of them prefer the one that reproduced the image best. -
aspectis the ratio of the original’s pixel dimensions, reduced to small whole numbers when |ln(written/original)| < 0.01 (so that it never differs from the original in the sense of § 9.3 Size and aspect); a ratio beyond 100:1 or 1:100 is written as100:1or1:100, the limits of the grammar. -
seedis left out unless the author wants exact reproduction with one model: a description tuned on one seed is still meant to work on any. -
preview, when wanted, is a tiny placeholder derived from the original, within the bounds of § 8.1.8 preview. -
Scores and the encoder’s settings, when recorded at all, go in the tool’s own vendor keys. Because vendor keys are part of the identity and add bytes, published documents usually leave them out and keep the report beside the document instead.
-
The original image is not embedded. An encoded document describes the original; it is not a copy of it, and it does not carry the original’s provenance or rights information (§ 13.10 Provenance).
11. HTML integration
11.1. Carriers
A document reaches an <img> element through one of three carriers. The
order below is the precedence a viewer applies when one element carries more
than one; it is not a recommendation (§ 11.1.1 Choosing a carrier says which to use).
Each carrier also marks the image as JAI: a plain <img> with ordinary
alt text is never a JAI image.
- picture carrier:
<picture>with<source type="image/jai"> -
This is HTML’s own format negotiation: a browser that does not support< picture > < source type = "image/jai" srcset = "castle.jai" > < img src = "castle.png" alt = "A castle at dusk" > </ picture > image/jaiskips the<source>without fetching it and shows the raster [HTML].srcandaltstay untouched, the.jaiis fetched only when a viewer wants to render, and a browser that one day decodesimage/jainatively needs no markup change. Thesrcsetmay name a.jairesource or hold adata:image/jaiURL. Thealtis the page’s own text and need not equal the description: it is written for readers of the page, often shorter. - attribute carrier: the
data-jaiattribute, withaltas the prompt unlessdata-jaigives one -
The attribute holds the text form. When it gives no< img src = "castle.png" alt = "A magical castle at dusk, seen from below" data-jai = "style=anime;prompt/flux=Lit windows glow warm" > promptvalue, the element’salttext is the prompt, taken literally and never parsed:altis both what screen readers speak and what the model draws, and nothing is written twice. Text that only the model needs (camera terms, framing fractions, qualified keys) goes indata-jaiand is not read aloud. An emptydata-jaimarks an image whosealtis its whole description:<img src="castle.png" alt="A rich description…" data-jai>.When the model needs more than readers should hear, the prompt goes at the start of
data-jai, andaltstays the page’s own text:< img src = "castle.png" alt = "A magical castle" data-jai = "A magical castle at dusk, seen from below. Mist fills the valley;style=anime" > data-jaiis never read as the JSON form: a JSON object in it is prose. - src carrier:
srcis adata:image/jaiURL or a.jaifile -
The pure form: the image is the description and there are no fallback pixels. In every current browser it is an unavailable image whose< img src = "castle.jai" alt = "A castle at dusk" width = "800" height = "600" > < img src = "data:image/jai,A%20red%20bicycle%20leaning%20against%20a%20whitewashed%20wall,%20afternoon%20sun" alt = "A leaning red bicycle, afternoon sun" width = "1024" height = "1024" > alttext is what the reader sees (§ 11.1.3 Requirements for the src carrier). The document is the resource alone:altis not used, and is the page’s own text, usually shorter than the description. In Markdown this is.
The picture and src carriers are HTML’s own image slots and the only carriers
a user agent that decodes image/jai natively implements: decoding an image
turns bytes into pixels and never sees the element’s alt, so documents in
those slots are complete on their own and travel as files or URLs. The
attribute carrier is defined for scripts and extensions acting for a user;
a native user agent ignores it unless the user enables such a viewer.
11.1.1. Choosing a carrier
This section is informative.
-
The attribute carrier is the everyday default when the page has a raster image: write a real description in
alt, which serves screen readers and models alike, and put settings, extra detail and per-model refinements indata-jai. It survives most sanitisers, but strict allow-list sanitisers (GitHub’s) stripdata-*, and only scripts and extensions read it. -
The picture carrier is the path a native user agent takes, and the form for hosts that strip
data-*but keep<picture>. The description lives in the.jairesource ordata:URL, andaltstays the page’s own text. -
The src carrier is for images that have no pixels at all: JAI-only content, Markdown, documents produced by an image encoder, and documents reused across pages. A
.jaifile keeps the markup short; adata:URL keeps everything in one tag.
11.1.2. Discovery
A viewer runs discovery over the <img> elements of a document in
tree order, descending into open shadow roots (an open shadow root’s tree is visited immediately after its host element and before the host’s children) and skipping closed ones, and
re-runs it when the page changes src, srcset, media, type,
data-jai or alt, or the children of a <picture>. Discovery MUST NOT
depend on the image having been fetched or having failed: lazily loaded
images fire no events until they approach the viewport. Discovery never
fetches: a .jai resource is fetched only when the user opens the image’s
controls or a render starts (§ 13.2 Permitted inputs).
For an <img> element:
-
If the element’s parent is a
<picture>: consider each<source>that precedes the<img>among the parent’s children, in tree order, whosetypeattribute has the essenceimage/jaiand whosemediaattribute is absent or matches the environment. Parse itssrcsetwith HTML’s parse a srcset attribute algorithm [HTML]; a candidate whose descriptors are invalid is dropped exactly as HTML drops it. If no candidate remains, skip the<source>(validators reportsrcset-unparseable). Otherwise let url be the first candidate’s URL; descriptors play no further part. If url is adata:URL and the data: URL processor [FETCH] returns failure, or returns a MIME type whose essence is notimage/jai, skip the<source>. Otherwise the document is the resource at url, resolved against the element’s base URL, and no later<source>is examined (picture carrier).widthandheighton the<source>are layout hints. An implementation that cannot evaluate media queries treats everymediavalue as matching. -
Otherwise, for a script or extension viewer: if the element has a
data-jaiattribute, the document is its value parsed with the text parsing algorithm; if that document has nopromptvalue (qualifiedprompt/…keys do not count) and the element’saltattribute, after value normalisation (which emits no diagnostic here), is not empty, thealtis its singlepromptvalue (attribute carrier). -
Otherwise, if the element has no
srcsetattribute and no<source>precedes it in a<picture>parent (otherwise HTML never usessrc; validators reportsrc-shadowed), let url be itssrcattribute parsed against the base URL (src carrier):-
if url is a
data:URL that the data: URL processor accepts and whose MIME type essence isimage/jai, the document is its body (§ 7.5 data: URLs); -
otherwise, if url is an
httporhttpsURL whose path, as the URL parser leaves it, ends in.jai(ASCII case-insensitively; the query and fragment play no part), the document is the resource at url.
-
-
Otherwise the element carries no document.
The user agent decodes image/jai natively, or the address delivered pixels
(a service worker or content negotiation), and the viewer stands down, if the
element’s currentSrc is the URL selected in step 1 or step 3 and the element
is complete with a natural width greater than zero. This is checked when a
render starts, never during discovery. A fetched resource that is served as
text/html, or that does not decode as JAI, carries no document; the viewer
removes its control without reporting a failure.
A native user agent decides by the response’s media type, whatever the URL;
a script or extension viewer takes the picture carrier’s resource by its
type attribute and the src carrier’s by the .jai path, and decodes a
fetched response as the file form (§ 7.4 Decoding). Servers SHOULD send Content-Type: image/jai
(§ 7.3 Media type and file extension); many static hosts send application/octet-stream, which
script viewers accept and native user agents may not.
A <source> without a type attribute is selected by the browser and
yields a broken image; validators report source-missing-type. A <source>
after the <img> is ignored by HTML (source-after-img). A JAI URL MUST NOT
appear in the <img>’s own srcset. Authors place the image/jai source
before raster sources when JAI-capable user agents should prefer it; an
extension’s discovery does not depend on the order. A document with
mode=keep in the picture or src carrier is unusual, since a native decoder
would then never show the raster, and a src image has none
(keep-in-source).
image/jai natively would select the JAI source
and never load the raster original; mode then applies only with an
explicit source. HTML never re-selects a source after a decode fails, so
native support will need a rule that a declined or failed render re-selects
the next candidate; the editors intend to raise this with the HTML
Standard’s maintainers when a native implementation exists.
11.1.3. Requirements for the src carrier
An <img> whose src is a data:image/jai
URL or a .jai resource:
-
MUST have a non-empty
altthat is prose; in every current browser thealtis what the reader gets. It need not repeat the description; -
SHOULD have
widthandheightattributes or a CSSaspect-ratio, since it has no intrinsic size until a render arrives (missing-size). Images written in Markdown have none; a viewer then lays the render out at the ratio § 9.3 Size and aspect chooses, at the available width; -
MUST NOT have a
srcset, and SHOULD NOT be the<img>of a<picture>with any<source>(src-shadowed).
Authors are warned that pages without a JAI viewer show an unavailable
image; that onerror handlers and lazy-loading libraries rewrite a broken
image’s src, which ends the src carrier (discovery re-runs on src
changes); that a Content
Security Policy must list data: in img-src for the data: form; and that
the browser requests a .jai file in src itself, with the page’s cookies
and referrer, before any viewer does, so the src form saves no bandwidth
today. When fallback pixels exist, the attribute or picture carrier is the
better choice. The inline pure form with a fallback is the picture carrier
with a data: URL in srcset:
< picture > < source type = "image/jai" srcset = "data:image/jai,A%20magical%20castle;style=anime" > < img src = "castle.png" alt = "A castle" > </ picture >
11.1.4. Serving .jai resources
This section is informative. See § 7.3 Media type and file extension for the server
requirements. A script on another origin can read a .jai resource only when
it is served with CORS headers; browser extensions with host permissions
fetch it from their privileged context but are still bound by
§ 13.2 Permitted inputs for any image input. Appendix Appendix C. Serving .jai files gives server mappings.
11.2. Transport decoding
Exactly one transport decoding is applied per carrier, before the decoding algorithm or the text parsing algorithm runs:
-
data:URL (picture carrier with adata:URL insrcset, or src carrier): parse the attribute value against the document’s base URL and run the data: URL processor of the Fetch Standard [FETCH]. The fragment is excluded; the percent-decoding is the URL Standard’s byte-level percent-decode [URL], which leaves a%not followed by two hexadecimal digits in place and never fails. Read the resulting bytes as in § 7.5 data: URLs. -
http(s) URL (picture or src carrier with a
.jairesource): the response body, decoded with § 7.4 Decoding regardless of the servedContent-Type, except that atext/htmlresponse carries no document. -
the
data-jaiattribute (attribute carrier): no transport decoding; the attribute value, as the HTML parser produced it, is the input.
No second percent-decoding is ever applied. Implementations MUST NOT use
decoders that throw on malformed input (decodeURIComponent) in a transport
step. Transport decoding never changes JAI syntax: %3B and %3D become ;
and = and parse as delimiters.
src attribute and reading the element’s src property give
the same data: body by construction, because the data: URL processor
starts from the parsed URL either way.
11.3. Viewer requirements
A viewer decides whether, when and how documents are rendered. The user
always wins: user settings (never render, ask, render on request, render
automatically for a site) override mode and every other author preference,
except that keep is never rendered without a user request
(§ 9.1 Modes and the original image), and the consent, budget and disclosure requirements of
§ 13.5 Consent, budgets and cancellation apply to every render.
A viewer MUST NOT present a render as saving data or bandwidth when the original image was fetched, and SHOULD NOT state any saving unless it avoided fetching the original.
11.3.1. Replacement
A viewer that replaces an image with a render:
-
MUST make the replacement effective under HTML’s image source selection and MUST verify it (the
loadevent andcurrentSrc). Settingsrcalone is a no-op when the element has asrcsetor a preceding matching<source>. RECOMMENDED: inside a<picture>, insert a viewer-owned<source>whosesrcsetis the rendered image as the first child and remove it to restore; otherwise set the element’ssrcset, recording the previous value. -
MUST keep the layout box: the element’s
widthandheightor CSSaspect-ratio, else the original’s ratio. -
MUST NOT alter
id,class, event listeners, or link ancestors, and MUST keep the element in place where possible; a replacement element carriesrole="img"and the same accessible name and description, plus the viewer’s state markings (§ 11.3.2 Accessibility). -
MUST record every state it changes and restore all of it on request and on failure, and MUST let the user compare the original and the render.
-
MUST NOT replace the same element more than once per identity per page load, and MUST NOT re-render on resize or scroll. If the page changes
src,srcsetor the<picture>children of a replaced element, the viewer treats the element as new and releases its saved state. -
SHOULD NOT, under an automatic setting, start rendering before the user agent would fetch the image (for
loading=lazy, not before it is near the viewport), and MUST NOT render elements that are not displayed. -
MUST obtain the rendered bytes itself and insert them from local data; it MUST NOT point a page element at a provider URL (which would leak the page through
Refererand reveal the provider). -
MUST confirm that a replacement loaded (
load, natural width greater than zero) and MUST NOT retry the same URL. Depending on the engine and on how the viewer is implemented, replacement loads may be governed by the page’s Content Security Policy [CSP3], under which'self'never matchesblob:and*never matchesdata:. (Chrome currently exempts loads initiated by an extension’s content script from the page’s policy; other engines and page scripts are not exempt.) When a replacement does not load, the viewer either restores the original or presents the render without a page-initiated fetch (for example anImageBitmappainted into a canvas sized to the layout box withrole="img"and the original accessible name) or in viewer-owned UI. Viewers SHOULD prefer adata:URL of the rendered bytes over ablob:URL, which more policies permit. -
Viewer UI injected into a page is subject to the page’s
style-srcandscript-src; a shadow root with constructed stylesheets avoids both.
11.3.2. Accessibility
-
A viewer MUST keep a human-written
altunchanged, includingalt="". If thealtis absent, the accessible name becomes the description with control characters removed, in full: a description is written to be read by people as well as models, and JAI sets no length limit on it. When the document has noprompt, the name is a localised generic name. Keys, URLs anddata:payloads never appear in an accessible name. -
A viewer SHOULD expose to assistive technology what it shows sighted users about the image’s state: that it was rendered by an AI model from a description, that it may differ from the publisher’s image, and that the original is available.
aria-description(oraria-describedbyreferring to an element the viewer owns) carries this;titledoes not.aria-busyis set while a render is pending. -
Per-image controls MUST be keyboard-operable and named, never hover-only.
-
Under
prefers-reduced-motionthe swap SHOULD happen without transitions. Individual replacements are not announced to assistive technology by default. -
The viewer’s own UI (consent, provider configuration, per-image controls, diagnostics) MUST be keyboard-operable and expose names, roles and states.
-
A JAI-aware user agent MAY, without rendering, expose the description as the original image’s accessible description; it MUST NOT replace a human-written
altwith it.
Generated imagery carries no authority: logos, text and interface elements inside a render are model output. A viewer MUST mark rendered images as generated in viewer-owned UI and always offer the original.
The page’s own accessibility conformance is unaffected by what a user’s agent does at the user’s request; a conforming viewer is a user agent in the sense of the User Agent Accessibility Guidelines.
11.3.3. Personalisation
At the user’s request, a viewer MAY render a document with transformations the user chose: for example a preferred style, a sensitivity or accessibility adjustment, the text inside the image translated into the user’s language, or a mood. A personalised render:
-
MUST be marked as personalised in viewer-owned UI, and SHOULD be exposed as personalised to assistive technology. Any marking placed in the page MUST be a generic "personalised" state that does not name the personalisation;
-
MUST leave the document unchanged, and the viewer MUST let the user request a render without personalisation (subject to § 13.5 Consent, budgets and cancellation) and show it in viewer-owned UI or in place; switching between the two is not a new replacement under § 11.3.1 Replacement item 5;
-
is reported like any render: the text sent to the model includes the personalisation, after the model description (§ 9.2 Assembling the model input);
-
is cached separately from unpersonalised renders (§ 6.5 Identity).
Personalisation is a user setting, off by default and enabled only by an explicit user action in viewer-owned UI. A document or a page MUST NOT be able to request, enable or trigger it. A viewer MUST NOT add or change a personalisation to get past a refusal, and after a failure follows § 9.5 Failure. Because a replacement exposes the rendered pixels to the page, a personalised render can reveal that a personalisation is active and possibly what it is; viewers SHOULD let the user restrict personalisation to sites they trust and MUST NOT expose its settings to the page (§ 13.6 What leaves the browser).
12. Extensibility
-
Keys without a
.are reserved for this specification and are only assigned by a revision of it. Validators report unassigned undotted keys (unknown-key). -
Anyone may define keys of the form
vendor.name, wherevendoris a segment they control (comfy.sampler,acme.lighting). Serialisers preserve them; renderers that do not understand them ignore them; renderers that do understand them honour them only through the mapping rules of § 13.4 Parameter forwarding. -
The segment
dcis reserved for Dublin Core terms:dc.title,dc.creator,dc.description,dc.created,dc.language(a BCP 47 tag for the language of the document’s text),dc.rights,dc.license. A viewer that writes document text into a page MAY setlangfromdc.language. -
Members of the JSON form whose value is an object, or an array containing non-strings, are reserved for future revisions (§ 6.1 Shape). From the first tagged edition, revisions will add keys and member shapes and will never remove a key or change the meaning of an existing one; a key may be deprecated with a diagnostic. Sequences, variants and multi-image documents, if ever defined, will use such members or a distinct media type, never additional gzip members.
-
There is no registry: this specification is the registry of undotted keys, and each vendor owns its segment. Appendix Appendix B. Model family names and the Dublin Core list above are informative.
13. Security and privacy considerations
Decoding a JAI document has side effects that no other image format has: it transmits the document, and possibly an input image, to a renderer; the render is performed under the user’s provider account and is attributable to the user; and it usually costs money. Every requirement in this section follows from that.
13.1. Untrusted input and bounds
All JAI input is untrusted. Parsing, reading and decoding are total (§ 2.2 Determinism): no input causes an exception, a crash, a hang, or unbounded resource use.
-
Decoders MUST bound the decompressed size of a gzip member, enforced during inflation, and the size of a
data:URL body. The bounds MUST be at least 16 MiB and 1 MiB respectively; those values are RECOMMENDED. Exceeding the decompression bound yields the empty document withmalformed-container; exceeding the text bound yields the empty document withundecodable. Viewers MAY apply the text bound to attribute carriers, with the same result. -
Viewers SHOULD decode a document only when the element is displayed and a render may follow, and SHOULD cap the length of values they transmit to a renderer, reporting
value-truncated. -
Viewers SHOULD bound the dimensions of any image they decode as an input or preview (RECOMMENDED 16 megapixels) and MUST re-encode input images before transmission, which also strips their metadata.
-
A viewer never interprets a value inside a document as another document, never runs discovery because of its own insertions or modifications (only the page’s changes trigger it, § 11.3.1 Replacement), and displays a
previewonly through an image decoder, never as markup.
13.2. Permitted inputs
A viewer MUST NOT use as an input to rendering any image data that the
embedding document could not itself read. In a browser that is exactly the
data that would not taint a canvas: same-origin images, data: images and
blob: images of the page’s origin, and cross-origin images loaded with CORS
that succeeded for the document’s origin. Input pixels are obtained with the
document’s own privileges (a content script’s canvas, or a fetch applying
the document’s CORS and credential rules), never from a privileged context
that carries the user’s cookies. When the implicit original is not readable,
transform behaves as generate with original-not-readable unless a
readable source is present. Publishers who want transform on cross-origin
originals serve them with CORS headers and crossorigin="anonymous".
A source URL is fetched only with the carrier document’s privileges and
only after the consent the render requires. Renders that transmit an input
image SHOULD require a per-image confirmation that shows the image and names
its origin.
A .jai resource named by the picture or src carrier is fetched only when the
user opens that image’s controls or a render starts (including automatic
rendering the user enabled for the site), never during discovery, and each
URL at most once per page. A viewer that can fetch from a privileged context
(an extension’s background with host permissions) MUST NOT let that context
become a way for a page to reach other servers. It fetches only http and
https URLs whose path ends in .jai, without credentials, referrer or
redirects; it refuses loopback, link-local, private-network and single-label
host names when the page itself is on a public host; and it limits how many
such fetches a page can cause. A script viewer on a page with a Content
Security Policy also needs connect-src to allow the .jai host.
13.3. Selectors, never locators
model is a selector: a viewer matches its values only against renderers
and models the user has configured and enabled. A viewer MUST NOT dispatch to
a model, package, endpoint or workflow because a document names it, even
inside a configured provider’s namespace, and MUST NOT download, install,
load or execute any artefact in response to a model value or to any other
key, standard or vendor, that names weights, LoRAs, workflows, graphs or
packages. Unmatched values use the user’s default renderer with
no-matching-model and are shown to the user as text, never as a link.
Viewers SHOULD let the user mark a renderer as available only on explicit
request.
13.4. Parameter forwarding
A document, through any standard or vendor key, MUST NOT be able to cause a viewer or renderer to fetch a URL, load weights, workflows or code, select or alter the endpoint, credentials, headers, webhooks or callbacks, change safety or moderation settings, or exceed the user’s configured cost policy (candidate count, steps, resolution, duration).
A renderer MUST forward document parameters to a provider only through a
mapping it controls: standard keys through its own semantics, qualified keys
only through § 8.3 Per-model refinements, and vendor keys only
into the provider’s model-input namespace, after validating each value
against the provider’s published input schema and the user’s limits, and only
when the key is not on the renderer’s per-provider deny-list of inputs that
name artefacts, carry credentials, or affect safety, output count or billing.
A renderer MUST ignore a key it will not forward and report
parameter-not-allowed.
"Preserved when serialising" (§ 12 Extensibility) binds serialisers, not
renderers.
13.5. Consent, budgets and cancellation
-
A render is requested by the user’s agent under the user’s provider account. Viewers MUST make this visible.
-
A viewer MUST NOT render automatically on a top-level site the user has not enabled; the default for every site is "ask" or "on request". Third-party frames are enabled separately. "Always render" is an explicit per-site setting with a spending or concurrency bound.
-
Automatic rendering MUST be bounded per page and per time window and run with bounded concurrency; limits are visible to the user and reaching one stops rendering. Elements not displayed to the user MUST NOT be rendered.
-
Consent and per-image actions are taken in viewer-owned UI from trusted user events and show the site; the full
prompt,styleandavoidtext that the selected model will receive after § 8.3 Per-model refinements, with the refinements marked as such; any input image and its origin; and the configured renderer that matched. -
The user MUST be able to cancel a render; a viewer SHOULD cancel the provider job and set provider-side time limits where the API offers them, and cancels on navigation.
-
A viewer MUST NOT render automatically from a document with
unsupported-version. -
A viewer SHOULD keep a local, clearable, unsynchronised record of renders: it is a browsing history.
-
A viewer SHOULD NOT render automatically in private browsing and MUST NOT persist records from it.
13.6. What leaves the browser
A viewer sends a provider only the parameters its renderer maps and the input
image bytes it decoded and re-encoded locally. It MUST NOT send the page URL,
title, referrer, cookies, identity or other page content, and SHOULD send
image bytes rather than URLs. The viewer’s disclosure names the provider and
links its retention terms. Any in-page UI, replacement or .jai fetch
reveals to the page that the user runs a viewer, and a .jai fetch reveals it to the
host that serves the file.
Credentials of the reference viewer are stored extension-locally, used only from its background context, never exposed to pages or content scripts, requested only in viewer UI, sent only to the configured endpoint, and redacted from logs; the background context accepts a provider endpoint, allow-listed parameters and image bytes, never arbitrary URLs.
13.7. Caches
A render cache keyed by identity is a cross-site history oracle. A cached render is subject to the same per-site consent and the same user action as an uncached one, and viewers SHOULD prevent documents from distinguishing cross-site cache hits, by keying the cache on (identity, renderer configuration, selected model, personalisation, top-level site) or by applying comparable delay.
13.8. Viewer UI hygiene
Viewer UI MUST render every document value as text, never as markup; SHOULD
isolate bidirectional text (unicode-bidi: plaintext or <bdi>); MUST NOT
silently truncate (prompt, avoid, style, model and every
qualified key are fully
available); SHOULD visualise or warn on control and invisible formatting
characters; MUST show the top-level site; and MUST display the configured
renderer that matched, never the document’s model string, as the thing that
will run. The same rules
apply to playgrounds and validators, which are cross-site scripting surfaces
for preview values and generated HTML snippets.
13.9. Guidance for publishers
Sites that accept user markup and do not intend to publish JAI SHOULD strip
data-jai, data:image/jai URLs in src and srcset, src URLs whose
path ends in .jai, and <source type="image/jai">. DOMPurify’s defaults
keep all of them; strict allow-list sanitisers remove data-jai and data:
URLs but keep <picture> sources and ordinary image URLs, including .jai
ones.
A .jai referenced by URL is fetched per viewer at render time and may change
after review; publishers who need stability inline the document or record its
identity. Injection through templated prose (§ 5.3 Escaping arbitrary text) can truncate
or override a document but, because of the rest of this section, can neither
select a renderer nor spend beyond the user’s limits.
13.10. Provenance
Renderers that write files SHOULD set the IPTC digitalSourceType to
trainedAlgorithmicMedia (compositeWithTrainedAlgorithmicMedia for
transform) [IPTC-PHOTOMETADATA] and MUST NOT strip provider-applied
provenance such as C2PA manifests [C2PA] or watermarks when re-encoding.
Viewers mark rendered images as generated (§ 11.3.2 Accessibility).
14. Diagnostics
A diagnostic is a code from the table below, optionally with the key it concerns, and with any human-readable message the implementation chooses. Codes are stable identifiers; messages are not.
-
Parser codes are emitted by parsers, JSON readers and decoders. They are normative: a conforming implementation emits exactly these codes for the conditions described, and the conformance fixtures assert them.
-
Validator codes are advisory. A validator SHOULD emit them for the conditions described and MAY define additional codes.
-
Interpreter codes are emitted by interpreters, including model matching. They are normative: for the conditions described, a conforming interpreter emits exactly these codes, and the
interpretfixtures compare the interpreter codes it emits as an exact multiset, ignoring any other codes. An interpreter that also validates MAY emit validator codes alongside them.
A code that belongs to more than one class is counted once per condition,
whichever classes an implementation combines; fixtures compare only the codes
of the class under test. In validator conditions, "prompt" means the core key
prompt: qualified prompt/… keys do not satisfy them.
-
Renderer codes are emitted by renderers; a renderer MUST emit them when the condition occurs (§ 9.4 Renderer diagnostics).
-
Viewer codes are emitted by viewers.
The Key column names the key a diagnostic concerns. When it names one, an
implementation MUST attach it to the diagnostic. Fixtures write a diagnostic as
code or code:key; a fixture that writes code alone does not constrain the
key.
| Code | Class | Key | Condition |
|---|---|---|---|
empty-segment
| parser | none | An interior empty or whitespace-only segment was ignored. |
empty-value
| parser | the key of the assignment or member (ASCII-lowercased; prompt for prose)
| A value was empty after normalisation and was dropped. |
reserved-key
| parser | jai
| An assignment to the reserved key jai was dropped.
|
invalid-key
| parser | none (MAY carry the member name as written) | A JSON member name is not a valid key; the member was dropped. |
missing-marker
| parser | none | JSON object without a jai member.
|
unsupported-version
| parser | none | The jai member is an integer other than 1.
|
invalid-marker
| parser | none | The jai member is not an integer.
|
number-value
| parser | the key of the assignment or member (ASCII-lowercased; prompt for prose)
| A JSON number or boolean was converted to a string. |
duplicate-member
| parser | jai
| A member name other than jai lowercases to jai; the member was dropped. (Validators MAY also report an exact repetition of a member name with this code.)
|
duplicate-key
| parser | the key of the assignment or member (ASCII-lowercased; prompt for prose)
| Two JSON member names collided after ASCII lowercasing; values were concatenated. |
unsupported-member
| parser | the key of the assignment or member (ASCII-lowercased; prompt for prose)
| A JSON object or nested array was dropped (reserved for future revisions). |
invalid-json
| parser | none | The JSON form (the decompressed content of a .jai file or resource) is not well-formed UTF-8 JSON with an object at the top level, within the limits of § 6.3 Reading; the document is empty.
|
malformed-container
| parser | none | The bytes of a .jai file or resource are not exactly one well-formed gzip member within the bound; the document is empty.
|
undecodable
| parser | none | The body of a data:image/jai URL is not well-formed UTF-8, contains the byte 00, or exceeds the text bound, or a data-jai value exceeds a viewer’s text bound; the document is empty.
|
first-segment-assignment
| validator | the key concerned | The first segment was an assignment to a key this specification does not define (not a standard key, not prompt, style or avoid with a target, not a dotted name) and the document has no prompt.
|
invalid-qualifier
| validator | the key concerned | A qualified key whose name is not prompt, style or avoid, vendor names included.
|
unknown-key
| validator | the key concerned | A key whose name (the part before any /) has no . and is not a standard key.
|
continuation-into-single-valued-key
| validator | the key concerned | Prose continued the value of aspect, mode, strength or seed (not source or preview, whose data: URLs contain semicolons; see split-data-uri).
|
no-prompt
| validator | none | No prompt, and the interpreted mode is generate.
|
bare-key
| validator | the key concerned | A prose segment is exactly a standard key; a key=value assignment was probably intended.
|
newline-assignment
| validator | the key concerned | A value contains a line break followed by key=.
|
split-data-uri
| validator | the key concerned | An unknown key such as charset or name follows a source or preview value: an unescaped ; inside a data URL.
|
confusable-delimiter
| validator | none | A full-width or Arabic semicolon is followed by what looks like key=.
|
confusable-equals
| validator | the key concerned | A full-width equals sign follows a key. |
quoted-value
| validator | the key concerned | A value was wrapped in quotation marks. |
percent-encoded-text
| validator | the key concerned | A non-URL value contains %XX sequences and no %25.
|
control-character
| validator | the key concerned | A value contains a control character other than TAB and LF. |
invisible-char
| validator | the key concerned | A value contains U+200B to U+200D, U+2060 or a non-initial U+FEFF. |
bidi-control
| validator | the key concerned | A value contains U+202A to U+202E or U+2066 to U+2069. |
nonstandard-value
| validator | the key concerned | A valid value in a non-canonical spelling (16x9); the canonical spelling is offered.
|
invalid-value
| validator, interpreter, renderer | the key concerned | A standard key’s value does not match its grammar and was ignored. |
negated-avoid
| validator | the key concerned | An avoid value begins with a negation.
|
strength-without-transform
| validator | the key concerned | strength without mode=transform.
|
repeated-single
| validator, interpreter, renderer | the key concerned | A single-valued key had several values; the last was used. |
model-looks-like-locator
| validator | the key concerned | A model value looks like a URL or a path.
|
large-payload
| validator | the key concerned (none for the document-size condition) | A value exceeds 8 KiB or the document exceeds 64 KiB. |
unencoded-url-text
| validator | none | The body of a data:image/jai URL contains whitespace, # or a % not followed by two hexadecimal digits.
|
srcset-unparseable
| validator | none | The srcset of a <source type="image/jai"> yields no candidate under HTML’s srcset parsing (for example because of an unencoded space).
|
missing-size
| validator | none | A src-carrier image with neither both width and height attributes nor an aspect-ratio other than auto in its style attribute (expected for Markdown images).
|
attribute-split
| validator | none | An element carrying a JAI carrier has an attribute whose name contains ", ', ; or =: an unescaped quote probably ended the carrier attribute early.
|
data-url-missing-comma
| validator | none | A data:image/jai URL in a carrier has no ,.
|
data-url-parameter
| validator | none | A data:image/jai URL has a media-type parameter or ;base64.
|
source-missing-type
| validator | none | A <source> naming a .jai or data:image/jai URL has no type.
|
source-after-img
| validator | none | A JAI <source> follows the <img>.
|
keep-in-source
| validator | none | The picture or src carrier holds a mode=keep document.
|
src-shadowed
| validator | none | A JAI src (a data:image/jai URL or a .jai path) on an <img> with its own srcset or a preceding <source>, so HTML never uses it.
|
no-matching-model
| interpreter, renderer | model
| No model value selected a model (or the document has none); the default was used.
|
substituted-model
| interpreter, renderer | model
| A family match selected a model the author did not name exactly. |
version-ignored
| interpreter, renderer | model
| A version suffix of a model value was ignored.
|
mode-degraded
| interpreter, renderer | mode
| transform with an input image was rendered as generate because the selected model accepts no image.
|
original-not-readable
| renderer | mode
| transform had no readable input image. Decided when inputs are fetched; interpreters do not emit it.
|
unsupported-parameter
| renderer | the standard key concerned | A standard key could not be honoured by the model and was omitted. |
folded-into-prompt
| renderer | avoid
| avoid values were folded into the prompt text.
|
adjusted-value
| interpreter, renderer | the standard key concerned | A value was clamped, snapped, reduced or shortened. |
ignored-value
| interpreter, renderer | the standard key concerned | A value had no effect in this context (aspect with an original, source outside transform).
|
seed-nondeterministic
| renderer | seed
| The seed was passed but the mode is not deterministic. |
parameter-not-allowed
| renderer | the vendor key refused | A vendor key was refused by the forwarding rules. |
value-truncated
| viewer | the standard key concerned | A value was shortened before transmission. |
unsupported-preview
| interpreter, renderer | preview
| A preview value is not an allowed raster data: URL.
|
invalid-image
| interpreter, renderer | source
| A source value is not an allowed raster image.
|
14.1. Conformance fixtures
Fixtures live under tests/<class>/<class>.json in the specification
repository. Each file is a JSON object with class, edition and cases.
A top-level note member, where present, is an informative summary of the
file. Every case has id (unique across the suite), since and rationale. A
document is an object mapping each key to an array of strings. A diagnostic is
written code or code:key (§ 14 Diagnostics). diagnostics is compared as
an exact multiset. advisories lists validator codes that an implementation
with a validator MUST emit; other codes are allowed. no_advisories lists
validator codes that it MUST NOT emit.
parse-
input(string) →document,diagnostics; optionaladvisories,no_advisories. serialize-
document→text(canonical text),json(canonical JSON),identity(lowercase hex SHA-256); optionalurl(canonical URL form, § 7.5 data: URLs); each field is compared when present. roundtrip-
document→ the document survives, and serialisation is a fixed point of, each of: the canonical text parsed with the text parsing algorithm; the canonical URL form read as in § 7.5 data: URLs; the canonical JSON read with the JSON reading algorithm; the file form decoded with § 7.4 Decoding. json-
input(JSON text) →document,diagnostics. decode-
bytes(base64) and optionalbound(the decompression bound in bytes, default 16 MiB) →document,diagnostics. url-
url(adata:URL string) →documentanddiagnostics, read as in § 7.5 data: URLs, ordiscovered: falsewhen the URL carries no document. html-
html(a fragment parsed as HTML’s fragment parsing algorithm does, with declarative shadow roots attached; base URLhttps://example.test/page/; everymediavalue matches) →discovered, one entry per<img>that carries a document, in the order of § 11.1.2 Discovery:carrier(picture,attributeorsrc), and eitherdocumentanddiagnostics, orurl, the URL as written insrcsetorsrc, compared after resolving it against the base URL. Optionaladvisoriesandno_advisoriesapply to every<img>in the fragment, whether it carries a document or not. interpret-
document; optionalcatalog, the configured models in configuration order, each{id, aliases, family, image_input, default}(familymay be null;default: truemarks the user’s default model, otherwise the first entry is the default); whencatalogis absent the interpreter is configured with no models (§ 8.2 Model matching); optionalfamilies, the renderer’s family list, mapping each family name to its spellings, in member order; optionalhas_original(boolean, defaultfalse: whether the carrier offers an original image; it affects only the mode and model eligibility); optionalgoverning_ratio(number: the element’s governing ratio, absent for none; it is given only by this member); optionalselected(theidof a catalog entry the user chose, which is then the selected model; an id not in the catalog is ignored and model matching runs) →interpretedanddiagnostics.interpretedis compared only for the members present:description(string: the description, core only);styleandavoid(arrays of strings: the core values);model_description(string: the model description);model_styleandmodel_avoid(arrays of strings: the values the selected model receives, § 8.3 Per-model refinements);aspect(W/H as a number,squareas 1, or the stringlandscapeorportrait);mode(string, the interpreted value of themodekey,generatewhen absent or invalid);strength(number);seed,source,preview(string);model(theidof the selected catalog entry);ratio(the ratio to render at under § 9.3 Size and aspect, W/H as a number;nullwhen thepreviewor the renderer’s default decides). Otherwisenullmeans absent or invalid.diagnosticsis the exact multiset of interpreter codes.
Fixtures are append-only from the first tagged edition: a changed expectation is a new case id with an erratum, never a silent edit.
15. Writing JAI by hand
This section is informative.
-
Write the description first, as you would describe the picture to someone on the phone: what is in it, how it is arranged, the light, the colours, the medium. Ordinary punctuation, including semicolons, is fine.
-
Add settings after a semicolon, each as
name=value:;style=anime,;aspect=16:9,;avoid=text. Repeatstyleandavoidfor several items rather than listing them in one value. -
On a web page with an image, write the description in the image’s
altand the settings in adata-jaiattribute; an emptydata-jaiis enough to mark the image. When the model needs more than readers should hear, startdata-jaiwith the full description instead, andaltstays the page’s own text. For an image with no pixels, make a.jaifile with a JAI tool, or write the text in adata:image/jai,URL, and use<img src="castle.jai" alt="…">, or in Markdown. Never put JAI syntax inalt: screen readers read it aloud. -
Describe what can be seen, concretely, with the essentials in the first sentence: a listener can stop once they have heard enough, and models with a short prompt window read only the beginning. Prefer visible facts to mood words ("warm lamplight on a wooden desk" rather than "an empowering atmosphere"). A content image’s
altshould say what the image shows, not only why it is there. Describe people by what can be seen of them (age, gender, skin tone, hair, eyes, clothing), not by a group they might belong to. Name skin tone for everyone, light skin as much as dark: a model fills in its own default for whatever is left out. -
If your description itself starts with a word followed by
=, start withprompt=instead. If you need a literal;right before something that looks likename=, write\;. -
For an existing photo you want restyled, add
;mode=transformand;strength=0.6. Describe the finished picture, including what stays the same, not the change. -
Name a model only if you care:
;model=flux. It is a preference, not a command; the reader’s own setup decides. -
Check it in the playground: it shows what a reader’s software will see and offers the canonical spelling to copy.
16. Examples
This section is informative.
A lighthouse on a cliff in a storm;style=watercolor A lighthouse on a cliff in a storm;style=anime A lighthouse on a cliff in a storm;style=35mm film photo;style=grainy
A still life of pears on pewter, Dutch golden age;model=flux;model=sdxl;aspect=4:3
< picture > < source type = "image/jai" srcset = "data:image/jai,Fishing%20boats%20in%20a%20harbour%20at%20dawn,%20as%20a%20loose%20pencil%20sketch;mode=transform;strength=0.7" > < img src = "harbour.jpg" alt = "Fishing boats in a harbour at dawn" crossorigin = "anonymous" width = "1200" height = "800" > </ picture >
< img src = "team.jpg" alt = "The four founders, in casual clothes, standing in front of the brick office building on an overcast day" data-jai = "mode=keep" >
.jai file’s content, decompressed:
{ "jai" : 1 , "prompt" :[ "A magical castle on a hill at dusk, lanterns in the windows" , "Mist in the valley below" ], "aspect" : "16:9" , "avoid" :[ "people" , "text" ], "model" : "flux" , "style" : "storybook illustration" }
A brass astrolabe on velvet;comfy.sampler=euler;dc.title=Astrolabe study
Appendix A. Media type registration template
This appendix is informative until registration is pursued. It follows the form of RFC 6838 §5.6 [RFC6838].
- Type name
-
image
- Subtype name
-
jai
- Required parameters
-
none
- Optional parameters
-
none
- Encoding considerations
-
binary. A resource is the file form: one gzip member containing UTF-8 JSON. In a
data:URL the body is the text form, UTF-8, percent-encoded. - Security considerations
-
See § 13 Security and privacy considerations. Decoding transmits content to a renderer and is performed under the viewer’s account; decoders bound decompression; model references are selectors and are never fetched; documents are untrusted input and parsing is total.
- Interoperability considerations
-
A resource is always the file form (§ 7.4 Decoding); a
data:URL always carries the text form (§ 7.5 data: URLs). Renderers produce different pixels for the same document by design. - Published specification
-
This document.
- Applications that use this media type
-
Browsers and browser extensions, image generation tools, authoring tools, AI agents.
- Fragment identifier considerations
-
none
- Additional information
-
Deprecated alias: none. Magic numbers:
1F 8B(gzip), then{"jai":1followed by,or}after decompression. File extension:.jai. Macintosh file type code: none. - Person and email address to contact for further information
-
The editors, via the specification repository.
- Intended usage
-
COMMON
- Restrictions on usage
-
none
- Author
-
The editors.
- Change controller
-
The specification repository.
Appendix B. Model family names
This appendix is informative. Family names and spellings a renderer may
recognise in model values. The list implies nothing about availability.
| Family | Spellings |
|---|---|
| flux | flux, flux-schnell, flux-dev, flux-pro, kontext
|
| sdxl | sdxl, stable diffusion xl, stable-diffusion-xl
|
| sd3 | sd3, stable diffusion 3
|
| ideogram | ideogram
|
| recraft | recraft
|
| dall-e | dall-e, dalle
|
| gpt-image | gpt image, gpt-image
|
| imagen | imagen
|
| midjourney | midjourney, mj
|
Appendix C. Serving .jai files
This appendix is informative.
Apache (.htaccess):
AddType image/jai .jai
<FilesMatch "\.jai$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
nginx:
types { image/jai jai; }
location ~ \.jai$ { add_header Access-Control-Allow-Origin "*"; }
GitHub Pages serves .jai as application/octet-stream; decoders accept
it regardless (§ 7.3 Media type and file extension).
Appendix D. Stability and change policy
This appendix is informative.
-
Frozen from the first tagged edition: the data model, the text grammar and parsing algorithm, the canonical forms, the JSON shape and the file form. Until then the draft changes freely.
-
Extensible: the key vocabulary (from the first tagged edition, keys are added by revision and never removed; a key may be deprecated with a diagnostic), the reserved member shapes, the diagnostics registry.
-
Informative and expected to change: model families and server mappings.
-
The
jaimarker stays 1 across editions. Parsers accept every document of any 1.x edition. Fixtures are append-only after the first tagged edition. -
The Agent Skill states the edition it teaches.
-
Everything in the specification repository is released under CC0-1.0.
Acknowledgements
The first edition was shaped by an adversarial review of the design across grammar, authoring, web platform, security, rendering, file format, agent authoring, accessibility and prior-art lenses, whose findings are recorded in the repository’s design record.