--- id: portkey-ai version: "2.3.4" license: MIT License license_treatment: permissive maintenance: active --- # portkey-ai — Python client library for the Portkey API License: permissive · Maintenance: active · Downloads: 976.9K/mo ## What it is and what it does Portkey is a Python client for the Portkey API that intercepts calls to OpenAI-compatible LLM providers and adds enterprise features on top. It maintains full API compatibility with the OpenAI SDK pattern, so you can adopt Portkey and immediately gain access to automated failover, load balancing across models, semantic caching, request tracing, and custom metadata tagging—all without rewriting your application logic. The package is built on httpx, pydantic, and anyio, enabling both sync and async usage patterns. It supports integrations with agent frameworks and offers virtual key management to keep API credentials secure. Observability features include request logging, tracing, feedback collection, and analytics. The SDK is actively maintained and supports Python 3.8 and later. Use it for: - Route LLM requests across multiple providers or models to reduce latency and cost via load balancing and semantic caching. - Implement automatic fallback to a secondary model or provider when the primary service is unavailable or slow. - Monitor and debug LLM application behavior with request tracing, custom metadata, and weighted user feedback. - Secure API keys by storing them in Portkey's vault and using disposable virtual keys instead of embedding credentials. - Integrate LLM calls into agent frameworks while retaining Portkey's observability and routing features. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Portkey is a Python SDK that wraps OpenAI-compatible APIs to add monitoring, failover, load balancing, caching, and observability without rewriting existing code. Yes. Portkey is actively maintained, has no known vulnerabilities, and offers genuine value for production LLM applications—especially if you need failover, load balancing, or observability without refactoring existing code. The MIT License is permissive. Install friction is low. The main prerequisite is a Portkey account and API key. ## Install pip install portkey-ai uv add portkey-ai poetry add portkey-ai ## Installing portkey-ai Before you install: Low install friction with a pure-Python wheel and 10 runtime dependencies. Actively maintained with a release 22 days ago. License in practice: MIT License permits commercial use, modification, and distribution with minimal restrictions—suitable for most projects. Quickstart: pip install portkey-ai export PORTKEY_API_KEY=your_key from portkey_ai import Portkey portkey = Portkey( api_key="PORTKEY_API_KEY", virtual_key="VIRTUAL_KEY" ) chat_completion = portkey.chat.completions.create( messages=[{"role": "user", "content": "Say this is a test"}], model="gpt-4" ) print(chat_completion) Requires a Portkey account and API key; virtual keys must be configured in Portkey's dashboard before use. Verify before relying: - Whether the 40+ production-critical metrics mentioned in analytics are documented or accessible via the SDK. - Performance overhead of semantic caching and request tracing relative to direct API calls. - Support status for providers beyond OpenAI-like implementations (fact sheet lists 'any OpenAI-like provider' but does not enumerate them). ## Package facts - License: MIT License (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 976.9K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags openai api gateway, llm failover and load balancing, ai observability and monitoring, semantic caching for llms, multi-provider llm routing, llm-gateway, observability, api-routing [View on SkillFed](https://skillfed.io/packages/portkey-ai) · [View on PyPI](https://pypi.org/project/portkey-ai/)