1. The Multi-Model Routing Challenge

Modern software engineering workflows increasingly require different AI models for different programming tasks. An engineer might prefer Claude 3.5 Sonnet for complex refactoring and AST transformations, ChatGPT-4o for rapid code explanations, DeepSeek R1 for algorithmic proofs, and Perplexity for querying live framework documentation.

However, managing four independent AI models locally introduces severe security and operational challenges:

  • Cookie & State Collisions: If models run inside a shared browser environment or single cookie jar, cross-origin scripts and authentication tokens can leak between provider contexts.
  • Insecure Key Storage: Storing raw API tokens in plain-text .env or JSON configuration files leaves developer credentials vulnerable to malicious npm packages or repository leakage.
  • Latency & Interception: Passing requests through intermediate cloud relays introduces latency and violates enterprise data compliance mandates.

Proxima resolves this through a Local-First Routing Engine combining Electron partition sandboxing, hardware-backed OS keychain encryption, and a local loopback IPC socket.

2. Sandboxed Partition Isolation (persist:*)

In Proxima's desktop core (proxima/electron/main-v2.cjs), each AI provider session is allocated a dedicated, persistent Electron session.fromPartition() partition.

The four isolated web session partitions are:

  • persist:chatgpt — Sandboxed OpenAI conversational container
  • persist:claude — Isolated Anthropic session storage
  • persist:gemini — Sandboxed Google AI workspace
  • persist:perplexity — Isolated search and real-time citation context
JavaScript // proxima/electron/main-v2.cjs
const { session, BrowserWindow } = require('electron');

// Initializing Isolated Session Partitions with Strict Local Boundaries
function createProviderView(providerId) {
  const ses = session.fromPartition(`persist:${providerId}`, {
    cache: true
  });

  // Strict CSP & WebSecurity Enforcements
  ses.setPermissionRequestHandler((webContents, permission, callback) => {
    // Explicitly deny camera, microphone, geolocation, and notification permissions
    const allowedPermissions = ['clipboard-read'];
    return callback(allowedPermissions.includes(permission));
  });

  return ses;
}

Because partitions are completely isolated by Chromium's storage layer, IndexedDB caches, localStorage records, cookies, and HTTP connection pools are segregated. A script or token inside the persist:chatgpt partition cannot read or inspect memory from persist:claude.

3. Loopback IPC Bridge (Port 19222)

The Model Context Protocol (MCP) server runs as a separate Node.js child process spawned by your IDE over standard input/output. To route tool invocations from the MCP process to the active Electron provider window, Proxima uses an internal loopback TCP socket on port 19222.

IDE (Cursor / VSCode) [MCP Host Process]
↓ stdio duplex stream
Proxima MCP Server (src/mcp/index.js)
↓ TCP Socket (127.0.0.1:19222)
Electron Hub Layer (electron/main-v2.cjs)
Routes to active WebContents partition (ChatGPT, Claude, Gemini, Perplexity)
Figure 2: Inter-Process Communication (IPC) Socket Topology
JavaScript // proxima/src/mcp/ipc-bridge.js
import net from 'net';

const IPC_PORT = process.env.PROXIMA_IPC_PORT || 19222;

export function sendToElectron(payload) {
  return new Promise((resolve, reject) => {
    const client = net.createConnection({ port: IPC_PORT, host: '127.0.0.1' }, () => {
      client.write(JSON.stringify(payload) + '\n');
    });

    let rawData = '';
    client.on('data', (chunk) => {
      rawData += chunk.toString();
      if (rawData.endsWith('\n')) {
        client.end();
        try {
          const parsed = JSON.parse(rawData.trim());
          resolve(parsed);
        } catch (e) {
          reject(new Error(`Malformed IPC response: ${e.message}`));
        }
      }
    });

    client.on('error', (err) => {
      reject(new Error(`IPC Bridge connection error on port ${IPC_PORT}: ${err.message}`));
    });
  });
}

4. Hardware-Backed Encryption via Electron SafeStorage

When developers choose to use API keys instead of browser sessions, credentials must be stored securely. In proxima/electron/api/byok/keys.cjs, Proxima leverages Electron’s safeStorage API to encrypt API keys before persisting them to disk (byok.json).

SafeStorage delegates cryptography directly to the host operating system's native hardware-backed credential vaults:

  • Windows: Data Protection API (DPAPI) tied to user account cryptographic keys.
  • macOS: Apple Keychain with AES-128 encryption.
  • Linux: Secret Service API or GNOME Keyring / KWallet.
