Agent skill · data analytics · jeremylongshore

openrouter-performance-tuning

Optimize OpenRouter request latency and throughput. Use when building

Why this skill is useful

Provides specific optimization techniques and benchmarking scripts for OpenRouter that enhance performance beyond general knowledge.

What it needs

Requires openai, python3 installed locally. Requires openrouter account access. About 4k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.

What this skill does

OpenRouter Performance Tuning Overview OpenRouter adds minimal overhead (~50-100ms) to direct provider calls. Most latency comes from the upstream model. Key levers: model selection (smaller = faster), streaming (lower TTFT), parallel requests, prompt size reduction, and provider routing to faster infrastructure. This skill covers benchmarking, streaming optimization, concurrent processing, and connection tuning. Prerequisites An OpenRouter API key (sk-or-v1-...) exported as OPENROUTERAPIKEY — see the openrouter-install-auth skill for setup Python 3.8+ with the OpenAI SDK (openai package) — the examples use both the sync OpenAI client and AsyncOpenAI for parallel processing Credits on the key if you benchmark paid models like anthropic/claude-3.5-sonnet; a :free model is enough to validate the benchmark harness itself HTTP-Referer / X-Title header values for your app (set in every client constructor here) Instructions 1. Establish a baseline: run benchmarkmodel() from Benchmark Latency against your candidate models (e.g. openai/gpt-4o-mini vs anthropic/claude-3.5-sonnet) and record p50/p95. 2. Check the results against the Model Speed Tiers table to confirm each candidate sits in the right tier for your latency budget (200-500ms TTFT fastest tier; 5-30s for reasoning models). 3. Switch user-facing paths to streamcompletion() per Streaming for Lower TTFT and verify ttftms drops (typically 2-10x). 4. Move batch workloads to parallelcompletions() per Parallel Request Processing, capping concurrency with asyncio.Semaphore (maxconcurrent=5-10). 5. Apply Connection Optimization — one shared client with timeout=30.0 and maxretries=2 instead of a new client per request. 6. Work through the Performance Optimization Checklist (set maxtokens, shrink prompts, consider :nitro variants and provider routing), then re-run the benchmark to quantify each change. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills jeremylongshore/openrouter-performance-tuning

View the source on GitHub

Browse the @skills marketplace