Files
memex/notes/org-skill-auth-api-key.org

1.8 KiB

SKILL: API Key Authentication (Universal Literate Note)

Overview

This skill provides the legacy-compatible Static API Key authentication method. It retrieves credentials from the system environment variables and provides them to the kernel's neural backends.

Phase A: Demand (PRD)

1. Purpose

Provide a simple, environment-driven authentication mechanism for LLM providers.

2. User Needs

  • Static Retrieval: Pull `LLM_API_KEY` from `.env`.
  • Provider Mapping: Support mapping keys to specific providers (Gemini, OpenAI, etc.).
  • Reliability: Return NIL gracefully if no key is found.

Phase B: Blueprint (PROTOCOL)

1. Architectural Intent

Interfaces for credential retrieval. Source of truth is the system environment.

2. Semantic Interfaces

(defun auth-api-key-get-credentials ()
  "Returns a plist containing the :api-key for the default provider.")

Phase D: Build (Implementation)

(defun auth-api-key-get-credentials ()
  (let ((key (uiop:getenv "LLM_API_KEY")))
    (when key
      (list :api-key key))))

(defun register-auth-provider (provider-name credential-fn)
  "Register a simple API key provider in the kernel."
  (org-agent:register-auth-provider provider-name credential-fn))

;; Register as the default auth provider for Gemini during transition
(register-auth-provider :gemini #'auth-api-key-get-credentials)

Registration

(defskill :skill-auth-api-key
  :priority 100
  :trigger (lambda (context) nil)
  :neuro (lambda (context) nil)
  :symbolic (lambda (action context) action))