@@ -31,7 +31,7 @@ If there’s no prebuilt wheel for your platform/Python, pip will build from sou
3131Run a prompt and collect structured events (typed):
3232
3333``` python
34- from codex.api import run_exec, CodexClient, CodexNativeError
34+ from codex import run_exec, CodexClient, CodexNativeError
3535from codex.config import CodexConfig, ApprovalPolicy, SandboxMode
3636
3737cfg = CodexConfig(
@@ -51,26 +51,42 @@ except CodexNativeError as e:
5151
5252# Conversation (streaming)
5353client = CodexClient(config = cfg)
54- for ev in client.start_conversation(" Add a smoke test" ):
55- print (ev.id, ev.msg.type)
54+ conv = client.start_conversation()
55+ conv.submit_user_turn(" Add a smoke test" )
56+ for ev in conv:
57+ print (ev.id, getattr (getattr (ev.msg, " root" , ev.msg), " type" , " unknown" ))
5658```
5759
5860Notes
5961- ` Event.msg ` is a typed union (` EventMsg ` ). For raw dicts from the native layer, use ` codex.native.start_exec_stream ` .
6062
6163## 3) API Overview
6264
63- - ` codex.api. run_exec(prompt, config, load_default_config=True) -> list[Event] `
64- Synchronous one‑shot execution ; returns all events.
65+ - ` codex.run_exec(prompt, *, config=None , load_default_config=True, output_schema=None ) -> list[Event] `
66+ Synchronous one‑shot; returns all events.
6567
66- - ` codex.api.CodexClient(config).start_conversation(prompt, load_default_config=None) -> Iterable[Event] `
67- Streaming conversation iterator.
68+ - ` codex.run_review(prompt, *, user_facing_hint=None, config=None, load_default_config=True) -> list[Event] `
69+ Synchronous review flow; returns all events.
70+
71+ - ` codex.run_prompt(prompt, *, config=None, load_default_config=True, output_schema=None) -> str | Any `
72+ Convenience: returns the final assistant message (or parsed JSON when ` output_schema ` is set).
73+
74+ - ` codex.CodexClient(config).start_conversation(... ) -> Conversation `
75+ Creates a stateful session. Iterate over ` Conversation ` to stream events.
76+ - ` Conversation.submit_user_turn(prompt, *, cwd=None, approval_policy=..., sandbox_mode=..., model=None, effort=..., summary=..., output_schema=None) `
77+ - ` Conversation.submit_review(prompt, user_facing_hint=None) `
78+ - ` Conversation.approve_exec(id, decision) ` / ` approve_patch(id, decision) `
79+ - ` Conversation.interrupt() ` , ` Conversation.shutdown() `
80+ - Utility: ` user_input_text ` , ` override_turn_context ` , ` add_to_history ` , ` get_history_entry ` , ` get_path ` , ` list_mcp_tools ` , ` list_custom_prompts ` , ` compact `
81+
82+ - ` await codex.CodexClient(...).astart_conversation() -> AsyncConversation `
83+ Async iterator with the same methods as ` Conversation ` (async variants).
6884
6985- Exceptions
70- - ` CodexError ` base class ; ` CodexNativeError ` wraps native failures and missing extension.
86+ - ` CodexError ` base; ` CodexNativeError ` wraps native failures / missing extension.
7187
72- - Native helpers
73- - ` codex.native.preview_config(config_overrides, load_default_config) ` returns a compact snapshot of the effective configuration (useful in tests ).
88+ - Native helper
89+ - ` codex.native.preview_config(config_overrides, load_default_config) ` → compact effective config snapshot (testing aid ).
7490
7591## 4) Configuration
7692
0 commit comments