Skip to main content
wrap() wraps the OpenAI client (Python and TypeScript) so every call inside a conversation or task block gets the context and records the answer. AzureOpenAI has the same shape and works with the same wrap(), with no adapter of its own; the integration test runs against both real clients.

Install

The five primitives

Minimal example

The same code is in examples/azure_openai.py.

Agent memory

Since niadra 0.2.1, wrap(client, agent_memory=True) puts the agent’s own notes in the same system message, before the customer’s context, like the other adapters. In TypeScript, read the block with conv.agentMemory() and put text in your system message. See Agent memory.

Limits

  • Outside a conversation or task block, calls pass through untouched.
  • In Python, with_streaming_response is not intercepted; in TypeScript, .asResponse() returns the raw HTTP response and nothing is recorded.
  • The wrapper returns a proxy and never modifies your client. Nothing it does can fail the model call.
  • Tested against openai 1.40 (real OpenAI and AzureOpenAI clients, with the transport replaced) and Niadra on the emulator.

Next steps

OpenAI Agents SDK

for those on the Agents SDK instead of the client.

Python SDK

wrap() and the provider’s prompt cache.