Files
codex/sdk/python
Adam Perry @ OpenAI a5d56d8120 Accept unknown Codex error variants in the app-server protocol (#49806)
## Why

New error variants should not prevent older clients from handling app-server errors.

## What changed

- Deserialize unknown `CodexErrorInfo` strings and objects as `Other` in Rust, while preserving known variants and the `"other"` serialization.
- Allow arbitrary strings and objects in the exported JSON schemas and TypeScript type.
- Update Python SDK generation and generated models to accept unknown error strings and object payloads.

## Testing

Add Rust tests for `"other"` round trips, unknown string and object fallbacks, known structured variants, and rejection of null, boolean, numeric, and array values.

GitOrigin-RevId: 40c17896019924b2ef7970ee2205ea0154d0d1b3
2026-10-01 01:38:04 +00:00
..

OpenAI Codex Python SDK

Build Python applications that start Codex threads, run turns, stream progress, and control workspace access.

Install

Install the SDK:

pip install openai-codex

Quickstart

The SDK reuses your existing Codex authentication when one is already available:

from openai_codex import Codex

with Codex() as codex:
    thread = codex.thread_start()
    result = thread.run("Explain this repository in three bullets.")
    print(result.final_response)

thread.run(...) returns a TurnResult containing the final response, collected items, and token usage.

Authentication

Existing Codex authentication is reused automatically. To start ChatGPT browser login explicitly:

from openai_codex import Codex

with Codex() as codex:
    login = codex.login_chatgpt()
    print(login.auth_url)
    print(login.wait().success)

For device-code login:

with Codex() as codex:
    login = codex.login_chatgpt_device_code()
    print(login.verification_url, login.user_code)
    login.wait()

For API-key login:

with Codex() as codex:
    codex.login_api_key("sk-...")

Built-In Help

Use Python's standard help(openai_codex), help(Codex), or python -m pydoc openai_codex documentation tools.

Documentation

The package is licensed under the repository Apache License 2.0.