instance: granollers.okai
MODERN PROTOCOL FOR AI SYSTEMS
Open Knowledge for AI
OKAI SERVICE

Contract

Observable contract of the okai_message object returned by the API.

Contracte observable de l’objecte okai_message retornat per l’API.

no active execution
Contract Scope / Abast del Contracte

The Contract tab describes the observable contract of the okai_message object returned by the API.

A successful API response returns a WorldResultPayload. Within this response, okai_message is the protocol surface documented here.

La pestanya Contract descriu el contracte observable de l’objecte okai_message retornat per l’API.

Una resposta correcta de l’API retorna un WorldResultPayload. Dins d’aquesta resposta, okai_message és la superfície de protocol documentada aquí.

SUCCESSFUL API RESPONSE
└── WorldResultPayload
    ├── superfícies runtime top-level
    └── okai_message
        ├── header
        └── payload

Top-level runtime surfaces may exist in the API response, but they are not part of the semantic contract of okai_message.

Les superfícies runtime top-level poden existir a la resposta de l’API, però no formen part del contracte semàntic de okai_message.

HTTP Response Contract / Contracte de Resposta HTTP

Successful Response / Resposta Correcta

Valid GET and POST invocations execute the same pipeline and return a serialized WorldResultPayload under the same response contract.

The successful HTTP response uses status 200 and JSON content.

Les invocacions GET i POST vàlides executen el mateix pipeline i retornen un WorldResultPayload serialitzat sota el mateix contracte de resposta.

La resposta HTTP correcta utilitza l’estat 200 i contingut JSON.

Content-Type: application/json; charset=utf-8

Error Response / Resposta d’Error

HTTP 400 and 500 responses use a JSON error object:

This object is not a WorldResultPayload, does not contain okai_message and is not part of the semantic OKAI Message contract.

Les respostes HTTP 400 i 500 utilitzen un objecte JSON d’error:

Aquest objecte no és un WorldResultPayload, no conté okai_message i no forma part del contracte semàntic d’OKAI Message.

{
  "error": "string"
}

Cache Header

GET responses explicitly include:

The POST handler does not explicitly set a cache-control header.

Les respostes GET inclouen explícitament:

El handler POST no estableix explícitament cap header de cache-control.

Cache-Control: no-store

The absence of an explicit POST header must not be interpreted as a cache policy or guarantee.

L’absència d’un header explícit a POST no s’ha d’interpretar com una política o garantia de cache.

OKAI Message Structure / Estructura de l'OKAI Message

An OKAI Message has two main parts:

Un OKAI Message té dues parts principals:

{
  "header": {
    "okai_version": "v0.2.13",
    "delivery": {
      "mode": "materialized | referenced | mixed",
      "deferred": []
    },
    "token_control": {
      "encoding": "o200k_base",
      "tokens": 0
    }
  },
  "payload": {
    "okai_instance": {},
    "known": {},
    "detected_as": [],
    "meaning": [],
    "detected_composition_members": [],
    "territorial_resolution": {},
    "functional_reality": [],
    "functional_relations": []
  }
}

header identifies the generating OKAI version and describes Delivery and token accounting.

payload contains the delivered semantic and operational content.

header identifica la versió d’OKAI que ha generat el missatge i descriu el delivery i el recompte de tokens.

payload conté el contingut semàntic i operatiu entregat.

Header

The header contains the generating OKAI version, Delivery metadata and token control metadata.

El header conté la versió d’OKAI que ha generat el missatge, metadades de delivery i metadades de control de tokens.

{
  "okai_version": "v0.2.13",
  "delivery": {
    "mode": "materialized",
    "deferred": []
  },
  "token_control": {
    "encoding": "o200k_base",
    "tokens": 0
  }
}

The header does not redefine the meaning of the delivered content.

okai_version identifies the OKAI release that generated a new message.

It also describes how the current message was delivered and how its tokens were counted.

El header no redefineix el significat del contingut entregat. okai_version identifica la release d’OKAI que ha generat un missatge nou. També descriu com s’ha entregat el missatge actual i com s’ha comptabilitzat.

