Integrate your privately hosted LLMs with Portkey for unified management, observability, and reliability.
Portkey’s Bring Your Own LLM feature allows you to seamlessly integrate privately hosted language models into your AI infrastructure. This powerful capability enables unified management of both private and commercial LLMs through a consistent interface while leveraging Portkey’s comprehensive suite of observability and reliability features.
Prerequisites
Your private LLM must implement an API specification compatible with one of Portkey’s supported providers (e.g., OpenAI’s /chat/completions
, Anthropic’s /messages
, etc.).
Portkey offers two primary methods to integrate your private LLMs:
Navigate to the Virtual Keys section in your Portkey dashboard and create a new Virtual Key.
Adding a private LLM as a Virtual Key
OpenAI
)Custom Host
fieldAfter creating your virtual key, you can use it in your applications:
If you prefer not to store your private LLM details in Portkey’s vault, you can pass them directly in your API requests:
The custom_host
must include the API version path (e.g., /v1/
). Portkey will automatically append the endpoint path (/chat/completions
, /completions
, or /embeddings
).
For headers containing sensitive information that shouldn’t be logged or processed by Portkey, use the forward_headers
parameter to pass them directly to your private LLM:
In the JavaScript SDK, convert header names to camelCase. For example, X-My-Custom-Header
becomes xMyCustomHeader
.
You can also specify forward_headers
in your Gateway Config for consistent header forwarding:
Private LLMs work seamlessly with all Portkey Gateway features. Some common use cases:
Learn more about Gateway Configs.
Portkey provides comprehensive observability for your private LLM deployments, just like it does for commercial providers:
Portkey Analytics Dashboard for Private LLMs
Issue | Possible Causes | Solutions |
---|---|---|
Connection Errors | Incorrect URL, network issues, firewall rules | Verify URL format, check network connectivity, confirm firewall allows traffic |
Authentication Failures | Invalid credentials, incorrect header format | Check credentials, ensure headers are correctly formatted and forwarded |
Timeout Errors | LLM server overloaded, request too complex | Adjust timeout settings, implement load balancing, simplify requests |
Inconsistent Responses | Different model versions, configuration differences | Standardize model versions, document expected behavior differences |
Can I use any private LLM with Portkey?
Yes, as long as it implements an API specification compatible with one of Portkey’s supported providers (OpenAI, Anthropic, etc.). The model should accept requests and return responses in the format expected by that provider.
How do I handle multiple deployment endpoints?
You have two options:
Are there any request volume limitations?
Portkey itself doesn’t impose specific request volume limitations for private LLMs. Your throughput will be limited only by your private LLM deployment’s capabilities and any rate limits you configure in Portkey.
Can I use different models with the same private deployment?
Yes, you can specify different model names in your requests as long as your private LLM deployment supports them. The model name is passed through to your deployment.
Can I mix private and commercial LLMs in the same application?
Absolutely! One of Portkey’s key benefits is the ability to manage both private and commercial LLMs through a unified interface. You can even set up fallbacks between them or route requests conditionally.
Explore these related resources to get the most out of your private LLM integration: