Noureddine RAMDI / PAI-OpenCode: modular multi-agent AI infrastructure with smart model routing

Created Mon, 04 May 2026 10:23:02 +0000 Modified Sat, 23 May 2026 20:41:27 +0000

Steffen025/pai-opencode

PAI-OpenCode tackles a common challenge in AI assistant frameworks: how to orchestrate multiple AI models across specialized agents efficiently while keeping the core lightweight and extensible. Unlike many AI coding assistants that rely on a single provider or manual switching, this project automatically routes tasks to different agents based on complexity and type, optimizing both cost and performance.

what pai-opencode does and how it’s built

PAI-OpenCode is a community-driven port of Daniel Miessler’s Personal AI Infrastructure (PAI v3.0) tailored to OpenCode, an open-source, provider-agnostic AI coding assistant. It supports over 75 AI providers, making it highly flexible for developers who want to avoid vendor lock-in.

At its core, the system is built in TypeScript and features a modular architecture:

  • 16 dynamically orchestrated agents: Each agent can be assigned a different AI model or provider, with task routing done automatically based on the nature and complexity of the request.
  • 52 modular skills: Skills represent discrete capabilities or integrations that agents can leverage, allowing for a highly composable system.
  • 8-level effort algorithm with Verify Completion Gate: This controls how rigorously tasks are verified for completion, balancing thoroughness and efficiency.
  • Session memory with learning loops: Agents maintain state and can improve over time through repeated interactions.
  • Event-driven plugin system: Extends functionality without bloating the core codebase.

One of the most striking architectural decisions is the separation between the core PAI infrastructure and product-layer features. The core is a minimal, developer-focused tool, while heavier user-facing features are reserved for a related project called Open Arc.

The core itself is impressively lightweight, around 20KB when lazy-loaded, compared to a typical 233KB static load seen in similar projects. This drastically reduces startup time and resource consumption.

the multi-agent architecture and modular design that stand out

What sets PAI-OpenCode apart is its agent-based model routing. Instead of a single monolithic model or manual provider switching, the system dynamically routes tasks to the most appropriate agent with a suitable AI model:

  • Cost optimization: Lightweight agents handle simple tasks, while heavyweight models are reserved for complex reasoning.
  • Provider diversity: Supports 75+ providers, enabling fallback strategies and multi-provider research routing.
  • Security: Implements prompt injection protection with over 200 patterns, an often overlooked but critical feature when dealing with AI prompts.

The modular skills system allows developers to extend capabilities easily without modifying the core. This modularity is paired with an event-driven plugin lifecycle, which makes the system adaptable and maintainable.

The codebase is surprisingly clean for a project of this complexity, with clear separation of concerns. The 8-level effort algorithm is a nice touch to control task completion rigorously, avoiding premature task finalization or endless loops.

The tradeoff here is complexity: managing 16 agents and 52 skills requires careful configuration and understanding. The project doesn’t come with out-of-the-box product features; it’s more of an infrastructure layer, so expect to invest time in tailoring it to your needs.

quick start with the interactive installer and provider setup

The project offers an interactive terminal installer wizard that simplifies the initial setup. Here are the exact commands from the README for new users:

# Run the interactive terminal installer wizard
bash PAI-Install/install.sh

After installation, connecting AI providers is a two-step process that does not require reinstalling the project:

  1. Run /connect inside OpenCode to store your API credentials:
/connect
  1. Update agent model assignments in opencode.json to point to your chosen provider:
bun run .opencode/tools/switch-provider.ts anthropic   # or zen-paid, openai, etc.

For multi-provider research routing, enable it anytime with:

bun run .opencode/tools/switch-provider.ts anthropic --multi-research

The project requires API keys for some researchers (GeminiResearcher, GrokResearcher, PerplexityResearcher, CodexResearcher), but falling back to your primary provider is supported if keys are missing.

This setup process balances ease of use with flexibility, letting you start quickly but customize deeply.

verdict: who is pai-opencode for and what to expect

PAI-OpenCode is a solid choice for developers and researchers who want a modular, provider-agnostic AI infrastructure with sophisticated multi-agent orchestration.

Its minimal 20KB lazy-loaded core is a concrete advantage for performance-conscious users. The automatic model routing across 16 agents is a practical approach to balancing cost and capability.

However, it’s not a plug-and-play AI assistant with polished user features out of the box. The focus on core infrastructure means you’ll need to invest time in configuration and extension, especially if you want to build user-facing products.

The security measures around prompt injection and the modular skills system show attention to real-world concerns.

If you’re building custom AI tooling or want to experiment with multi-agent AI orchestration across many providers, PAI-OpenCode is worth exploring. For those seeking a ready-made AI assistant or simpler single-provider setups, other projects may be more straightforward.

Overall, PAI-OpenCode offers a developer-focused, extensible foundation with smart architectural decisions that merit attention from those serious about AI infrastructure.


→ GitHub Repo: Steffen025/pai-opencode ⭐ 161 · TypeScript