Skip to Content
Server Mode

Last Updated: 4/8/2026


Server Mode

Learn how to run Pie as a persistent server for production deployments.

Starting the Server

Basic Server

pie serve

This starts Pie on http://localhost:8080.

Custom Configuration

pie serve --host 0.0.0.0 --port 9000 --model llama-3.2-1b

Server Options

  • --host - Bind address (default: localhost)
  • --port - Port number (default: 8080)
  • --model - Model to load
  • --gpu - GPU device ID
  • --workers - Number of worker processes

Client Connection

Once the server is running, connect with a client:

Python

from pie_client import PieClient client = PieClient("http://localhost:8080") result = client.run( inferlet="std/text-completion", args={"prompt": "Hello"} )

JavaScript

import { PieClient } from '@pie-project/client'; const client = new PieClient('http://localhost:8080'); const result = await client.run({ inferlet: 'std/text-completion', args: { prompt: 'Hello' } });

Production Deployment

Using Docker

FROM python:3.11 RUN pip install pie-server EXPOSE 8080 CMD ["pie", "serve", "--host", "0.0.0.0"]

Using systemd

Create /etc/systemd/system/pie.service:

[Unit] Description=Pie Server After=network.target [Service] Type=simple User=pie ExecStart=/usr/local/bin/pie serve --host 0.0.0.0 Restart=always [Install] WantedBy=multi-user.target

Enable and start:

sudo systemctl enable pie sudo systemctl start pie

Monitoring

Server Logs

pie logs --follow

Health Check

curl http://localhost:8080/health

Metrics

curl http://localhost:8080/metrics

Security

API Authentication

Set API key:

export PIE_API_KEY=your-secret-key pie serve

Client usage:

client = PieClient( "http://localhost:8080", api_key="your-secret-key" )

TLS/SSL

Use reverse proxy (nginx, caddy) for HTTPS:

server { listen 443 ssl; server_name pie.example.com; ssl_certificate /path/to/cert.pem; ssl_certificate_key /path/to/key.pem; location / { proxy_pass http://localhost:8080; } }

Scaling

Multiple Workers

pie serve --workers 4

Load Balancing

Run multiple Pie instances behind a load balancer.

Next Steps