caesura-io-openai
CaesuraO recommendations for OpenAI Python 2.x and 3.x. Supports Chat Completions
and Responses through create(), including streaming, with sync and async clients.
pip install caesura-io-openai openai
Set OPENAI_API_KEY and CAESURA_API_KEY, then create a conversation once:
from openai import OpenAI
from caesura_core import AnalysisContext, AnalyzeMessage, CustomerTurn
from caesura_openai import CaesuraOpenAIOptions, create_caesura
with create_caesura(OpenAI(), CaesuraOpenAIOptions(mode="sync")) as client:
conversation_id = client.create_conversation(name="Support conversation")
response = client.responses.create(
model="gpt-5.4-mini",
input="Can you help me?",
caesura_conversation_id=conversation_id,
caesura_context=AnalysisContext(
turn=CustomerTurn("customer-message-1", AnalyzeMessage("user", "Can you help me?")),
),
)
print(response.output_text)
Save the returned conversation ID and reuse it on later calls. Use a distinct customer message ID for each new turn and reuse it on retries. The SDK does not fetch history.
For async applications, use create_async_caesura(AsyncOpenAI(), options) and await
creation/model calls. For Chat Completions, use client.chat.completions.create()
with messages and the same caesura_conversation_id / caesura_context options.
Behavior and options
| Option | Behavior |
|---|---|
mode="async" (default) |
Analyze in the background; guidance is available to later calls |
mode="sync" |
Await analysis before the current model call |
persist=True (default) |
Save the selected customer utterance and analysis via HTTP |
failure_policy="continue" (default) |
Report analysis/storage errors and allow the model call |
failure_policy="raise" |
Fail required foreground work before invoking the model |
speaker_names=SpeakerNames(agent="Agent", customer="Customer") |
Participant labels; default indices are agent 0 and customer 1 |
Analysis mode is independent of Python's sync/async client type. An authoritative
conversation ID is required even with persist=False. Full transcript storage uses
the separate persist_transcript hook.
New customer turns trigger analysis. Earlier assistant dialogue provides background;
tool/RAG content should be excluded with explicit CustomerTurn selection. Keep your
application dialogue separate from SDK-injected requests.
Use stream=True and consume or close streams to finalize usage and persistence.
The wrapper preserves native chunks but returns a delegating stream proxy. Convenience
.stream() and raw-response helpers bypass the analysis wrapper; use create().
on_credit_usage=create_credit_meter().record collects credit usage.
on_provider_request captures the finalized model request; on_provider_outcome
reports responses, stream completion, errors, and available usage.
See application integration for guidance placement, stores, cancellation, and audit contracts; migration for breaking changes; and runnable applications for local examples.
Licensed under Apache-2.0.
Metadata
Release files for caesura-io-openai 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| caesura_io_openai-3.0.0.tar.gz | 43.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| caesura_io_openai-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 58.8 kB
Release files / caesura_io_openai-3.0.0.tar.gz
| Download URL | caesura_io_openai-3.0.0.tar.gz |
|---|---|
| Size | 43.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5211928ba320d757615d183bdbb715fab3320abe5896426b3715edf066c5500f
|
|
BLAKE2b-256 checksum How to use checksums |
160a69e1b22e6da2d73711a35d0b6259f731edf872a463e27f2e7061f9b86a94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / caesura_io_openai-3.0.0-py3-none-any.whl
| Download URL | caesura_io_openai-3.0.0-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f5e9179483a56021154e31c663d01905e41361fe1248a7601bba83265aeaf80
|
|
BLAKE2b-256 checksum How to use checksums |
bf5e0d3e99669e4f52a3609b5fb70ad7aa6f2f0cb7587e322d6c4e40227f9eb5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency log