/ docs / adapters / desktop / chatgpt-app.md
chatgpt-app.md
 1  # ChatGPT App
 2  
 3  Control the **ChatGPT macOS Desktop App** directly from the terminal. OpenCLI supports two automation approaches for ChatGPT.
 4  
 5  ## Approach 1: AppleScript (Default, No Setup)
 6  
 7  The current built-in commands use native AppleScript automation — no extra launch flags needed.
 8  
 9  ### Prerequisites
10  1. Install the official [ChatGPT Desktop App](https://openai.com/chatgpt/mac/) from OpenAI.
11  2. Grant **Accessibility permissions** to your terminal app in **System Settings → Privacy & Security → Accessibility**.
12  
13  ### Commands
14  - `opencli chatgpt-app status`: Check if the ChatGPT app is currently running.
15  - `opencli chatgpt-app new`: Activate ChatGPT and press `Cmd+N` to start a new conversation.
16  - `opencli chatgpt-app send "message"`: Copy your message to clipboard, activate ChatGPT, paste, and submit.
17  - `opencli chatgpt-app send "message" --model thinking`: Switch model/mode first, then send the message.
18  - `opencli chatgpt-app read`: Read the last visible message from the focused ChatGPT window via the Accessibility tree.
19  - `opencli chatgpt-app ask "message"`: Send a prompt and wait for the visible reply in one shot.
20  - `opencli chatgpt-app ask "message" --model instant`: Run a one-shot prompt using a specific model/mode.
21  - `opencli chatgpt-app model thinking`: Switch the active ChatGPT model/mode without sending a message.
22  
23  Supported model choices: `auto`, `instant`, `thinking`, `5.2-instant`, `5.2-thinking`.
24  
25  ## Approach 2: CDP (Advanced, Electron Debug Mode)
26  
27  ChatGPT Desktop is also an Electron app and can be launched with a remote debugging port:
28  
29  ```bash
30  /Applications/ChatGPT.app/Contents/MacOS/ChatGPT \
31    --remote-debugging-port=9224
32  ```
33  
34  ```bash
35  export OPENCLI_CDP_ENDPOINT="http://127.0.0.1:9224"
36  ```
37  
38  > The CDP approach is primarily for advanced automation and future desktop-only commands. The built-in command set above still works in the default AppleScript path unless you explicitly route through `OPENCLI_CDP_ENDPOINT`.
39  
40  ## How It Works
41  
42  - **AppleScript mode**: Uses `osascript` to control ChatGPT, `pbcopy`/`pbpaste` to paste prompts, and the macOS Accessibility tree to read visible chat messages.
43  - **CDP mode**: Connects via Chrome DevTools Protocol to the Electron renderer process.
44  
45  ## Limitations
46  
47  - macOS only (AppleScript dependency)
48  - AppleScript mode requires Accessibility permissions
49  - `read` returns the last visible message in the focused ChatGPT window — scroll first if the message you want is not visible