stack/apps/backend/src/lib/ai/proxy-preprocessing.ts
BilalG1 0621ad2032
ai proxy fix (#1343)
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Refactor**
* Request sanitization now includes an extra proxy-specific
preprocessing step for safer AI proxying.
* **New Features**
* Initialization prompts centralized into a shared helper, with a
web-specific prompt variant.
* Authenticated requests can optionally route via a provided external
API key to access alternate models.
* **Chores**
* Added and exposed a preprocessing hook with a default no-op
implementation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-19 22:57:38 -07:00

9 lines
325 B
TypeScript

/**
* Opaque preprocessing step applied to every parsed request body that
* flows through the AI proxy. The concrete behavior lives in the
* private implementation; the fallback is an identity function.
*/
export type AiProxyBodyProcessor = (input: {
parsedBody: Record<string, unknown>,
}) => Record<string, unknown>;