portkey
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "portkey" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-bc8f88a5e73b9af66736dd6f70e05f9452f618fd4253aa8a022634543f14a948. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Portkey is an AI gateway placed between your application and LLM providers. Through a single unified API it adds caching, failover, load balancing, request retries, protections, semantic caching, budget limits, and observability for LLM calls, supporting over 200 models from OpenAI, Anthropic, Google, and open-source providers.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Testing
- Not tested
Browse files
Frontmatter
name: portkey
description: >-
You are an expert in Portkey, the AI gateway that sits between your app and
LLM providers. You help developers add caching, fallbacks, load balancing,
request retries, guardrails, semantic caching, budget limits, and
observability to LLM calls — using a single unified API that works with 200+
models from OpenAI, Anthropic, Google, and open-source providers.
license: Apache-2.0
compatibility: ''
metadata:
author: terminal-skills
version: 1.0.0
category: AI & Machine Learning
tags:
- llm
- gateway
- observability
- routing
- caching
- guardrails
- productionPortkey — AI Gateway for Production LLM Apps
You are an expert in Portkey, the AI gateway that sits between your app and LLM providers. You help developers add caching, fallbacks, load balancing, request retries, guardrails, semantic caching, budget limits, and observability to LLM calls — using a single unified API that works with 200+ models from OpenAI, Anthropic, Google, and open-source providers.
Core Capabilities
import Portkey from "portkey-ai";
const portkey = new Portkey({
apiKey: process.env.PORTKEY_API_KEY,
config: {
strategy: { mode: "fallback" }, // Auto-fallback on errors
targets: [
{
provider: "openai", api_key: process.env.OPENAI_KEY,
override_params: { model: "gpt-4o" },
weight: 0.7,
},
{
provider: "anthropic", api_key: process.env.ANTHROPIC_KEY,
override_params: { model: "claude-sonnet-4-20250514" },
weight: 0.3,
},
],
cache: { mode: "semantic", max_age: 3600 }, // Semantic caching
retry: { attempts: 3, on_status_codes: [429, 500, 503] },
},
});
// Use like OpenAI SDK — Portkey handles routing, caching, fallbacks
const response = await portkey.chat.completions.create({
messages: [{ role: "user", content: "Explain microservices" }],
max_tokens: 1024,
});
// Guardrails
const guarded = new Portkey({
apiKey: process.env.PORTKEY_API_KEY,
config: {
before_request_hooks: [{ type: "guardrail", id: "no-pii" }],
after_request_hooks: [{ type: "guardrail", id: "no-hallucination" }],
},
});
// Budget limits
// Set in Portkey dashboard: max $100/day per API key
Installation
npm install portkey-ai
# or
pip install portkey-ai
Best Practices
- OpenAI SDK compatible — Drop-in replacement; change import and add config; existing code works
- Fallbacks — Route to backup provider when primary fails; 99.99% effective uptime
- Semantic caching — Cache similar (not just identical) queries; 40-60% cache hit rate typical
- Load balancing — Split traffic across providers by weight; optimize cost vs quality
- Retry with backoff — Auto-retry on 429/500/503; configurable attempts and status codes
- Guardrails — PII detection, content moderation, hallucination checks; pre and post request
- Budget limits — Set per-key spending caps; prevent runaway costs from bugs or abuse
- Observability — Dashboard shows latency, cost, tokens, errors per provider; no additional SDK
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 面向生产级 LLM 应用,解决缓存、故障转移、负载均衡等核心痛点
- 功能闭环完整,受众明确(AI/ML 开发者)
Highlights
- 触发词覆盖全面(Portkey、gateway、caching、fallbacks 等),边界清晰
Highlights
- 结构清晰,包含完整 TypeScript 示例和最佳实践
- frontmatter 完整,文档长度适中
Highlights
- 工具来源明确,参数配置正确,异常处理机制完善
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 77, 79 -
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 35, 40, 45, 63, 71
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.