Skip to main content

Documentation Index

Fetch the complete documentation index at: https://sunpeak.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

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

import { detectHost, isChatGPT, isClaude } from 'sunpeak/host';

detectHost

Detect the current host.

Signature

function detectHost(): Host

Host Type

type Host = 'chatgpt' | 'claude' | 'unknown';

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

import { detectHost } from 'sunpeak/host';

function MyResource() {
  const host = detectHost();

  switch (host) {
    case 'chatgpt':
      return <ChatGPTFeatures />;
    case 'claude':
      return <ClaudeFeatures />;
    default:
      return <GenericUI />;
  }
}

isChatGPT

Check if the app is running in a ChatGPT host.

Signature

function isChatGPT(): boolean

Usage

import { isChatGPT } from 'sunpeak/host';
import { useUploadFile } from 'sunpeak/host/chatgpt';

function MyResource() {
  if (!isChatGPT()) {
    return <p>Upload requires ChatGPT.</p>;
  }
  return <Uploader />;
}

function Uploader() {
  const uploadFile = useUploadFile();
  // ...
}

isClaude

Check if the app is running in a Claude host.

Signature

function isClaude(): boolean

Usage

import { isClaude } from 'sunpeak/host';

function MyResource() {
  if (isClaude()) {
    // Claude-specific behavior
  }
}

Inspector Behavior

In the Inspector, host detection reflects the currently selected host:
Host selectedisChatGPT()isClaude()detectHost()
ChatGPTtruefalse'chatgpt'
Claudefalsefalse*'unknown'*
* 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.