Skip to content

Plugin Secure Proxy

The Orama Secure Proxy plugin is an official Orama plugin that allows you to perform vector and hybrid search securely on your browser by masking OpenAI (and other services soon) API keys when generating embeddings.

Installation

First of all, install it via npm (or any other package manager of your choice):

Terminal window
npm install @orama/plugin-secure-proxy

Usage

Now, when creating a new Orama Instance, make sure to install the plugin:

import { create } from "@orama/orama";
import { pluginSecureProxy } from "@orama/plugin-secure-proxy";
const secureProxy = secureProxyPlugin({
apiKey: "YOUR API KEY",
defaultProperty: "embeddings",
model: "openai/text-embedding-ada-002",
});
const db = create({
schema: {
title: "string",
description: "string",
embeddings: "vector[1536]",
},
plugins: [secureProxy],
});

Available models

Right now, the Orama Secure Proxy Plugin supports two different models for generating embeddings:

Model nameProviderDimensions
orama/gte-smallOrama384
orama/gte-mediumOrama768
orama/gte-largeOrama1024
openai/text-embedding-ada-002Openai1536
openai/text-embedding-3-smallOpenai1536
openai/text-embedding-3-largeOpenai3072

Running queries

By telling on which property to perform search by default (in the example above, 'embeddings'), the plugin will automatically translate your search term into a vector by calling the OpenAI API for you and setting the result into the vector.value property.

This will finally allow you to perform hybrid and vector search with the exact same APIs used for full-text search.

import { search } from '@orama/orama'
const resultsHybrid = await search(db, {
mode: 'hybrid',
term: 'Videogame for little kids with a passion about ice cream'
})
const resultsVector = await search(db, {
mode: 'vector',
term: 'Videogame for little kids with a passion about ice cream'
})

Specifying the vector property

If you have a more complex schema with multiple vector properties, you can always override the vector property to perform search on by using the default vector property:

const resultsVector = await search(db, {
mode: 'vector',
term: 'Videogame for little kids with a passion about ice cream',
vector: {
property: 'myAlternativeProperty'
}
})