Overview
These hooks wrap the ChatGPTwindow.openai runtime APIs, providing typed React hooks for host-specific features that go beyond the MCP Apps standard. They are available only when running inside ChatGPT (or the inspector with the ChatGPT host selected).
Import
Feature Detection Pattern
useUploadFile
Upload a file from the app UI into the ChatGPT conversation.Signature
Returns
CreateFileResult
Supported Formats
image/png, image/jpeg, image/webp
Usage
useRequestModal
Open a host-controlled modal in ChatGPT.Signature
OpenModalParams
Usage
useRequestCheckout
Trigger the ChatGPT instant checkout flow.Signature
CheckoutSession
CheckoutOrder
Usage
Low-Level Access
For advanced use cases, you can access thewindow.openai runtime directly:
Inspector Support
When the ChatGPT host is selected in the Inspector, a mockwindow.openai runtime is automatically injected into the iframe. This makes isChatGPT() return true and all ChatGPT hooks functional with stub implementations that log to the browser console.
When a different host (e.g. Claude) is selected, window.openai is not injected and isChatGPT() returns false.
See Also
Host Detection
Detect which host is running your app.
Inspector
Test ChatGPT hooks locally with the mock runtime.