Skip to main content
sunpeak API

Overview

Host detection utilities help you identify which host (ChatGPT, Claude, etc.) is running your app, so you can conditionally use host-specific features.

Import

detectHost

Detect the current host.

Signature

Host Type

Detection Order

  1. Runtime objects — checks for window.openai (injected by ChatGPT and by the inspector when ChatGPT host is selected)
  2. User agent — checks navigator.userAgent for host identifiers
  3. Hostname — checks window.location.hostname for known host domains

Usage


isChatGPT

Check if the app is running in a ChatGPT host.

Signature

Usage


isClaude

Check if the app is running in a Claude host.

Signature

Usage


Inspector Behavior

In the Inspector, host detection reflects the currently selected host: * Claude detection relies on user agent or hostname, which aren’t present in the inspector. Use useHostContext() to read host identity from the MCP protocol instead.

See Also

ChatGPT Hooks

Host-specific hooks for ChatGPT features.

useHostContext

Read host identity and capabilities via the MCP protocol.