Skip to main content

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 async mode (default), the on_credit_usage callback 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

caesura_io_openai-1.0.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

caesura_io_openai-1.0.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

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

Hashes for caesura_io_openai-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a65f6e57eadd6a728c3f7223d942cb5aa6da031c37aa34a39aeb3717adde67bc
MD5 ab4e46f52c897ef37023b81499ca47c6
BLAKE2b-256 153458138983e1f2559ba3faac6148d00ac359847c217860571d6827f7b84466

See more details on using hashes here.

Provenance

The following attestation bundles were made for caesura_io_openai-1.0.3.tar.gz:

Publisher: release.yml on caesura-io/sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file caesura_io_openai-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for caesura_io_openai-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 143322571bf44e972138924e924bb7a1005973e0a4d2af2e58045a7f7f4032d9
MD5 17cd007801dfb4cb325e3c78821611c7
BLAKE2b-256 4a6124457a3e037f3fab894e5e8c4cad69e2b7a5c28de57d2a2fcdadaf0a719a

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page