APM manages LLM runtime installation and configuration automatically. This guide covers the supported runtimes, how to use them, and how to extend APM with additional runtimes.
APM acts as a runtime package manager, downloading and configuring LLM runtimes from their official sources. Currently supports three runtimes:
| Runtime | Description | Best For | Configuration |
|---|---|---|---|
| GitHub Copilot CLI | GitHub's Copilot CLI (Recommended) | Advanced AI coding, native MCP support | Auto-configured, no auth needed |
| OpenAI Codex | OpenAI's Codex CLI | Code tasks, GitHub Models API | Auto-configured with GitHub Models |
| LLM Library | Simon Willison's llm CLI |
General use, many providers | Manual API key setup |
# 1. Install APM
curl -sSL https://raw.githubusercontent.com/microsoft/apm/main/install.sh | sh
# 2. Setup AI runtime (downloads and configures automatically)
apm runtime setup copilotapm runtime list # Show installed runtimes
apm runtime setup llm # Install LLM library
apm runtime setup copilot # Install GitHub Copilot CLI (Recommended)
apm runtime setup codex # Install Codex CLIAPM automatically installs GitHub Copilot CLI from the public npm registry. Copilot CLI provides advanced AI coding assistance with native MCP integration and GitHub context awareness.
apm runtime setup copilotThis automatically:
- Installs GitHub Copilot CLI from public npm registry
- Requires Node.js v22+ and npm v10+
- Creates MCP configuration directory at
~/.copilot/ - No authentication required for installation
APM executes scripts defined in your apm.yml. When scripts reference .prompt.md files, APM compiles them with parameter substitution. See Prompts Guide for details.
# Run scripts (from apm.yml) with parameters
apm run start --param service_name=api-gateway
apm run debug --param service_name=api-gatewayScript Configuration (apm.yml):
scripts:
start: "copilot --full-auto -p analyze-logs.prompt.md"
debug: "copilot --full-auto -p analyze-logs.prompt.md --log-level debug"APM automatically downloads, installs, and configures the Codex CLI with GitHub Models for free usage.
apm runtime setup codexThis automatically:
- Downloads the latest Codex binary for your platform
- Installs to
~/.apm/runtimes/codex - Creates configuration for GitHub Models (
github/gpt-4o) - Updates your PATH
# Get a fine-grained GitHub token (preferred) with "Models" permissions
export GITHUB_TOKEN=your_github_token# Run scripts (from apm.yml) with parameters
apm run start --param service_name=api-gateway
apm run debug --param service_name=api-gatewayScript Configuration (apm.yml):
scripts:
start: "codex analyze-logs.prompt.md"
debug: "RUST_LOG=debug codex analyze-logs.prompt.md"APM also supports the LLM library runtime with multiple model providers and manual configuration.
apm runtime setup llmThis automatically:
- Creates a Python virtual environment
- Installs the
llmlibrary and dependencies - Creates a wrapper script at
~/.apm/runtimes/llm
# GitHub Models (free)
llm keys set github
# Paste your GitHub PAT when prompted
# Other providers
llm keys set openai # OpenAI API key
llm keys set anthropic # Anthropic API keyAPM executes scripts defined in your apm.yml. See Prompts Guide for details on prompt compilation.
# Run scripts that use LLM runtime
apm run llm-script --param service_name=api-gateway
apm run analysis --param time_window="24h"Script Configuration (apm.yml):
scripts:
llm-script: "llm analyze-logs.prompt.md -m github/gpt-4o-mini"
analysis: "llm performance-analysis.prompt.md -m gpt-4o"# Run scripts defined in apm.yml
apm run start --param service_name=api-gateway
apm run copilot-analysis --param service_name=api-gateway
apm run debug --param service_name=api-gateway# Scripts that use Copilot CLI for advanced code understanding
apm run code-review --param pull_request=123
apm run analyze-code --param file_path="src/main.py"
apm run refactor --param component="UserService"# Scripts that use Codex for code understanding
apm run codex-review --param pull_request=123
apm run codex-analyze --param file_path="src/main.py"# Scripts that use LLM for text processing
apm run document --param project_name=my-project
apm run summarize --param report_type="weekly""Runtime not found"
# Install missing runtime
apm runtime setup copilot # Recommended
apm runtime setup codex
apm runtime setup llm
# Check installed runtimes
apm runtime list"Command not found: copilot"
# Ensure Node.js v22+ and npm v10+ are installed
node --version # Should be v22+
npm --version # Should be v10+
# Reinstall Copilot CLI
apm runtime setup copilot"Command not found: codex"
# Ensure PATH is updated (restart terminal)
# Or reinstall runtime
apm runtime setup codexAPM's runtime system is designed to be extensible. To add support for a new runtime:
APM's runtime system consists of three main components:
- Runtime Adapter (
src/apm_cli/runtime/) - Python interface for executing prompts - Setup Script (
scripts/runtime/) - Shell script for installation and configuration - Runtime Manager (
src/apm_cli/runtime/manager.py) - Orchestrates installation and discovery
- Create Runtime Adapter - Extend
RuntimeAdapterinsrc/apm_cli/runtime/your_runtime.py - Create Setup Script - Add installation script in
scripts/runtime/setup-your-runtime.sh - Register Runtime - Add entry to
supported_runtimesinRuntimeManager - Update CLI - Add runtime to command choices in
cli.py - Update Factory - Add runtime to
RuntimeFactory
- Follow the
RuntimeAdapterinterface - Use
setup-common.shutilities for platform detection and PATH management - Handle errors gracefully with clear messages
- Test installation works after setup completes
- Support vanilla mode (no APM-specific configuration)
To contribute a new runtime to APM:
- Fork the repository and follow the extension guide above
- Add tests and update documentation
- Submit a pull request
The APM team welcomes contributions for popular LLM runtimes!