Runtime Compatibility
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.
Overview
Section titled “Overview”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 |
Quick Setup
Section titled “Quick Setup”Install APM and Setup Runtime
Section titled “Install APM and Setup Runtime”# 1. Install APMcurl -sSL https://raw.githubusercontent.com/microsoft/apm/main/install.sh | sh
# 2. Setup AI runtime (downloads and configures automatically)apm runtime setup copilotRuntime Management
Section titled “Runtime Management”apm runtime list # Show installed runtimesapm runtime setup llm # Install LLM libraryapm runtime setup copilot # Install GitHub Copilot CLI (Recommended)apm runtime setup codex # Install Codex CLIGitHub Copilot CLI Runtime (Recommended)
Section titled “GitHub Copilot CLI Runtime (Recommended)”APM 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.
1. Install via APM
Section titled “1. Install via APM”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 parametersapm run start --param service_name=api-gatewayapm 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"OpenAI Codex Runtime
Section titled “OpenAI Codex Runtime”APM automatically downloads, installs, and configures the Codex CLI with GitHub Models for free usage.
1. Install via APM
Section titled “1. Install via APM”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
2. Set GitHub Token
Section titled “2. Set GitHub Token”# Get a fine-grained GitHub token (preferred) with "Models" permissionsexport GITHUB_TOKEN=your_github_token# Run scripts (from apm.yml) with parametersapm run start --param service_name=api-gatewayapm 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"LLM Runtime
Section titled “LLM Runtime”APM also supports the LLM library runtime with multiple model providers and manual configuration.
1. Install via APM
Section titled “1. Install via APM”apm runtime setup llmThis automatically:
- Creates a Python virtual environment
- Installs the
llmlibrary and dependencies - Creates a wrapper script at
~/.apm/runtimes/llm
2. Configure API Keys (Manual)
Section titled “2. Configure API Keys (Manual)”# GitHub Models (free)llm keys set github# Paste your GitHub PAT when prompted
# Other providersllm keys set openai # OpenAI API keyllm 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 runtimeapm run llm-script --param service_name=api-gatewayapm 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"Examples by Use Case
Section titled “Examples by Use Case”Basic Usage
Section titled “Basic Usage”# Run scripts defined in apm.ymlapm run start --param service_name=api-gatewayapm run copilot-analysis --param service_name=api-gatewayapm run debug --param service_name=api-gatewayCode Analysis with Copilot CLI
Section titled “Code Analysis with Copilot CLI”# Scripts that use Copilot CLI for advanced code understandingapm run code-review --param pull_request=123apm run analyze-code --param file_path="src/main.py"apm run refactor --param component="UserService"Code Analysis with Codex
Section titled “Code Analysis with Codex”# Scripts that use Codex for code understandingapm run codex-review --param pull_request=123apm run codex-analyze --param file_path="src/main.py"Documentation Tasks
Section titled “Documentation Tasks”# Scripts that use LLM for text processingapm run document --param project_name=my-projectapm run summarize --param report_type="weekly"Troubleshooting
Section titled “Troubleshooting”“Runtime not found”
# Install missing runtimeapm runtime setup copilot # Recommendedapm runtime setup codexapm runtime setup llm
# Check installed runtimesapm runtime list“Command not found: copilot”
# Ensure Node.js v22+ and npm v10+ are installednode --version # Should be v22+npm --version # Should be v10+
# Reinstall Copilot CLIapm runtime setup copilot“Command not found: codex”
# Ensure PATH is updated (restart terminal)# Or reinstall runtimeapm runtime setup codexExtending APM with New Runtimes
Section titled “Extending APM with New Runtimes”APM’s runtime system is designed to be extensible. To add support for a new runtime:
Architecture
Section titled “Architecture”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
Adding a New Runtime
Section titled “Adding a New Runtime”- 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
Best Practices
Section titled “Best Practices”- 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)
Contributing
Section titled “Contributing”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!