Python SDK for Codex agents controlling visible ChatGPT web sessions through a local backend.
Project description
codex-chatgpt-control Python SDK
Python parity client for Codex agents controlling visible ChatGPT web sessions through the shared Node backend protocol.
Unofficial project: not affiliated with, endorsed by, or sponsored by OpenAI. This is not an OpenAI API wrapper and does not call hidden or private ChatGPT endpoints.
Python SDK -> backend protocol -> Node runtime -> browser bridge -> visible chatgpt.com session
The current browser-control runtime is Node/TypeScript. Python talks to it through a long-lived local stdio backend service. This is intentionally not a pure-Python browser-control runtime yet.
Install
python -m pip install codex-chatgpt-control
The Python package needs a Node backend command for browser-control workflows. Install or build the Node package too:
npm install codex-chatgpt-control
Development Install
Build the backend bundle first:
cd ../node
npm ci
npm run bundle:backend
Install the Python package:
cd ../python
python -m pip install -e .[dev]
Sync Usage
from codex_chatgpt_control import Agent, BackendClient, Runner, StdioBackendTransport
backend = BackendClient(StdioBackendTransport(
command=["node", "../node/dist/codex-chatgpt-control-backend.mjs"]
))
runner = Runner(backend)
agent = Agent(name="reviewer", instructions="Review carefully.")
try:
result = runner.run_sync(agent, {
"input": "Reply with hi.",
"thread": {"type": "new"},
"response": {"format": "markdown"},
})
finally:
backend.close()
print(result.status)
print(result.output_text)
Agents-Style API
The Python SDK exposes OpenAI Agents SDK-inspired names where they fit the visible-session product:
AgentRunner.runRunner.run_syncRunner.run_streamedRunResultRunResultStreaming
The semantics are browser-control semantics, not OpenAI API semantics. Instructions are visible by default and are submitted to ChatGPT web as prompt text unless instructions_mode="metadata_only" is used.
Product-Specific API
The ChatGPT facade exposes workflows and primitive command groups:
chatgpt.responses.create(...)chatgpt.ask(...),ask_in_thread(...),ask_with_files(...)chatgpt.run_plan({"name": "new-ask-read", ...})chatgpt.doctor(...)chatgpt.reports.create(...)chatgpt.session,threads,messages,files,projects.sources,modes,tools,responsechatgpt.commands(),describe(...),help(...)chatgpt.explain_blocker(result_or_blocker, ...)and module-levelexplain_blocker(...)
Unsupported OpenAI API-only Responses fields, such as model, temperature, and previous_response_id, return explicit unsupported responses instead of silently submitting misleading prompts.
Blocker Explainability
explain_blocker(...) preserves backend blocker dictionaries and returns structured fields plus Markdown for logs or CLI output:
result = chatgpt.session.bootstrap(existing_tab=True)
if not result.ok:
explanation = chatgpt.explain_blocker(result, command="session.bootstrap")
print(explanation["markdown"])
Existing-tab blockers expose only safe metadata: requested target, candidate tab IDs, URLs, titles, conversation IDs, omitted candidate count, and mismatch reason. They do not include page text or chat content.
Host-Local Attachment Paths
The Python client does not normalize attachment paths. It forwards them to the Node backend. Use the path form for the backend host, not necessarily the Python caller host. If Python is running on WSL but the backend is running in Windows, pass a Windows path. If the backend is running in WSL/Linux, pass a Linux path such as /home/you/file.pdf.
Validate local file metadata without opening ChatGPT:
preflight = chatgpt.files.preflight(paths=["/absolute/host/path/to/report.pdf"])
if not preflight.ok:
print(preflight.blocker)
Plan append-only ChatGPT Project Sources changes before mutating a project:
plan = chatgpt.projects.sources.plan_add(
project_url="https://chatgpt.com/g/g-p-example/project",
files=["/absolute/host/path/to/source.md"],
)
added = chatgpt.projects.sources.add(
project_url="https://chatgpt.com/g/g-p-example/project",
files=["/absolute/host/path/to/source.md"],
confirm_mutation=True,
)
plan_add validates explicit local file metadata without reading file contents or opening ChatGPT. add is append-only and returns needs_confirmation unless confirm_mutation=True is supplied.
Backend And Browser Bridge
Ordinary shells can launch the backend and validate the protocol. Browser-required calls need a compatible browser bridge.
Without a bridge, live browser operations should return:
{
"kind": "browser_bridge_unavailable"
}
That blocker is expected in ordinary shells. A real live browser pass requires a backend command with bridge access. A plain Python-spawned Node subprocess does not automatically inherit a Codex browser bridge.
Override the backend command when needed:
CHATGPT_BROWSER_BACKEND_COMMAND="node /absolute/path/to/bridge-enabled-backend.mjs" \
python scripts/live_smoke.py --mode browser-bridge
Validation
Run from packages/python:
python -m unittest discover -s tests
python -m compileall -q src examples
python -m pyright src tests
python scripts/live_smoke.py --mode ordinary-shell
The ordinary-shell smoke succeeds when the backend stays alive, backend.health succeeds, command descriptors load, and browser-required calls return browser_bridge_unavailable.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codex_chatgpt_control-0.2.0a1.tar.gz.
File metadata
- Download URL: codex_chatgpt_control-0.2.0a1.tar.gz
- Upload date:
- Size: 55.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39c04370079eeeb5d4c4ccad70082375933f8860a6d7ace501bc1ea2dc76fb0e
|
|
| MD5 |
24d0971ea6433c6181eab203c7683a89
|
|
| BLAKE2b-256 |
dc5f3b65cc3eecdc7a5547b6991564ff18b3b3633362b16bbcac68e35da7ee68
|
Provenance
The following attestation bundles were made for codex_chatgpt_control-0.2.0a1.tar.gz:
Publisher:
release.yml on adamallcock/codex-chatgpt-control
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_chatgpt_control-0.2.0a1.tar.gz -
Subject digest:
39c04370079eeeb5d4c4ccad70082375933f8860a6d7ace501bc1ea2dc76fb0e - Sigstore transparency entry: 1785026269
- Sigstore integration time:
-
Permalink:
adamallcock/codex-chatgpt-control@04b2d7981c95118fe4c62752f1ee85b62f164c6c -
Branch / Tag:
refs/tags/v0.2.0-alpha.1 - Owner: https://github.com/adamallcock
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04b2d7981c95118fe4c62752f1ee85b62f164c6c -
Trigger Event:
push
-
Statement type:
File details
Details for the file codex_chatgpt_control-0.2.0a1-py3-none-any.whl.
File metadata
- Download URL: codex_chatgpt_control-0.2.0a1-py3-none-any.whl
- Upload date:
- Size: 34.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9a337bc2848d435966e3f900f57be7cafb61fd21118c43d344d054d46db4993
|
|
| MD5 |
f02f881b16dd001273332d0191b50ecd
|
|
| BLAKE2b-256 |
ca91fb33bde8ac0901176cef7bede451d9eaba8cc10dceca0ff1afbabbae66ab
|
Provenance
The following attestation bundles were made for codex_chatgpt_control-0.2.0a1-py3-none-any.whl:
Publisher:
release.yml on adamallcock/codex-chatgpt-control
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_chatgpt_control-0.2.0a1-py3-none-any.whl -
Subject digest:
d9a337bc2848d435966e3f900f57be7cafb61fd21118c43d344d054d46db4993 - Sigstore transparency entry: 1785026339
- Sigstore integration time:
-
Permalink:
adamallcock/codex-chatgpt-control@04b2d7981c95118fe4c62752f1ee85b62f164c6c -
Branch / Tag:
refs/tags/v0.2.0-alpha.1 - Owner: https://github.com/adamallcock
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@04b2d7981c95118fe4c62752f1ee85b62f164c6c -
Trigger Event:
push
-
Statement type: