"type": "module" and the tsx runner.
Most applications should use the TypeScript SDK. It manages subscriptions, callback dispatch, session configuration, result assembly and cleanup. The HTTP API is useful when building another language client or integrating an externally operated runtime.
The endpoint reference describes the Cognitio runtime packaged with this SDK. Use the complete OpenAPI document for session and control endpoint schemas. In v2, the live /doc route exposes a limited control-plane schema, not the complete API. Check /global/health for the running runtime version when assessing compatibility.
Inspect a bundled runtime without a model call
Installcognitio-agent-sdk and use Node.js 22+. This complete example starts the bundled local runtime, reads health and the limited live schema metadata, and stops it. It does not need a provider key. Save it as inspect-http.ts; run node --import tsx inspect-http.ts.
Understand the responsibilities
The SDK’s
AgentMessage stream is a higher-level API than raw HTTP events. Do not expect raw SSE payloads to have the same field names or envelopes as Agent.stream() results.
Build a correct session flow
- Select the server-side directory/workspace and use it consistently for related requests.
- Create or attach to a session and install the intended runtime configuration.
- Establish the event/control subscription and wait until it is ready.
- Submit input, service callback requests, and track the session’s terminal outcome.
- Close subscriptions and callback resources. Delete the session only when your application’s retention policy requires it.
directory query parameter or the x-cognitio-directory header; the header value is URI-encoded by the SDK. Paths refer to the runtime host. Using the wrong directory context can target a different runtime instance even when the URL and session ID look correct.
A successful async prompt submission does not mean the model turn has completed. See events and control for readiness, cancellation and reconnection rules. The generated endpoint schemas provide exact request bodies; a generic POST wrapper does not implement the required session state machine.