---
title: How to set up an Agent Host Protocol connection in aiKonnector
description: "## Overview An Agent Host Protocol (AHP) connection lets aiKonnector talk to an agent host running on your machine, such as the one built into VS Code. Setup takes three steps: start and share the host in VS Code, add…"
url: "http://aikonnector.com/docs/how-to-set-up-an-agent-host-protocol-connection-in-aikonnector/"
updated: "2026-11-21"
category: Chat UI for LLM AI models and AHP (Agent Host Protocol)
---

# How to set up an Agent Host Protocol connection in aiKonnector

## Overview

An Agent Host Protocol (AHP) connection lets aiKonnector talk to an agent host running on your machine, such as the one built into VS Code. Setup takes three steps: start and share the host in VS Code, add it in aiKonnector, then authenticate it if the host asks.

**Before you start, you need:**

- VS Code installed, with access to a terminal
- An aiKonnector account with access to the **Admin** area of the [aiKonnector Human Approval Platform](https://app.aikonnector.com)
- A GitHub account, if you plan to use VS Code models (needed for Step 3)

### Step 1: Prepare the agent host in VS Code

Start the agent host on a port, then share that port publicly so aiKonnector can reach it.

#### Start the agent host

1. Open a terminal in VS Code.
2. Run the following command:

```
code-tunnel agent host --port 36692
```

You can use a different port. If you do, use that port number everywhere this guide says 36692.

#### Forward and share the port

1. Open the **Ports** panel. It sits next to the **Terminal** panel at the bottom of VS Code.
2. Click **Forward a Port**.
3. Type `36692` (or the port you started the agent host on) and press Enter.
4. Right-click the forwarded port and choose **Port Visibility** > **Public**. Click **OK** to confirm.
5. Copy the **Forwarded Address** VS Code shows for the port. You will paste it into aiKonnector in Step 2.

> **Note:** Public visibility means anyone with this address can reach the port. Treat the address, including its `tkn=` value, like a password and don't share it.

### Step 2: Add the host in aiKonnector

Add the host under **Admin** > **AHP Hosts**, using a WebSocket version of the address you copied from VS Code.

1. Sign in to the [aiKonnector Human Approval Platform](https://app.aikonnector.com) and go to **Admin** > **AHP Hosts**.
2. Click **Add Host**.
3. In **Name**, enter a name that's easy to recognize, such as `My VS Code`.
4. In **URL**, paste the address you copied from VS Code, then edit it:
   - Change the protocol from `https://` to `wss://`.
   - Add the port `:443` right after the hostname.
5. Click **Save**.

##### Example URL

|  | Address |
| --- | --- |
| Copied from VS Code | `https://exhostname-36692.use.devtunnels.ms?tkn=f08d9876-cb17-4e01-9a5d-ec12e39b1234` |
| Entered in aiKonnector | `wss://exhostname-36692.use.devtunnels.ms:443?tkn=f08d9876-cb17-4e01-9a5d-ec12e39b1234` |

Keep the `?tkn=` part of the address exactly as VS Code gave it. If the copied address has a `/` before `?tkn=`, put `:443` before that slash.

### Step 3: Authenticate the host (if required)

Some hosts need extra authentication before aiKonnector can use them, and VS Code models do. If so, the host shows an **Authentication required** notice on the **AHP Hosts** screen. For VS Code, you authenticate with a GitHub token from the GitHub CLI.

1. Install the [GitHub CLI](https://cli.github.com/) (`gh`).
2. In a terminal, sign in to GitHub:

```
gh auth login
```

1. Follow the prompts to finish signing in.
2. Print your token:

```
gh auth token
```

1. Copy the token from the output.
2. In aiKonnector, go to **Admin** > **AHP Hosts** and open the host to edit it.
3. Paste the token into the authentication field at the bottom of the **AHP Host** edit screen.
4. Click **Save**. The **Authentication required** notice should clear.

> **Note:** This token gives access to your GitHub account. Don't share it or paste it anywhere other than aiKonnector.

### Step 4: Use AHP host from the web

Now that the host is configured, it is ready to be used from the web.

- Browse to the [aiKonnector Human Approval Platform](https://app.aikonnector.com/) and log in
- Click "New Chat"
- In the Model selector (bottom right), click the drop-down that shows models
  - At the bottom of the list, you will now see your machine name (as configured in "AHP Hosts") and each model that is available to select
    - For VSCode, Free will show a single Microsoft model, Paid will show all 20+ models available from within VSCode
  - Select one of these models
- Start chatting with the agent on the host. As this is an agent (and not just an LLM), you can ask it such as:
  - Ask it what directory its in
  - To change directory
  - To open a file and read or summarize it
  - To create an app
- NOTE - You can also configure different folders (in Admin) that are select-able in the "Tool" menu for new chats.

### Troubleshooting

| Problem | What to check |
| --- | --- |
| aiKonnector can't connect to the host | Make sure the agent host is still running in VS Code and the port is still forwarded. Stopping either one closes the connection. |
| Connection is refused | Confirm the port's visibility is **Public**, not **Private**. |
| URL won't connect | Confirm it starts with `wss://`, includes `:443`, and keeps the full `?tkn=` value. |
| Wrong port | The port in the forwarded address must match the `--port` value you used to start the agent host. |
| **Authentication required** notice returns | Your GitHub token may have been revoked or you may have signed out. Run `gh auth login` and `gh auth token` again, then paste the new token. |
