Skip to main content

pi-sidecar

A standalone HTTP service that wraps the Pi coding agent SDK (requires @earendil-works/pi-coding-agent ≥ 0.99.0), exposing AI sessions over a simple JSON API. Ships with a Python client for easy integration.

📖 Full Documentation

Features

  • Session management — create, prompt, abort, and delete AI sessions over REST; optionally supply a provider-agnostic, session-scoped API key
  • Model discovery — discover models from ACPX, CLI, and built-in providers. See key-scoped model discovery for user keys.
  • Provider discovery — GET /providers lists every provider registered in the initialized runtime, including built-ins and extensions, even without discoverable models or ambient credentials. The JSON response is { "providers": [{ "provider": string, "supportsSessionApiKey": boolean }] }. provider is the exact ID; supportsSessionApiKey says whether POST /sessions accepts api_key, not whether the server has credentials. No credentials or auth diagnostics are returned. Python: await SidecarClient.get_providers() returns a typed list of these records. Use discovery to enumerate providers, GET /models for available models, and GET /models/:provider/status for details about a known provider.
  • Provider diagnostics — GET /models/:provider/status reports registration, model count, auth status, and supportsSessionApiKey (a boolean indicating whether POST /sessions accepts api_key for that provider, regardless of server credentials; false for unknown, headless-excluded, and ambient CLI/ACPX providers). Python: SidecarClient.get_model_provider_status(). Full auth detail on loopback; on non-loopback binds (SIDECAR_HOST / DEV_MODE) authStatus/authCheck are redacted to { configured } / { type }; supportsSessionApiKey remains public on both binds and in 404 responses
  • Custom tools — plug in domain-specific tools at session creation via custom_tools
  • HTTP-backed tools — custom tools with http config get automatic request execution with parameter interpolation and security hardening
  • Subagent delegation — delegate tasks to specialized agents via the subagent tool (loaded as a Pi SDK extension)
  • Watchdog — opt-in health-check poller for companion backend liveness
  • Localhost-only — binds to 127.0.0.1 by default; no auth needed behind the network boundary

Packages

Package Language Install
@myk-org/pi-sidecar TypeScript npm install @myk-org/pi-sidecar
pi-sidecar-client Python ≥ 3.10 uv pip install pi-sidecar-client

The npm tarball is the Node server only. Python wheels/sdists publish to PyPI — they must not ship inside @myk-org/pi-sidecar even though uv build writes them to the same dist/ as tsc.

Quick Start

from pi_sidecar_client import call_ai_once

result = await call_ai_once(
    "Summarize this log file",
    ai_provider="gemini",
    ai_model="gemini-2.5-flash",
    system_prompt="You are a log analyst.",
)
print(result.text)

To override the server's stored/environment API key for one session, pass api_key=user_api_key to SidecarClient.create_session, call_ai, or call_ai_once. The wire field is api_key in POST /sessions (a non-empty string of at most 1,024 characters); the response remains { "session_id": "..." }. The key applies only to the selected provider and that session, takes precedence over server credentials, and is held in memory until the session is deleted or expires. Omitting it preserves server credential fallback. Providers without Pi API-key auth capability reject it with HTTP 400; OAuth, Vertex/ADC and CLI login state are not configured by this field. Keys are not saved in session files, returned in API responses, or passed to nested agents. Treat sidecar access as privileged: its default loopback bind is not an authentication boundary against local users.

# Start the sidecar
npm run build && node dist/server.js  # listens on 127.0.0.1:9100

# Or, for local development (background by default; default port 9201 — override with SIDECAR_PORT; see --help):
scripts/start-sidecar.sh

See the Consumer Integration Guide for Docker, Python client, and deployment best practices. See the full documentation for everything else.

Key-scoped model discovery

GET /models uses the server's credentials. Static getModels metadata cannot verify what a supplied key can access. For providers with supportsSessionApiKey: true in GET /providers, query with the key instead:

curl -s -X POST http://127.0.0.1:9100/models/for-api-key \
  -H 'Content-Type: application/json' \
  -d '{"provider":"openai","api_key":"<your-key>"}'
