
Azure AI + Vercel AI SDK RAG Template
Live sample: https://vercelazurerag.azurewebsites.net/
A Next.js application, powered by the Vercel AI SDK, that uses retrieval-augmented generation (RAG) to reason and respond with information outside of the model's training data.
Features
- Information retrieval and addition through tool calls using the
streamTextfunction - Real-time streaming of model responses to the frontend using the
useChathook - Vector embedding retrieval with Azure AI Search using embeddings from Azure OpenAI
- Generative text streaming with Azure OpenAI
- Animated UI with Framer Motion
Getting Started
To get the project up and running, follow these steps:
-
Install dependencies:
npm install -
Copy the example environment file:
cp .env.example .env -
Create prerequisite resources in Azure AI:
- Azure AI Search index
- Optionally create a semantic search configuration and include vector fields in the index
Note: create a vector search index via REST API or within Azure Portal)
- Azure OpenAI Chat model
- Azure OpenAI Embedding model, if using vector search
Note: see available Azure OpenAI models here and deploy them using this guide
-
Add your Azure OpenAI and Azure AI Search variables to the
.envfile:AZURE_SEARCH_ENDPOINT=your_azure_search_endpoint_hereAZURE_SEARCH_KEY=your_azure_search_key_hereAZURE_SEARCH_INDEX_NAME=your_azure_search_index_name_hereAZURE_SEARCH_CONTENT_FIELD=your_azure_search_content_field_hereAZURE_SEARCH_VECTOR_FIELD=your_azure_search_vector_field_here # include if using vector searchAZURE_SEARCH_SEMANTIC_CONFIGURATION_NAME=your_azure_search_semantic_configuration_name_here # include if using semantic searchAZURE_OPENAI_API_ENDPOINT=your_azure_openai_api_endpoint_hereAZURE_RESOURCE_NAME=your_azure_resource_name_hereAZURE_DEPLOYMENT_NAME=your_azure_deployment_name_here # chat model deployment nameAZURE_EMBEDDING_DEPLOYMENT_NAME=your_azure_embedding_deployment_name_here # embedding model deployment nameAZURE_API_KEY=your_azure_api_key_here -
Start the development server:
npm run dev
Your project should now be running on http://localhost:3000.
Virtual Dev Environments
Appendix
This template includes code from Vercel's AI SDK RAG Template, which is licensed under the MIT license.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.