Delivery Contract / Contracte de Delivery

delivery describes the DATA representation of the delivered PROJECT.

delivery descriu la representació de DATA del PROJECT entregat.

{
  "mode": "materialized",
  "deferred": []
}

mode describes the DATA models observed in payload.functional_reality[].data for the delivered PROJECT.

mode does not describe global completeness.

mode does not indicate whether other resolved packages exist outside the delivered PROJECT.

mode does not depend on deferred.

deferred lists resolved packages that belong to the EXPEDIENT but were excluded from the delivered PROJECT because of the contractual Delivery limit.

mode descriu els models DATA observats a payload.functional_reality[].data per al PROJECT entregat.

mode no descriu la completitud global.

mode no indica si existeixen altres resolved packages fora del PROJECT entregat.

mode no depèn de deferred.

deferred llista resolved packages que pertanyen a l’EXPEDIENT però que han estat exclosos del PROJECT entregat a causa del límit contractual de Delivery.

Delivery Modes / Modes de Delivery

materialized

The delivered PROJECT contains only DATA resolved as materialized, or no DATA is observed in payload.functional_reality[].data.

A materialized mode does not necessarily mean that materialized DATA is present in the message.

El PROJECT entregat conté només DATA resolta com a materialized, o no s’observa cap DATA a payload.functional_reality[].data.

Un mode materialized no significa necessàriament que hi hagi DATA materialized present al missatge.

referenced

The delivered PROJECT contains only DATA explicitly represented using the referenced model.

Referenced DATA uses a reference-based representation instead of transporting all operational content inline.

El PROJECT entregat conté només DATA representada explícitament amb el model referenced.

La DATA referenced utilitza una representació basada en referències en lloc de transportar tot el contingut operatiu inline.

mixed

The delivered PROJECT contains more than one DATA model within payload.functional_reality[].data.

Under the current contract, this means that materialized and referenced DATA coexist within the delivered PROJECT.

El PROJECT entregat conté més d’un model DATA dins de payload.functional_reality[].data.

En el contracte actual, això significa que DATA materialized i DATA referenced coexisteixen dins del PROJECT entregat.

Deferred Contract / Contracte de deferred

deferred contains resolved packages excluded from the delivered PROJECT because of the Delivery limit.

deferred conté resolved packages exclosos del PROJECT entregat a causa del límit de delivery.

{
  "reason": "protocol_request_limit",
  "detected": {
    "key": "string",
    "label": "string"
  },
  "limit": {
    "tokens": 50000
  },
  "action": "new_request",
  "message": "string"
}

reason indicates why the package was excluded.

detected identifies the resolved detection that was excluded.

limit.tokens indicates the contractual token limit applied.

action indicates the expected action of the consumer.

message provides a human-readable explanation.

deferred does not mean unresolved.

deferred does not mean a Detection error.

deferred does not mean a Resolution error.

deferred does not imply automatic retrieval.

A deferred package belongs to the resolved EXPEDIENT, but it is not part of the PROJECT delivered in this OKAI Message.

reason indica per què el package ha estat exclòs.

detected identifica la detecció resolta que ha estat exclosa.

limit.tokens indica el límit contractual de tokens aplicat.

action indica l’acció esperada del consumidor.

message proporciona una explicació llegible per humans.

deferred no significa unresolved.

deferred no significa un error de Detection.

deferred no significa un error de Resolution.

deferred no implica recuperació automàtica.

Un package deferred forma part de l’EXPEDIENT resolt, però no forma part del PROJECT entregat en aquest OKAI Message.

Token Control / Control de Tokens

token_control describes the token accounting of the API response.

token_control descriu la comptabilització de tokens de la resposta de l’API.

{
  "encoding": "o200k_base",
  "tokens": 0
}

encoding identifies the tokenizer used.

tokens indicates the token count of the final serialized WorldResultPayload returned by the API, calculated using o200k_base.

The count is based on the serialized API response as returned, not exclusively on okai_message.payload.

Some top-level WorldResultPayload fields are outside the semantic contract of okai_message, but may be part of the serialized representation used for token accounting.

