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

# Prime Tunnel

> Expose local services to the internet through secure reverse proxy

## What is Prime Tunnel?

Prime Tunnel creates secure, public URLs for services running on your local machine. You start a local server, create a tunnel, and get an HTTPS URL that anyone can access.

**Common use cases:**

* Expose a local development server to the internet
* Receive webhooks from external services during development
* Share a work-in-progress app with teammates

<Note>
  Hosted evaluations can use Prime Tunnel too. Launch the run with
  `--allow-tunnel-access`, then create the tunnel from inside the hosted
  sandbox using the same API or CLI flow described here. The flag only grants
  tunnel permissions to the temporary `PRIME_API_KEY`. See
  [Hosted Evaluations](/tutorials-environments/hosted-evaluations).
</Note>

## Complete Example

Here's a full working example: start a local HTTP server and expose it to the internet.

**1. Start a local server**

```bash theme={null}
# Create a simple HTML file
echo '<h1>Hello from Prime Tunnel!</h1>' > index.html

# Start Python's built-in HTTP server on port 8000
python -m http.server 8000
```

**2. Create a tunnel (in another terminal)**

<CodeGroup>
  ```python Python SDK theme={null}
  import asyncio
  from prime_tunnel import Tunnel

  async def main():
      tunnel = Tunnel(local_port=8000)
      await tunnel.start()

      print(f"Public URL: {tunnel.url}")
      print("Press Ctrl+C to stop")

      # Keep running until interrupted
      try:
          while True:
              await asyncio.sleep(1)
      except KeyboardInterrupt:
          pass
      finally:
          await tunnel.stop()

  asyncio.run(main())

  ```

  ```bash CLI theme={null}
  prime tunnel start --port 8000
  ```
</CodeGroup>

**3. Access your server**

Open the printed URL (e.g., `https://t-0-abc123def456.tunnel.pinfra.io`) in any browser. Your local server is now accessible from anywhere.

## Context Manager

For automatic cleanup, use the async context manager:

```python theme={null}
async with Tunnel(local_port=8000) as tunnel:
    print(f"URL: {tunnel.url}")
    # Tunnel is active here
# Tunnel automatically stopped
```

## Tunnel Properties

```python theme={null}
tunnel = Tunnel(local_port=8000)
await tunnel.start()

tunnel.tunnel_id  # "t-0-abc123def456"
tunnel.url        # "https://t-0-abc123def456.tunnel.pinfra.io"
```

## CLI Commands

```bash theme={null}
# Start a tunnel
prime tunnel start --port 8000

# List active tunnels
prime tunnel list

# Stop a tunnel
prime tunnel stop t-0-abc123def456
```