# Returns: {"models": [...], "modelListingSupported": true}

The response is { "models": [...], "modelListingSupported": boolean }. A provider with native key-scoped listing returns modelListingSupported: true; models: [] then means the listing returned no models. A provider without native key-scoped listing returns { "models": [], "modelListingSupported": false }. In that case, ask the user to enter a model ID. A canonical builtin always supports key-scoped listing on its own host, even when its catalog mixes APIs (OpenRouter fronts Anthropic models alongside OpenAI ones); a models.json baseUrl override or a custom gateway is still refused, so a request-supplied endpoint never receives the credential. A listing is only key-listed: it does not verify that a prompt will work. Google results require generateContent; known non-generation OpenAI model families are excluded, but remaining IDs are not prompt-verified. Do not use static catalog entries as verified models for that key. Known static IDs can be used with a supplied key. Unknown IDs can create a session only when the native listing supplies reliable positive input and output token limits (currently Google); otherwise POST /sessions returns HTTP 400 for missing model metadata.

In Python, await SidecarClient.get_models_for_api_key(provider, api_key) returns the full dictionary, including models and modelListingSupported. Providers without supportsSessionApiKey return HTTP 400. The lookup is request-local: the sidecar does not cache the supplied key or result.

CLI Commands

After installing @myk-org/pi-sidecar, two CLI commands are available:

# Start the sidecar server (Node.js entry point)
npx pi-sidecar

# Start/stop via shell script (background mode, dev defaults on port 9201)
npx pi-sidecar-start
npx pi-sidecar-start --stop
npx pi-sidecar-start --help

License

Apache-2.0

Metadata

Release files for pi-sidecar-client 4.8.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pi-sidecar-client 4.8.3
File Size Uploaded
pi_sidecar_client-4.8.3.tar.gz 20.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pi-sidecar-client 4.8.3
File Interpreter ABI Platform
pi_sidecar_client-4.8.3-py3-none-any.whl Python 3 none any Details

Total release size: 37.9 kB

Release files / pi_sidecar_client-4.8.3.tar.gz

Download URL pi_sidecar_client-4.8.3.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
04ebdfbe7e4a18edfd63a58a417a8f6354b60d23f048e82d1ba051cf8b934584
BLAKE2b-256 checksum
How to use checksums
e5b1e8d45748c8a6eda0003a9467236525bdabaa1a920928291270dc2afa3e74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pi_sidecar_client-4.8.3-py3-none-any.whl

Download URL pi_sidecar_client-4.8.3-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35bd781944ae753567bbcd0688f33dadc1987e47d872dd63778ad547cdb1eec4
BLAKE2b-256 checksum
How to use checksums
c3b9433d6dbd757f4e6b174bf6ab6df6fd1251e24d49ed233473635497932b71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

4.10.0

2 release files

4.9.0

2 release files

4.8.5

2 release files

4.8.4

2 release files

This release

4.8.3 This release

2 release files

4.8.2

2 release files

4.8.1

2 release files

4.8.0

2 release files

4.7.3

2 release files

4.7.2

2 release files

4.7.1

2 release files

4.7.0

2 release files

4.6.5

2 release files

4.6.4

2 release files

4.6.3

2 release files

4.6.2

2 release files

4.6.1

2 release files

4.6.0

2 release files

4.5.0

2 release files

4.4.1

2 release files

4.4.0

2 release files

4.3.12

2 release files

4.3.11

2 release files

4.3.10

2 release files

4.3.9

2 release files

4.3.8

2 release files

4.3.7

2 release files

4.3.6

2 release files

4.3.5

2 release files

4.3.4

2 release files

4.3.3

2 release files

4.3.2

2 release files

4.3.1

2 release files

4.2.1

2 release files

4.2.0

2 release files

4.1.5

2 release files

4.1.3

2 release files

4.1.2

2 release files

4.1.1

2 release files

1.5.0

1 release file

1.4.0

1 release file

1.3.1

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page