encoding identifica el tokenizer utilitzat.

tokens indica el recompte de tokens del WorldResultPayload final serialitzat retornat per l’API, calculat amb o200k_base.

El recompte es basa en la resposta de l’API serialitzada tal com es retorna, no exclusivament en okai_message.payload.

Alguns camps top-level del WorldResultPayload són fora del contracte semàntic de okai_message, però poden formar part de la representació serialitzada utilitzada per al recompte de tokens.

Payload Contract / Contracte del payload

payload contains the delivered semantic and operational content of the OKAI Message.

payload conté el contingut semàntic i operatiu entregat de l’OKAI Message.

{
  "okai_instance": {},
  "known": {},
  "detected_as": [],
  "meaning": [],
  "detected_composition_members": [],
  "territorial_resolution": {},
  "functional_reality": [],
  "functional_relations": []
}

okai_instance

Identifies the operational instance and the context that produced the message.

Identifica la instància operativa i el context que ha produït el missatge.

known

Represents known or unknown text detected in the original question.

This field is global to the EXPEDIENT and is not filtered exclusively to the delivered PROJECT.

Representa text conegut o desconegut detectat a la pregunta original.

Aquest camp és global a l’EXPEDIENT, no filtrat només al PROJECT entregat.

detected_as

Contains delivered entities detected as semantic matches.

Detected entities may include public fields such as level, entity_nature, entity_class, entity_pattern and related descriptors.

Conté les entities entregades detectades com a coincidències semàntiques.

Les entities detectades poden incloure camps públics com level, entity_nature, entity_class, entity_pattern i descriptors relacionats.

meaning

Contains definition and contextual information for delivered META detections.

Only detected entities with level: "meta" contribute to this layer.

Conté definició i informació contextual per a deteccions META entregades.

Només les entities detectades amb level: "meta" contribueixen a aquesta capa.

detected_composition_members

Contains detected composition members.

This field is global to the EXPEDIENT and is not filtered exclusively to the delivered PROJECT.

Conté membres de composició detectats.

Aquest camp és global a l’EXPEDIENT, no filtrat només al PROJECT entregat.

territorial_resolution

Contains the active territorial context of the EXPEDIENT.

It may expose available territorial fields such as key, scope, context or contexts.

Conté el context territorial actiu de l’EXPEDIENT.

Pot exposar camps territorials disponibles com key, scope, context o contexts.

functional_reality

Contains resolved FUNCTIONAL entities and their associated DATA.

This is the primary location where operational DATA appears within the OKAI Message.

Conté entities FUNCTIONAL resoltes i la seva DATA associada.

Aquesta és la ubicació principal on apareix DATA operativa dins de l’OKAI Message.

functional_relations

Contains outgoing functional relations of delivered FUNCTIONAL entities.

Functional relations may expose related functional context and may include DATA depending on the resolved case.

Conté relacions funcionals sortints de les entities FUNCTIONAL entregades.

Les relacions funcionals poden exposar context funcional relacionat i poden incloure DATA segons el cas resolt.

Knowledge Layers / Capes de Coneixement

The OKAI Message exposes three confirmed public knowledge layers.

L’OKAI Message exposa tres capes públiques de coneixement confirmades.

META

META represents conceptual knowledge.

META appears through delivered detections and meaning structures.

A public META detection is identified by:

META representa coneixement conceptual.

META apareix mitjançant deteccions entregades i estructures de meaning.

Una detecció META pública s’identifica amb:

{
  "level": "meta"
}

FUNCTIONAL

FUNCTIONAL represents an operationally identifiable reality.

FUNCTIONAL appears primarily in functional_reality, direct detections and functional relations.

A public FUNCTIONAL detection is identified by:

FUNCTIONAL representa una realitat identificable operativament.

FUNCTIONAL apareix principalment a functional_reality, deteccions directes i relacions funcionals.

Una detecció FUNCTIONAL pública s’identifica amb:

{
  "level": "functional"
}

DATA

DATA represents operational information associated with a FUNCTIONAL entity.

