docs: update AI Pipeline spec to use OpenRouter instead of OpenAI direct

Migrated from OpenAI direct API to OpenRouter for multiple advantages:

Cost Optimization:
- Reduced cost by ~25%: /bin/bash.00015/call (vs /bin/bash.0002/call OpenAI)
- Monthly estimate: ~/bin/bash.15 for 1000 calls (vs /bin/bash.20)

Provider Benefits:
- Access to 300+ AI models (OpenAI, Anthropic, Google, etc.)
- Automatic fallback between providers for 99.9% uptime
- Single API key for all providers
- Unified API interface

Technical Changes:
- Updated endpoint: api.openai.com → openrouter.ai/api/v1
- Model format: gpt-4o-mini → openai/gpt-4o-mini
- Added required headers: HTTP-Referer, X-Title
- Environment variables: OPENAI_API_KEY → OPENROUTER_API_KEY
  + OPENROUTER_SITE_URL (for OpenRouter ranking)
  + OPENROUTER_APP_NAME

Added Sections:
- 3.1 Why OpenRouter? (benefits comparison)
- 3.5 Model Fallback (automatic provider switching)
- Updated all code examples with OpenRouter integration
- Updated test cases (openai_client → openrouter_client)
- Updated cost estimates throughout document

References updated to OpenRouter documentation.

Refs: OpenRouter docs https://openrouter.ai/docs
This commit is contained in:
Luca Sacchi Ricciardi
2026-04-02 19:31:04 +02:00
parent 96ba01b349
commit d0f530f757
2 changed files with 135 additions and 52 deletions

View File

@@ -34,6 +34,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- n8n_automation_mastery: n8n workflow best practices
- context7_documentation_retrivial: Context-aware documentation lookup
- docs: Add requirements.txt with Python dependencies (pytest, requests)
- docs: Add AI Pipeline technical specification
- System prompt with Metodo Sacchi integration (Safety First, Little Often, Double Check)
- OpenRouter configuration (migrated from OpenAI direct)
- 25% cost savings (~$0.00015/call vs ~$0.0002/call)
- Multi-provider fallback (300+ models available)
- Automatic failover if primary provider down
- Complete n8n Code Node JavaScript implementation
- OpenRouter endpoint: https://openrouter.ai/api/v1
- Required headers: HTTP-Referer, X-Title for ranking
- Model format: provider/model (e.g., openai/gpt-4o-mini)
- JSON output schema with severity mapping (critical/medium/low)
- Error handling with circuit breaker pattern
- Security guidelines (data sanitization, rate limiting)
- 10 acceptance criteria defined
- 5 test scenarios with expected input/output
- 5 real-world examples (OOM, disk full, connection refused, etc.)
- Implementation checklist for developers
### Changed