# AI RAG Configuration

The `ai-rag` plugin retrieves context with Azure OpenAI embeddings and Azure AI Search before an LLM request is proxied.<!-- --> <!-- -->Configuration covers plugin parameters and request body fields.

## Plugin Parameters[​](#plugin-parameters "Direct link to Plugin Parameters")

See plugin [common configurations](https://docs.api7.ai/apisix/reference/plugin-common-configurations.md) for configuration options available to all plugins.

* embeddings\_provider

  object

  required

  ***

  Provider used to generate the embedding for vector retrieval.

  * azure\_openai

    object

    required

    ***

    [Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-services/openai-service) endpoint and authentication used to generate embeddings.

    * endpoint

      string

      required

      ***

      Azure OpenAI embedding model endpoint.

    * api\_key

      string

      required

      ***

      Azure OpenAI API key. Encrypted at rest when data encryption is enabled for gateway configuration storage.

* vector\_search\_provider

  object

  required

  ***

  Provider used to retrieve context with the generated embedding.

  * azure\_ai\_search

    object

    required

    ***

    [Azure AI Search](https://azure.microsoft.com/en-us/products/ai-services/ai-search) endpoint and authentication used for vector retrieval.

    * endpoint

      string

      required

      ***

      Azure AI Search endpoint.

    * api\_key

      string

      required

      ***

      Azure AI Search API key. Encrypted at rest when data encryption is enabled for gateway configuration storage.

* ssl\_verify

  boolean

  default: `true`

  ***

  If true, verify TLS certificates when calling the embedding and vector search endpoints. Set to false only for temporary development or migration with an untrusted certificate.

  Introduced in API7 Enterprise 3.9.10 and APISIX 3.17.0.

## Request Body Parameters[​](#request-body-parameters "Direct link to Request Body Parameters")

Configure the `ai_rag` request object with the following fields.

* ai\_rag

  object

  required

  ***

  Retrieval input used to generate an embedding and search for context before the LLM request is proxied.

  * embeddings

    object

    required

    ***

    Input sent to Azure OpenAI to generate the embedding used for retrieval.

    * model

      string

      ***

      Azure OpenAI embedding deployment name. Required in the request body when the configured endpoint uses the Azure OpenAI v1 API. A legacy deployment-specific endpoint already identifies the deployment in its URL.

    * input

      string

      required

      ***

      Text used to generate the embedding for vector retrieval. Include the user request separately in the LLM protocol's prompt field, such as `messages` for Chat Completions.

    * user

      string

      ***

      A unique identifier representing your end user, which helps in monitoring and detecting abuse.

    * encoding\_format

      string

      default: `float`

      valid value:

      `float` or `base64`

      ***

      Data type of the returned embeddings.

    * dimensions

      integer

      ***

      Requested number of dimensions in the embedding output. When configured, it must match the Azure AI Search vector field dimensions. The dimensions for `text-embedding-ada-002` are fixed at 1536. For `text-embedding-3-small` and `text-embedding-3-large`, supported values range from 1 to 1536 and 3072, respectively.

  * vector\_search

    object

    required

    ***

    Azure AI Search vector retrieval input.

    * fields

      string

      required

      ***

      Name of the Azure AI Search vector field used for retrieval.