JavaScript // proxima/electron/api/byok/keys.cjs
const { safeStorage } = require('electron');
const fs = require('fs/promises');
const path = require('path');

// Encrypt API key using OS keychain before writing to ~/.proxima/byok.json
async function saveApiKey(provider, rawApiKey) {
  if (!safeStorage.isEncryptionAvailable()) {
    throw new Error('OS Keychain encryption (SafeStorage) is not available on this platform.');
  }

  const encryptedBuffer = safeStorage.encryptString(rawApiKey);
  const base64Cipher = encryptedBuffer.toString('base64');

  const configPath = path.join(process.env.USERPROFILE || process.env.HOME, '.proxima', 'byok.json');
  let currentKeys = {};
  try {
    const raw = await fs.readFile(configPath, 'utf8');
    currentKeys = JSON.parse(raw);
  } catch {
    currentKeys = {};
  }

  currentKeys[provider] = base64Cipher;
  await fs.writeFile(configPath, JSON.stringify(currentKeys, null, 2), 'utf8');
  return { success: true, provider };
}

// Decrypt API key on-demand during request execution
async function getApiKey(provider) {
  const configPath = path.join(process.env.USERPROFILE || process.env.HOME, '.proxima', 'byok.json');
  const raw = await fs.readFile(configPath, 'utf8');
  const keys = JSON.parse(raw);

  if (!keys[provider]) return null;

  const buffer = Buffer.from(keys[provider], 'base64');
  return safeStorage.decryptString(buffer);
}

5. The 12 BYOK Providers Pipeline

A codebase audit confirms that Proxima provides built-in adapter modules for exactly 12 BYOK Providers:

Provider ID Adapter Module Target API Endpoint
chatgpt providers/openai.cjs https://api.openai.com/v1/chat/completions
claude providers/anthropic.cjs https://api.anthropic.com/v1/messages
gemini providers/gemini.cjs https://generativelanguage.googleapis.com/v1beta/models
perplexity providers/perplexity.cjs https://api.perplexity.ai/chat/completions
deepseek providers/deepseek.cjs https://api.deepseek.com/v1/chat/completions
groq providers/groq.cjs https://api.groq.com/openai/v1/chat/completions
xai providers/xai.cjs https://api.x.ai/v1/chat/completions
openrouter providers/openrouter.cjs https://openrouter.ai/api/v1/chat/completions
together providers/together.cjs https://api.together.xyz/v1/chat/completions
fireworks providers/fireworks.cjs https://api.fireworks.ai/inference/v1/chat/completions
mistral providers/mistral.cjs https://api.mistral.ai/v1/chat/completions
nvidia providers/nvidia.cjs https://integrate.api.nvidia.com/v1/chat/completions

6. Engineering Trade-offs: Web Sessions vs BYOK API Keys

Selecting between Web Session Routing and BYOK API keys depends on your team's workflow requirements:

Dimension Web Session Routing (Electron Partitions) BYOK API Keys (Direct REST)
Setup Requirement Log in once in desktop app partition Acquire API key from cloud developer console
Billing Mechanism Uses existing personal/pro user subscription Pay-per-token billed directly by provider
Rate Limit Profile Standard web tier concurrency High-throughput tier concurrency
Headless CLI Support Requires Electron background runtime Runs completely headless in terminal/CI

7. Failure Analysis & Troubleshooting

Symptom Cause Diagnosis Fix
SafeStorage encryption unavailable Running on a Linux distribution without a configured D-Bus secret service. Check if gnome-keyring or kwallet is running. Install libsecret-1-0 and unlock the default system keyring.
Session expired / re-login required Provider session cookie reached natural cloud expiration interval. Open provider tab in Proxima desktop app to verify login prompt. Complete interactive authentication; session will persist in partition.
Port 19222 address already in use A zombie instance of Proxima Electron is already bound to loopback socket. Run netstat -ano | findstr 19222 in Command Prompt / Terminal. Terminate orphan process with taskkill /PID <PID> /F and relaunch.

8. Architectural Takeaways

By combining strict Electron partition sandboxing, OS keychain encryption with SafeStorage, and a loopback IPC bridge on port 19222, Proxima delivers multi-model AI routing with rigorous local security boundaries.