Files
memex/notes/org-skill-provider-openrouter.org

2.5 KiB

SKILL: OpenRouter Provider Agent (Universal Literate Note)

Overview

The OpenRouter Provider Agent acts as a unified gateway to hundreds of LLMs. It provides flexibility by dynamically switching between models based on intelligence tiers while maintaining architectural alignment.

Phase A: Demand (PRD)

1. Purpose

Define the interface for unified communication with the OpenRouter API.

2. User Needs

  • Abstraction: OpenAI-compatible interface for all OpenRouter models.
  • Dynamic Routing: Support for intelligence tiers (:POWERFUL, :FAST, :FREE).
  • Resilience: Leverage auto-routing fallbacks.
  • Transparency: Proper identification via Referer and Title headers.

3. Success Criteria

TODO Tiered Model Resolution

TODO OpenAI-Compatible Payload Generation

TODO Header Compliance Verification

Phase B: Blueprint (PROTOCOL)

1. Architectural Intent

Interfaces for executing neural completion requests via the unified OpenRouter gateway.

2. Semantic Interfaces

(defun execute-openrouter-request (prompt system-prompt)
  "Executes a completion request via the OpenRouter API.")

(defun get-openrouter-models ()
  "Returns a curated list of models across tiers.")

Phase D: Build (Implementation)

Request Execution

(defun execute-openrouter-request (prompt system-prompt)
  (let ((api-key (uiop:getenv "OPENROUTER_API_KEY")))
    (unless api-key (return-from execute-openrouter-request "ERROR: Key missing"))
    (let ((model (get-tiered-model :fast "meta-llama/llama-3-70b-instruct")))
      ;; Physical API call logic (mocked for refactor)
      (format nil "Executing OpenRouter request on ~a" model))))

Model Discovery

(defun get-openrouter-models ()
  '((:id "anthropic/claude-3.5-sonnet" :context "200k" :tier :powerful)
    (:id "google/gemini-flash-1.5" :context "1m" :tier :fast)
    (:id "openrouter/auto" :context "varying" :tier :free)))

Registration

(defskill :skill-provider-openrouter
  :priority 100
  :trigger (lambda (context) nil)
  :neuro (lambda (context) nil)
  :symbolic (lambda (action context) action))