Skip to main content
Protocol version 1 lets any backend language support a Cogni frontend through three HTTP operations. It uses UTF-8 JSON, snake_case fields, and POST; readers ignore unknown fields but enforce all required fields.

Route map

Cogni reserves no path prefix. The host supplies all three routes during initialization:
Routes may be relative or absolute. Protect them with host authentication; credentials never belong in Cogni payloads.

Common identifiers

request_id identifies a batch; prediction_id follows one candidate. Timestamps use RFC 3339, durations use integer milliseconds, and byte counts are non-negative integers.

Capabilities

The frontend first negotiates transports, representations, and limits. The request has no Cogni body; the response uses application/json:
At least one transport and representation is required. The frontend must honor advertised limits.

Predictions

Predictions submit a bounded set of registered reads as application/json:
The wire format accepts 1 to 16 candidates: Resource names use lowercase letters and digits with single ., _, or - separators and are at most 128 characters. cache_key is 1 to 512 characters; parameters are resource-defined JSON.

Event sequence

JSON returns an ordered events array; NDJSON sends the same events one per line. Common fields are at, protocol_version, request_id, and type; candidate events add prediction_id. A resolved resource contains name, cache_key, payload, media_type, optional expiry metadata, and measured work. Rejection reasons are below_quality_gate, budget_exhausted, invalid_parameters, queue_full, unavailable, and unsupported_representation. Candidate events may interleave, but resolution or failure must follow acceptance. Rejection is terminal.

Delivery modes

Return application/x-ndjson when the request accepts it and the implementation supports streaming. Write every event as one complete JSON object followed by \n, flushing as results complete. Return application/json with this envelope for buffered transport:
Both transports preserve the lifecycle. NDJSON exposes completed resources while slower work continues.

Outcome reporting

The frontend reports whether resolved data was actually consumed:
Each batch contains at least one outcome: Success is HTTP 204. Foreground navigation never waits for outcome reporting.

Errors

Protocol failures use HTTP status codes and application/problem+json. Problems require status, title, and type. Use HTTP 400 for invalid messages, 401 or 403 for host authentication or authorization failures, 413 for a batch outside the wire limit, and 429 when predictive work is overloaded. A 429 response may include Retry-After in seconds. Candidate failures belong in prediction.failed; malformed requests, authentication failures, and whole-request overload remain HTTP errors.

Conformance

A conforming backend must:
  1. Authenticate the host request and resolve tenancy before predictive data access.
  2. Parse protocol version 1 while ignoring unknown fields and enforcing required fields.
  3. Apply advertised batch and horizon limits plus bounded concurrency and backpressure.
  4. Resolve only server-registered read-only resource names.
  5. Validate parameters and apply the same authorization as the foreground read.
  6. Propagate request cancellation and enforce each candidate deadline.
  7. Emit candidate terminal events in completion order while preserving per-candidate ordering.
  8. End every successful prediction response with one consistent batch.completed event.
  9. Accept and persist outcome reports without making foreground navigation depend on them.
protocol/conformance contains canonical capability, prediction, event, and outcome fixtures.

Continue