> ## Documentation Index
> Fetch the complete documentation index at: https://docs.skybridge.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# useOpenFile

> Ask ChatGPT to open a local file

> [!NOTE]
>
> This is an [OpenAI MCP extension](https://github.com/openai/mcp-extensions/blob/main/docs/spec.md), not part of MCP or MCP Apps. Only **ChatGPT** supports it: on other hosts the function rejects.

A view usually has no access to the filesystem. When your server knows the absolute path of a file, for example one it just generated, `useOpenFile` asks ChatGPT to open it. This needs ChatGPT desktop, and the path must exist on the machine that runs it.

ChatGPT desktop opens the file in a new tab with its built-in viewer, from which the user can view the source or open it in an external editor. It doesn't go through your app's [file entrypoint](/api-reference/register-tool.md#openai), even when the file's extension matches one. That's what we observed in ChatGPT desktop; the spec doesn't describe it.

## Example

A view offers to open the file the tool exported.

```tsx theme={null}
import { useHost, useOpenFile } from "skybridge/web";
import { useToolInfo } from "../helpers.js";

function ExportResult() {
  const { output } = useToolInfo<"export-part">();
  const { openaiCapabilities } = useHost();
  const openFile = useOpenFile();

  if (!openaiCapabilities.files || !output) {
    return null;
  }
  return <button onClick={() => openFile(output.path)}>Open in ChatGPT</button>;
}
```

## Returns

```tsx theme={null}
(path: string) => Promise<void>;
```

A memoized function that sends `openai/files/open` with the absolute `path`. It rejects with a `NotSupportedError` on hosts that don't advertise `openai/files`, so check [`useHost().openaiCapabilities.files`](/api-reference/use-host#openaicapabilities) before showing the control.

> **[useHost](/api-reference/use-host.md)**
>
> Check which extensions the host supports

> **[useOpenExternal](/api-reference/use-open-external.md)**
>
> Open a URL outside the conversation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.