portkey

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.

Last repository push
GitHub Stars
219
Forks
38
Issues / PRs
7

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.

0 Downloads

Introduction source: third_party · TerminalSkills · 1.0.0 Reference

SkillPi interpretation

Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
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
    - production

Portkey — 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

  1. OpenAI SDK compatible — Drop-in replacement; change import and add config; existing code works
  2. Fallbacks — Route to backup provider when primary fails; 99.99% effective uptime
  3. Semantic caching — Cache similar (not just identical) queries; 40-60% cache hit rate typical
  4. Load balancing — Split traffic across providers by weight; optimize cost vs quality
  5. Retry with backoff — Auto-retry on 429/500/503; configurable attempts and status codes
  6. Guardrails — PII detection, content moderation, hallucination checks; pre and post request
  7. Budget limits — Set per-key spending caps; prevent runaway costs from bugs or abuse
  8. Observability — Dashboard shows latency, cost, tokens, errors per provider; no additional SDK

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 面向生产级 LLM 应用,解决缓存、故障转移、负载均衡等核心痛点
  • 功能闭环完整,受众明确(AI/ML 开发者)
Trigger Precision90/100

Highlights

  • 触发词覆盖全面(Portkey、gateway、caching、fallbacks 等),边界清晰
Structure and Standards90/100

Highlights

  • 结构清晰,包含完整 TypeScript 示例和最佳实践
  • frontmatter 完整,文档长度适中
Execution Reliability90/100

Highlights

  • 工具来源明确,参数配置正确,异常处理机制完善
Evidence Verifiability (mean of the first four)89/100

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.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

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.