Core API¶
Primary client and thread classes.
When to use this page¶
You want docstrings for the main entry points:
Codex,Thread, and async equivalents.You want the exact
run/run_streamedsignatures and return types.
- class acodex.codex.Codex(**options)[source]¶
Codex is the main class for interacting with the Codex agent.
Use start_thread() to start a new thread or resume_thread() to resume a previously started thread.
- class acodex.codex.AsyncCodex(**options)[source]¶
Codex is the main class for interacting with the Codex agent.
Use start_thread() to start a new thread or resume_thread() to resume a previously started thread.
- class acodex.thread.Thread(*, exec, options, thread_options, thread_id=None)[source]¶
Represent a thread of conversation with the agent.
One thread can have multiple consecutive turns.
- property id¶
Return the ID of the thread.
The ID is populated after the first turn starts.
- run_streamed(input, output_type=None, **turn_options)[source]¶
Provide input to the agent and stream turn events as they are produced.
Set turn_options[“signal”] via event.set() to request cancellation. Use threading.Event in synchronous flows.
- Returns:
A streamed turn result with an iterator of parsed events.
- class acodex.thread.AsyncThread(*, exec, options, thread_options, thread_id=None)[source]¶
Represent a thread of conversation with the agent.
One thread can have multiple consecutive turns.
- property id¶
Return the ID of the thread.
The ID is populated after the first turn starts.
- async run_streamed(input, output_type=None, **turn_options)[source]¶
Provide input to the agent and stream turn events as they are produced.
Set turn_options[“signal”] via event.set() to request cancellation. Use asyncio.Event in asynchronous flows.
- Returns:
A streamed turn result with an async iterator of parsed events.
- async run(input, output_type=None, **turn_options)[source]¶
Provide input to the agent and return the completed turn.
Set turn_options[“signal”] via event.set() to request cancellation. Use asyncio.Event in asynchronous flows.
- Returns:
The completed turn with reduced items, final response, and usage.
- class acodex.types.turn.Turn(items, final_response, usage, structured_response_factory)[source]¶
Completed turn.
This is the result returned by run().
- property structured_response¶
Return the structured response.