DATA appears primarily in functional_reality[].data.

DATA may be materialized or referenced according to its model.

DATA representa informació operativa associada a una entity FUNCTIONAL.

DATA apareix principalment a functional_reality[].data.

DATA pot ser materialized o referenced segons el seu model.

META_CLASS / META_CONCEPT

META_CLASS and META_CONCEPT may exist as internal modeling distinctions, but the current OKAI Message does not expose a public discriminator that allows consumers to distinguish them unambiguously.

Consumers must rely on level: "meta" for public META detection.

META_CLASS i META_CONCEPT poden existir com a distincions internes de modelatge, però l’OKAI Message actual no exposa cap discriminador públic que permeti als consumidors distingir-los inequívocament.

Els consumidors han de basar-se en level: "meta" per a la detecció pública META.

Consumer Interpretation / Interpretació del Consumidor

Consumers may infer that:

  • The message contains an okai_message object with header and payload.
  • delivery.mode describes the DATA models observed in payload.functional_reality[].data for the delivered PROJECT.
  • deferred identifies resolved packages excluded from the delivered PROJECT because of the Delivery limit.
  • token_control.tokens counts the final serialized WorldResultPayload returned by the API using o200k_base.
  • level: "meta" identifies public META detections.
  • level: "functional" identifies public FUNCTIONAL detections.
  • functional_reality is the primary location for reading resolved FUNCTIONAL entities and their DATA.

Els consumidors poden inferir que:

  • El missatge conté un objecte okai_message amb header i payload.
  • delivery.mode descriu els models DATA observats a payload.functional_reality[].data per al PROJECT entregat.
  • deferred identifica resolved packages exclosos del PROJECT entregat a causa del límit de delivery.
  • token_control.tokens compta el WorldResultPayload final serialitzat retornat per l’API utilitzant o200k_base.
  • level: "meta" identifica deteccions públiques META.
  • level: "functional" identifica deteccions públiques FUNCTIONAL.
  • functional_reality és el lloc principal per llegir entities FUNCTIONAL resoltes i la seva DATA.

Consumers must not infer that:

  • delivery.mode describes global completeness.
  • delivery.mode = "materialized" guarantees that materialized DATA exists in the message.
  • deferred means unresolved.
  • deferred means a Detection error.
  • deferred means a Resolution error.
  • deferred implies automatic retrieval.
  • The protocol exposes public META_CLASS or META_CONCEPT discriminators.

The consumer must not infer scoring, ranking or priority from the order or structure of the message.

Els consumidors no han d’inferir que:

  • delivery.mode descriu la completitud global.
  • delivery.mode = "materialized" garanteix que existeix DATA materialized al missatge.
  • deferred significa unresolved.
  • deferred significa un error de Detection.
  • deferred significa un error de Resolution.
  • deferred implica recuperació automàtica.
  • El protocol exposa discriminadors públics META_CLASS o META_CONCEPT.
  • El consumidor no ha d’inferir scoring, ranking ni prioritat a partir de l’ordre o l’estructura del missatge.
Out of Scope / Fora de l'Abast

The following fields may exist at the top level of the WorldResultPayload returned by the API:

Els camps següents poden existir al top-level del WorldResultPayload retornat per l’API:

{
  "detected_elements": [],
  "detected_elements_data": [],
  "detected_class_members": [],
  "detected_entity_class_groups": [],
  "relation_overdub": [],
  "only_matched_text": {}
}

These fields exist in the WorldResultPayload returned by the API, but they are not part of okai_message or its semantic contract documented in this tab.

only_matched_text may be projected into the OKAI Message as payload.known, but the top-level runtime field itself remains outside this contract.

Aquests camps existeixen al WorldResultPayload retornat per l’API, però no formen part de okai_message ni del seu contracte semàntic documentat en aquesta pestanya.

only_matched_text es pot projectar dins de l’OKAI Message com a payload.known, però el camp runtime top-level mateix queda fora d’aquest contracte.

© 2026 Denys Sanz · Tots els drets reservats OKAI — Protocol M2M v0.3.2