AI RAG Injector Policy

RAG injection with OpenAI and Valkey

Configure the AI RAG Injector policy to use Valkey as a vector database and the OpenAI text-embedding-3-large model for embedding.

Valkey is automatically detected when using the redis vectordb strategy. AI Gateway queries the server and uses the Valkey-specific driver when it detects a Valkey backend.

This example uses text-embedding-3-large, which supports up to 3072 dimensions. If you use text-embedding-ada-002 instead, you must set dimensions to exactly 1536.

Prerequisites

  • An existing AI Model.

  • You have an OpenAI account.

  • A Valkey 8.x instance.

  • Port 6379, or your custom Valkey port, is open and reachable from AI Gateway.

Environment variables

  • OPENAI_API_KEY: The API key to use to connect to OpenAI.

  • VALKEY_HOST: The Valkey server’s host

Set up the policy

Attach the policy

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!