Apply security and data validation measures to vector embedding requests to protect sensitive information and ensure data quality.
Portkey’s guardrails aren’t limited to chat completions - they can also be applied to embedding requests. This means you can protect your embedding workflows with the same robust security measures you use for your other LLM interactions.
Vector embeddings form the backbone of modern AI applications, transforming text into numerical representations that power semantic search, recommendation systems, and RAG pipelines. However, unprotected embedding workflows create significant business risks that technical leaders cannot ignore.
Without proper guardrails, sensitive customer data can leak into vector databases, toxic content can contaminate downstream systems, and resources are wasted embedding low-quality inputs. Protecting these workflows is essential because:
By implementing guardrails at the embedding stage, you create a critical safety layer that protects your entire AI pipeline. For technical teams already building with embeddings, Portkey’s guardrails integrate seamlessly with existing workflows while providing the security measures that enterprise applications demand.
Guardrails for embeddings are applied at the “before request” stage, examining your text before it’s sent to the embedding model:
You can use any of Portkey’s “before request” guardrails with embedding requests:
Protect user privacy by preventing PII from being embedded
Filter content based on custom pattern matching
Block embedding requests with specific words/phrases
Ensure embeddings meet appropriate length requirements
Detect and block code snippets from being embedded
Implement your own custom guardrail logic
Utilize guardrails from Pangea, Pillar, and other partners
Prevent healthcare data from entering embedding systems
Filter out harmful content before embedding
Follow the standard process to create a guardrail in Portkey:
Guardrails
page and click Create
Make sure to select guardrails that support the beforeRequestHook
since embeddings only use pre-request validation.
Add your guardrail ID to the before_request_hooks
in your Portkey config:
Protecting Against PII in Embeddings: When building search systems or RAG applications, you need to ensure no personally identifiable information is inadvertently embedded:
Filtering Code from Document Embeddings: If you’re building a knowledge base that shouldn’t include code snippets:
Size-Based Filtering: Ensure only appropriately sized documents get embedded:
Custom Regex Filtering: Create domain-specific filters using regex patterns:
All guardrail actions on embedding requests are logged in the Portkey dashboard, just like other guardrail activities. You can:
If you’re implementing guardrails for embeddings and need assistance, reach out to the Portkey team on the community forum.