Skip to content
tokz

OpenAI integration

Add context compression around your OpenAI client.

Tokz's OpenAI wrapper keeps your model call and provider key in the same application while compressing eligible tool-result context before the request continues upstream.

openai.ts
import OpenAI from "openai";
import { withTokz } from "@tokz/openai";

const openai = withTokz(new OpenAI(), {
  apiKey: process.env.TOKZ_API_KEY!,
});

await openai.responses.create({ model: "gpt-4o", input });

What the wrapper changes

The wrapper intercepts supported request content and sends a selected context view to the provider. The model response and your OpenAI API shape remain the responsibility of OpenAI.

Keep required context explicit

Use preserve and protected-context controls for instructions, identifiers, and fields your application must retain. Compression is a context policy, not an authorization boundary.

Limitations

The wrapper cannot improve a missing source fact or guarantee a model answer. Hosted Tokz receives payloads for processing but does not persist them.