export_json()

Export a conversation capture as an auditable JSON file.

Usage

Source

export_json(
    capture,
    path,
    *,
    metadata=None,
    indent=2,
)

The output is a structured JSON document with session metadata, a timestamp, and a full event log with ISO 8601 timestamps.

Parameters

capture: ConversationCapture

The conversation capture to export.

path: str | Path

File path to write the JSON export to.

metadata: dict[str, Any] | None = None

Additional metadata to include in the export header (e.g., {"reviewer": "Jane Doe", "department": "compliance"}).

indent: int = 2
JSON indentation level (default 2).

Returns

Path
The path the file was written to.

Examples

import talk_box as tb

capture = tb.ConversationCapture(session_id="audit-001")
capture.record_prompt("Summarize the Q4 report.")
capture.record_response("Revenue increased 12% year-over-year.", model="openai:gpt-4o")

tb.export_json(capture, "audit-001.json", metadata={"reviewer": "Jane Doe"})