Transparent wrapper for the OpenAI Python SDK to inject Caesura recommendations.
Project description
caesura-io-openai
Asynchronous, non-blocking recommendation injection for the official OpenAI Python SDK.
Caesura listens to your agent's dialogue and pushes short, real-time recommendations ("analysis") into the model's context without blocking the conversation. It plugs in as a transparent wrapper around the OpenAI client.
Status: early development. API is not yet stable.
Install
pip install caesura-io-openai openai
Quick Start
Sync Client (Chat Completions)
import openai
+from caesura_openai import create_caesura
-client = openai.OpenAI()
+client = create_caesura(openai.OpenAI(), {
+ "base_url": "https://dev.caesura.io",
+ # api_key auto-read from CAESURA_API_KEY if omitted
+})
completion = client.chat.completions.create(
model="gpt-5.4-mini",
messages=conversation,
+ caesura_conversation_id=session_id,
)
Async Client (Chat Completions)
import openai
+from caesura_openai import create_async_caesura
-client = openai.AsyncOpenAI()
+client = create_async_caesura(openai.AsyncOpenAI(), {
+ "base_url": "https://dev.caesura.io",
+})
completion = await client.chat.completions.create(
model="gpt-5.4-mini",
messages=conversation,
+ caesura_conversation_id=session_id,
)
Responses API
import openai
+from caesura_openai import create_caesura
-client = openai.OpenAI()
+client = create_caesura(openai.OpenAI(), {
+ "base_url": "https://dev.caesura.io",
+})
response = client.responses.create(
model="gpt-5.4-mini",
input="Hello agent!",
+ caesura_conversation_id=session_id,
)
Credit Usage Reporting
+from caesura_openai import create_caesura, create_credit_meter
import openai
+meter = create_credit_meter()
+
-client = openai.OpenAI()
+client = create_caesura(openai.OpenAI(), {
+ "base_url": "https://dev.caesura.io",
+ "on_credit_usage": meter.record,
+})
+# Query credit metrics later
+print("total credits consumed:", meter.total())
+print("credits by conversation:", meter.breakdown())
Note: In
asyncmode (default), theon_credit_usagecallback fires out-of-band as soon as the asynchronous analyze call completes, decoupled from the synchronous OpenAI request resolution.
Caesura Mode vs Python Sync/Async
Caesura's mode setting ("sync" or "async") controls whether recommendation
generation blocks the model call. It is independent of whether you use Python's
sync OpenAI or async AsyncOpenAI client:
mode="async"(default): Observation runs in the background. Recommendations appear on the next turn.mode="sync": Observation runs inline. Recommendations are injected into the current turn.
Both modes work with both the sync and async Python clients.
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file caesura_io_openai-1.0.3.tar.gz.
File metadata
- Download URL: caesura_io_openai-1.0.3.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a65f6e57eadd6a728c3f7223d942cb5aa6da031c37aa34a39aeb3717adde67bc
|
|
| MD5 |
ab4e46f52c897ef37023b81499ca47c6
|
|
| BLAKE2b-256 |
153458138983e1f2559ba3faac6148d00ac359847c217860571d6827f7b84466
|
Provenance
The following attestation bundles were made for caesura_io_openai-1.0.3.tar.gz:
Publisher:
release.yml on caesura-io/sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
caesura_io_openai-1.0.3.tar.gz -
Subject digest:
a65f6e57eadd6a728c3f7223d942cb5aa6da031c37aa34a39aeb3717adde67bc - Sigstore transparency entry: 2085960319
- Sigstore integration time:
-
Permalink:
caesura-io/sdk-py@4b59bd1fb9f45cbb9041b86cc208b54283c72a3f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/caesura-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4b59bd1fb9f45cbb9041b86cc208b54283c72a3f -
Trigger Event:
push
-
Statement type:
File details
Details for the file caesura_io_openai-1.0.3-py3-none-any.whl.
File metadata
- Download URL: caesura_io_openai-1.0.3-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
143322571bf44e972138924e924bb7a1005973e0a4d2af2e58045a7f7f4032d9
|
|
| MD5 |
17cd007801dfb4cb325e3c78821611c7
|
|
| BLAKE2b-256 |
4a6124457a3e037f3fab894e5e8c4cad69e2b7a5c28de57d2a2fcdadaf0a719a
|
Provenance
The following attestation bundles were made for caesura_io_openai-1.0.3-py3-none-any.whl:
Publisher:
release.yml on caesura-io/sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
caesura_io_openai-1.0.3-py3-none-any.whl -
Subject digest:
143322571bf44e972138924e924bb7a1005973e0a4d2af2e58045a7f7f4032d9 - Sigstore transparency entry: 2085960988
- Sigstore integration time:
-
Permalink:
caesura-io/sdk-py@4b59bd1fb9f45cbb9041b86cc208b54283c72a3f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/caesura-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4b59bd1fb9f45cbb9041b86cc208b54283c72a3f -
Trigger Event:
push
-
Statement type: