openrouter-reference-architecture

Featured

Design production architectures using OpenRouter as the LLM gateway. Use when planning system design, reviewing architecture, or scaling AI applications. Triggers: 'openrouter architecture', 'openrouter system design', 'openrouter at scale', 'llm gateway architecture'.

AI & Automation 2,940 stars 439 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# OpenRouter Reference Architecture ## Overview OpenRouter serves as a unified LLM gateway, abstracting provider complexity. A production architecture wraps it with caching, rate limiting, cost controls, observability, and async processing. This skill provides three reference architectures: simple (single service), standard (microservice), and enterprise (event-driven). ## Architecture 1: Simple (Single Service) ``` ┌─────────────┐ ┌──────────────────────────┐ ┌──────────────┐ │ Your App │────▶│ OpenRouter Client │────▶│ OpenRouter │ │ │ │ - Retry (SDK built-in) │ │ /api/v1 │ │ │◀────│ - Cost tracking │◀────│ │ │ │ │ - Structured logging │ └──────────────┘ └─────────────┘ └──────────────────────────┘ ``` ```python import os, logging from openai import OpenAI log = logging.getLogger("llm") client = OpenAI( base_url="https://openrouter.ai/api/v1", api_key=os.environ["OPENROUTER_API_KEY"], max_retries=3, timeout=30.0, default_headers={"HTTP-Referer": "https://my-app.com", "X-Title": "my-app"}, ) def complete(prompt, model="openai/gpt-4o-mini", **kwargs): kwargs.setdefault("max_tokens", 1024) response = client.chat.completions.create( model=model, messages=[{"role": "user", "content": prompt}], **kwargs, ) log.info(f"[{response.model}] {response.usage.prompt_tokens}+{response.usage.completion_tokens} t...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category