Skip to main content

Function: wrapOpenAI()

Defined in: Wraps an OpenAI instance with logging.

Type Parameters

T

T extends OpenAIType

Parameters

openAIClient

T The OpenAI instance to wrap.

logger?

PermitechLogger The logger to use. Defaults to a new PermitechLogger instance.

ingestionHook?

(request: LogTracesIngestRequest) => void | Promise<void> Optional async callback invoked with the trace ingest request payload before sending to the Permitech API. Use this to inspect or modify trace data before ingestion. When provided without a logger, a new PermitechLogger is created with this hook and traces are automatically flushed to the hook after each completed call. No explicit flush() is needed.

Returns

T The wrapped OpenAI instance. Usage: