OpenAI
Installing Telem into a coding agent instead? The one-line curl detects the frameworks you already have and installs into as many as you select in one pass. This page is the Python library integration.
Telem.wrap(client) — and AsyncTelem.wrap(client) for openai.AsyncOpenAI —
patches an OpenAI client in place and hands back the same object, with
chat.completions.create equipped with Telem search. One wrapped client is one
agent conversation.
Install
Section titled “Install”pip install "telem-sdk[openai]"openai is an optional extra: the wrap module is duck-typed and imports the real
package only to give a clearer error when the object you pass in isn’t shaped
like an OpenAI client.
What it adds
Section titled “What it adds”- A
telem_searchtool the model can call, backed by the samesearch()every other SDK surface uses. - Conversation recording — every request and reply is published as
client.telem_messagesafter each call. - Session threading — every search carries the flat message history plus its
session identity, tagged
HARNESS_ID = "openai", so the conversation arrives in the console as one trajectory.
Identity
Section titled “Identity”| Option | Behavior |
|---|---|
conversation_id |
Auto-minted per wrap() call. Pass your own when the conversation should outlive a single wrapped client — e.g. a web server wrapping a fresh client per request. |
context_window_id |
Omitted: the wrap anchors on the first message, so trimming or summarizing the history starts a new generation on its own. |
parent= |
Freezes the parent client’s conversation snapshot into this client’s ancestors, at wrap() time — wrap the child when you delegate to it, not at startup, or the snapshot predates anything the parent said. |
from openai import OpenAIfrom telem import Telem
telem = Telem() # reads TELEM_API_KEY / TELEM_BASE_URL from the environmentclient = OpenAI() # reads OPENAI_API_KEY from the environmenttelem.wrap(client) # patches client.chat.completions.create in place
completion = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "What's new in the Telem search API?"}],)print(completion.choices[0].message.content)print(completion.telem_responses) # list[SearchResponse] telem ran answering this turnprint(client.telem_messages) # the recorded conversation so farAsync is the same shape with AsyncTelem and openai.AsyncOpenAI:
import asynciofrom openai import AsyncOpenAIfrom telem import AsyncTelem
async def main(): telem = AsyncTelem() client = AsyncOpenAI() telem.wrap(client) completion = await client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "What's new in the Telem search API?"}], ) print(completion.choices[0].message.content)
asyncio.run(main())Both examples need a real OPENAI_API_KEY and make a live model call.
Streaming isn’t supported yet
Section titled “Streaming isn’t supported yet”A stream=True call bypasses Telem entirely — no telem_search tool, no
session tracking, no reply recording — and the wrap emits a UserWarning
every time it happens.