Context Layer

Install Context Layer

Context Layer establishes a runtime boundary between applications and LLM providers. Provision Execution Authority in the console to generate the wrapper script. This wrapper is not an SDK. You copy it into your codebase; you do not install a package.

Quick start

  1. Set CL_API_KEY
  2. Import the wrapper
  3. Call invokeCL() for execution

Step 1 — set API key

export CL_API_KEY="your_flow_api_key"

Step 2 — import wrapper

const { invokeCL } = require("./flow-wrapper");

Step 3 — run Flow execution

Each invokeCL() call represents one workflow step.

const res = await invokeCL("Generate invoice");
console.log(res.output);

Step 4 — final step and termination

Mark the final step of the workflow using workflowEnd.

const res = await invokeCL("Finalize invoice", { workflowEnd: true });

if (res.terminated) {
  console.log("Workflow completed");
}

Important

  • Flow steps execute sequentially
  • Concurrent invokeCL() calls are rejected
  • Direct model provider calls (OpenAI, Anthropic, etc.) are blocked

Runtime behavior

Context Layer automatically:

  • controls execution context
  • enforces constraints
  • verifies outputs
  • routes models
  • produces execution receipts

Note

Model selection is controlled by Context Layer routing and API key configuration.
Developers cannot select models per step.


Prerequisites

  • Node.js 18+ (or compatible runtime)
  • An LLM provider API key (OpenAI-compatible or Anthropic)
  • A Context Layer account

Step 1: provision execution authority

Create a project in the Context Layer console and click Provision Execution Authority. The console generates a wrapper script. Copy it into the project. Do not modify the generated script. The API key is obtained when you provision Execution Authority.


Step 2: copy the wrapper script

Place the generated wrapper in the project. The wrapper enforces runtime execution rules. It exposes invokeCL().


Step 3: export cl_api_key

The wrapper requires the environment variable CL_API_KEY.

export CL_API_KEY=your_flow_api_key

or for Pulse Mode:

export CL_API_KEY=your_pulse_api_key

The wrapper throws an error if CL_API_KEY is not set.


Stateless execution

Stateless execution (optional)

Stateless calls run outside of a workflow session.
They do not accumulate workflow state.

await invokeCL("Quick validation", { stateless: true });

Constraint: stateless cannot be combined with { workflowEnd: true }.


Pulse usage

const { invokeCL } = require("./pulse-wrapper");

await invokeCL("User message");

Provider compatibility

Context Layer supports:

  • OpenAI-compatible providers (OpenAI, Grok)
  • Anthropic

Developers use their own provider SDK in their application. Context Layer never accesses developer LLM API keys.


Runtime contract checklist

Before using the wrapper:

  • Final workflow step MUST include { workflowEnd: true }
  • Concurrent invokeCL() calls are rejected
  • Direct model provider calls are blocked
  • Stateless executions bypass workflow state
  • Context Layer never accesses developer LLM API keys

Next steps