TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: An open-source AI Gateway with integrated guardrails

21 点作者 roh26it9 个月前
Hi HN,<p>I&#x27;ve been developing Portkey Gateway, an open-source AI gateway that&#x27;s now processing billions of tokens daily across 200+ LLMs. Today, we&#x27;re launching a significant update: integrated Guardrails at the gateway level.<p>Key technical features: 1. Guardrails as middleware: We&#x27;ve implemented a hooks architecture that allows guardrails to act as middleware in the request&#x2F;response flow. This enables real-time LLM output evaluation and transformation. 2. Flexible orchestration: The gateway can now route requests based on guardrail verdicts. This allows for complex logic like fallbacks to different models or prompts based on output quality. 3. Plugin system: We&#x27;ve designed a modular plugin system that allows integration of various guardrail implementations (e.g., anthropic&#x2F;constrained-llm, microsoft&#x2F;guidance). 4. Stateless design: The guardrails implementation maintains the gateway&#x27;s stateless nature, ensuring scalability and allowing for easy horizontal scaling. 5. Unified API: Despite the added complexity, we&#x27;ve maintained our unified API across different LLM providers, now extended to include guardrail configurations.<p>Implementation details: * The guardrails are implemented as async functions in the request pipeline. * We use a combination of regex and LLM-based evaluation for output validation. * The system supports both pre-processing (input modification) and post-processing (output filtering&#x2F;transformation) guardrails.<p>Performance impact: * Latency increase is minimal (&lt;50ms) for most deterministic guardrails. * We&#x27;ve implemented caching mechanisms to reduce repeated evaluations. * Since the gateway lives on the edge, it avoids longer roundtrips<p>Challenges we&#x27;re still tackling: * Balancing strict guardrails with maintaining model creativity * Standardizing evaluation metrics across different types of guardrails * Handling guardrail false positives&#x2F;negatives effectively<p>We believe this approach of integrating guardrails at the gateway level provides a powerful tool for managing LLM behavior in production environments.<p>The code is open-source, and we welcome contributions and feedback. We&#x27;re particularly interested in hearing about specific use cases or challenges you&#x27;ve faced in implementing reliable LLM systems.<p>Detailed documentation: <a href="https:&#x2F;&#x2F;portkey.wiki&#x2F;guardrails" rel="nofollow">https:&#x2F;&#x2F;portkey.wiki&#x2F;guardrails</a><p>What are your thoughts on this approach? Are there specific guardrail implementations or orchestration patterns you&#x27;d like to see added?

3 条评论

hrishi9 个月前
Love this!
brianjking9 个月前
Coming over from Twitter&#x2F;X (@iamrobotbear) -- congrats on the launch! Will dive into the docs, thanks for this!
评论 #41247563 未加载
namanyayg9 个月前
saw your tweet on X, nice work and congrats on launching!<p>i&#x27;m curious about the caching mechanisms you&#x27;ve implemented to reduce repeated evaluations - are you using a traditional cache store like redis or something more bespoke?
评论 #41246949 未加载