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

# API Proxy for Self-Hosted ComfyUI

> Serve the Comfy API v2 in front of your own ComfyUI so the official SDKs can run workflows against it

The [Comfy SDKs](/development/api-development/sdks) speak [Comfy API v2](/api-reference/v2/overview). During the beta, a self-hosted ComfyUI does not serve v2 itself. [comfy-api-proxy](https://github.com/Comfy-Org/comfy-api-proxy) is a small open-source service that runs alongside your instance and serves the v2 contract in front of it.

<Note>
  The proxy is a stopgap. Once the v2 API stabilizes it moves into ComfyUI core and the proxy is no longer needed.
</Note>

## Install and run

```bash theme={null}
pip install comfy-api-proxy
comfy-api-proxy
```

By default it proxies the ComfyUI on `127.0.0.1:8188` and serves the v2 API on `127.0.0.1:8189`. Use `--comfyui` and `--port` to change either.

Run it with `--comfyui-base-dir /path/to/ComfyUI` if you also want to upload model files into your install.

## Point the SDK at it

Set the base URL and construct the client as usual:

```bash theme={null}
export COMFY_BASE_URL="http://127.0.0.1:8189"
```

<CodeGroup>
  ```python Python theme={null}
  from comfy_sdk import Comfy

  client = Comfy()
  ```

  ```typescript TypeScript theme={null}
  import { Comfy } from "@comfyorg/sdk";

  const client = new Comfy();
  ```
</CodeGroup>

Everything in the [SDK guide](/development/api-development/sdks) works the same way against the proxy as against Comfy Cloud.

## Authentication

Authentication is not required by default. If the proxy is configured with a static bearer token, pass that token as the SDK API key: `Comfy(api_key="...")`.

<Warning>
  The proxy binds to loopback only by default. If you expose it beyond loopback, for example in front of a ComfyUI on a rented GPU, configure a bearer token or put an authenticating reverse proxy in front of it.
</Warning>

## Next steps

* [Comfy SDKs](/development/api-development/sdks): the client guide
* [Comfy API v2 Reference](/api-reference/v2/overview): the HTTP contract the proxy serves
* [Self-Hosting Options](/development/deploy/self-hosting): where to run the ComfyUI behind it
* [Design Notes](/development/api-development/sdks-design#the-local-proxy): why the proxy exists
