Skip to main content

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:

  • Agent
  • Runner.run
  • Runner.run_sync
  • Runner.run_streamed
  • RunResult
  • RunResultStreaming

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, modes, tools, response
  • chatgpt.commands(), describe(...), help(...)

Unsupported OpenAI API-only Responses fields, such as model, temperature, and previous_response_id, return explicit unsupported responses instead of silently submitting misleading prompts.

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 --pythonpath "$(which python)" 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codex_chatgpt_control-0.1.0a1.tar.gz (40.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codex_chatgpt_control-0.1.0a1-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file codex_chatgpt_control-0.1.0a1.tar.gz.

File metadata

  • Download URL: codex_chatgpt_control-0.1.0a1.tar.gz
  • Upload date:
  • Size: 40.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for codex_chatgpt_control-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 e399271ab70e78a83e996811bab475f0c330cd37b076ba0457cf00ad7e57caf1
MD5 4282ae385841de44bebb79f5bde88180
BLAKE2b-256 0d130d5bfb96e0f91e02ffd85f4e692040721361bb89ae11cf5021c087333891

See more details on using hashes here.

File details

Details for the file codex_chatgpt_control-0.1.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for codex_chatgpt_control-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f9a52b527186cb6ecd6ab2b72881b2f231de4883475c8a7b0c55ba6a10d68ce
MD5 018f55ae05d316d7455f6915367add26
BLAKE2b-256 bd3c5a0c92d080dfb70592b9e585bd16bc1fa81e42f857399f1dd849a4813b38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page