{"id":11876,"date":"2026-02-10T10:27:15","date_gmt":"2026-02-10T18:27:15","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=11876"},"modified":"2026-03-19T09:45:48","modified_gmt":"2026-03-19T16:45:48","slug":"building-ai-powered-apps-azure-cosmos-db-vercel","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/building-ai-powered-apps-azure-cosmos-db-vercel\/","title":{"rendered":"Building AI-Powered Apps with Azure Cosmos DB and the Vercel AI SDK"},"content":{"rendered":"<p>The <a href=\"https:\/\/ai-sdk.dev\/\">Vercel AI SDK<\/a> is an open-source TypeScript toolkit that provides the core building blocks for integrating AI into any JavaScript application. It works with 20+ AI providers out of the box\u2014including OpenAI, Azure OpenAI, Anthropic, Google, Mistral, and more\u2014so you can write your code once and switch providers by changing a single import.<\/p>\n<p>At its core, the SDK handles streaming (responses appear word-by-word instead of making users wait), tool calling (allowing the AI to invoke your functions, such as querying a database), and multi-step agentic reasoning, where the AI chains multiple tool calls together to answer complex questions.<\/p>\n<p>It also provides a useChat() React hook that manages the entire chat lifecycle on the frontend, uses Zod schemas for type-safe tool validation, supports structured output so the AI can return typed JSON instead of plain text, and enables generative UI where the AI returns rendered React components. With built-in middleware for logging, caching, and guardrails, the Vercel AI SDK is one of the fastest ways for JavaScript and TypeScript developers to move from prototype to a production-ready AI experience.<\/p>\n<p>When you pair this powerful Vercel AI SDK with Azure Cosmos DB, a globally distributed, low-latency NoSQL database, you get a compelling combination that allows your AI to query, reason over, and present real-time operational data through natural conversation. In this post, we will walk through building a complete AI-powered product assistant that brings these two technologies together, guided by the <a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/gen-ai\/agent-kit\">Azure Cosmos DB Agent Kit<\/a> and its production best practices.<\/p>\n<p>Want to skip ahead and dive into the code? The complete working sample including the Azure Cosmos DB service layer includes definitions, streaming API route, and seed script\u00a0 is available on <a href=\"https:\/\/github.com\/sajeetharan\/cosmos-ai-vercel-app\">GitHub<\/a>. Clone it, plug in your credentials, and you&#8217;ll have a running AI assistant in minutes.<\/p>\n<p><center><iframe title=\"Build an AI Powered Chat Assistant with Vercel AI SDK + Azure Cosmos DB + Agent Kit Description\" src=\"https:\/\/www.youtube.com\/embed\/B3m4lRoIyMA\" width=\"934\" height=\"526\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><\/center><\/p>\n<h2>The Problem with Traditional Product Experiences<\/h2>\n<p>The era of &#8220;search bars and filters&#8221; for product catalogs is ending. Users expect conversational experiences \u2014 <em>&#8220;Show me surfboards under $500&#8221;<\/em>, <em>&#8220;What&#8217;s trending in electronics?&#8221;<\/em>, or <em>&#8220;Compare the top 3 items in outdoor gear.&#8221;<\/em><\/p>\n<p>Building this traditionally means gluing together a search engine, a recommendation service, and dozens of API endpoints. But with <strong>Azure Cosmos DB<\/strong> as your operational data store and the <strong>Vercel AI SDK<\/strong> orchestrating LLM tool calls, you can build a single intelligent assistant that:<\/p>\n<ul>\n<li><strong>Queries your database<\/strong> in real time using natural language<\/li>\n<li><strong>Streams responses<\/strong> token-by-token for a snappy UX<\/li>\n<li><strong>Runs multi-step reasoning<\/strong> \u2014 the AI can query, filter, aggregate, and present results across multiple tool calls<\/li>\n<li><strong>Follows production best practices<\/strong> automatically via the Azure Cosmos DB Agent Kit<\/li>\n<\/ul>\n<h2>Architecture at a Glance:<\/h2>\n<p>This solution is built on two core <strong>Azure services<\/strong>:<\/p>\n<ul>\n<li><a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/nosql\/\"><strong>Azure Cosmos DB NoSQL<\/strong><\/a> \u2014 The globally distributed, low-latency database that stores and serves product catalog data in real time.<\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/azure\/ai-foundry\/\"><strong>Microsoft<\/strong><strong> AI Foundry<\/strong><\/a> \u2014 The platform that hosts and manages the GPT-4.1 model used for natural language understanding and tool-call orchestration.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Architecture-Vercel.png\"><img decoding=\"async\" class=\"size-full wp-image-11879 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Architecture-Vercel.png\" alt=\"Architecture 8211 Vercel image\" width=\"624\" height=\"532\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Architecture-Vercel.png 624w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Architecture-Vercel-300x256.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p><span class=\"TextRun SCXW30664513 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun CommentStart CommentHighlightPipeClicked CommentHighlightClicked SCXW30664513 BCX0\">The frontend uses the AI SDK&#8217;s\u00a0<\/span><\/span><span class=\"TextRun Highlight SCXW30664513 BCX0\" lang=\"EN-US\" style=\"font-family: terminal, monaco, monospace;\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SpellingErrorV2Themed CommentHighlightClicked SCXW30664513 BCX0\">useChat<\/span><span class=\"NormalTextRun CommentHighlightClicked SCXW30664513 BCX0\">()<\/span><\/span><span class=\"TextRun SCXW30664513 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun CommentHighlightClicked SCXW30664513 BCX0\">\u00a0hook for streaming. The API route uses\u00a0<\/span><\/span><span class=\"TextRun Highlight SCXW30664513 BCX0\" lang=\"EN-US\" style=\"font-family: terminal, monaco, monospace;\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SpellingErrorV2Themed CommentHighlightClicked SCXW30664513 BCX0\">streamText<\/span><span class=\"NormalTextRun CommentHighlightClicked SCXW30664513 BCX0\">()<\/span><\/span><span class=\"TextRun SCXW30664513 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun CommentHighlightClicked SCXW30664513 BCX0\"><span style=\"font-family: terminal, monaco, monospace;\">\u00a0<\/span>to orchestrate GPT-4.1 with four Azure Cosmos DB<\/span><span class=\"NormalTextRun CommentHighlightClicked SCXW30664513 BCX0\">\u00a0<\/span><span class=\"NormalTextRun CommentHighlightClicked SCXW30664513 BCX0\">backed tools\u00a0\u00a0<\/span><\/span><span class=\"TextRun Highlight SCXW30664513 BCX0\" lang=\"EN-US\" style=\"font-family: terminal, monaco, monospace;\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SpellingErrorV2Themed CommentHighlightClicked SCXW30664513 BCX0\">queryProducts<\/span><\/span><span class=\"TextRun SCXW30664513 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun CommentHighlightClicked SCXW30664513 BCX0\">,\u00a0<\/span><\/span><span class=\"TextRun Highlight SCXW30664513 BCX0\" lang=\"EN-US\" style=\"font-family: terminal, monaco, monospace;\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SpellingErrorV2Themed CommentHighlightClicked SCXW30664513 BCX0\">getProduct<\/span><\/span><span class=\"TextRun SCXW30664513 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun CommentHighlightClicked SCXW30664513 BCX0\">,\u00a0<\/span><\/span><span class=\"TextRun Highlight SCXW30664513 BCX0\" lang=\"EN-US\" style=\"font-family: terminal, monaco, monospace;\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SpellingErrorV2Themed CommentHighlightClicked SCXW30664513 BCX0\">getCatalogInsights<\/span><\/span><span class=\"TextRun SCXW30664513 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun CommentHighlightClicked SCXW30664513 BCX0\">, and\u00a0<\/span><\/span><span class=\"TextRun Highlight SCXW30664513 BCX0\" lang=\"EN-US\" style=\"font-family: terminal, monaco, monospace;\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SpellingErrorV2Themed CommentHighlightClicked SCXW30664513 BCX0\">searchCatalog<\/span><\/span><span class=\"TextRun SCXW30664513 BCX0\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun CommentHighlightClicked SCXW30664513 BCX0\">. All database access follows Agent Kit best practices (singleton client, parameterized queries, partition-aware reads, RU monitoring).<\/span><\/span><span class=\"EOP CommentHighlightPipeClicked SCXW30664513 BCX0\" data-ccp-props=\"{&quot;335559739&quot;:120}\">\u00a0<\/span><\/p>\n<h3>Key Benefits of the Vercel AI SDK<\/h3>\n<ol>\n<li><strong> LLM Orchestration Without Boilerplate<\/strong>\nWithout the AI SDK, you would need to manually construct chat-completion API calls, parse JSON tool-call responses, execute the right function, feed results back into the next prompt, and handle retries and errors \u2014 all from scratch. The AI SDK&#8217;s <span style=\"font-family: terminal, monaco, monospace;\">streamText()<\/span> function handles this entire loop in a single call.<\/li>\n<li><strong> Type-Safe Tool Definitions<\/strong>\nThe tool() helper lets you define tools with Zod schemas. The SDK automatically generates the JSON schema for the LLM, validates incoming parameters at runtime, and provides full TypeScript inference \u2014 no manual schema wiring.<\/li>\n<li><strong> Multi-Step Reasoning (Agentic Loop)<\/strong>\nWith stopWhen: <span style=\"font-family: terminal, monaco, monospace;\">stepCountIs(5)<\/span>, the AI SDK enables the LLM to make up to 5 sequential tool calls before producing its final answer. This means a single user prompt like <em>&#8220;Compare surfboards and paddleboards under $500&#8221;<\/em> can trigger queryProducts twice and synthesize results \u2014 all automatically orchestrated.<\/li>\n<li><strong> Built-in Streaming<\/strong>\nThe <span style=\"font-family: terminal, monaco, monospace;\">toUIMessageStreamResponse()<\/span> helper converts the LLM output into a streaming HTTP response. On the client, <span style=\"font-family: terminal, monaco, monospace;\">useChat()<\/span> consumes this stream and re-renders the chat UI token-by-token \u2014 giving users instant visual feedback instead of waiting for the full response.<\/li>\n<li><strong> Provider Agnostic<\/strong>\nThe AI SDK supports 20+ model providers (OpenAI, Azure OpenAI, Anthropic, Google, Mistral, etc.) through a unified interface. Switching from Azure OpenAI to another provider requires changing a single import \u2014 no rewrite of your tool definitions, streaming logic, or frontend code.<\/li>\n<\/ol>\n<h3>How They Work Together<\/h3>\n<p>The Azure Cosmos DB SDK is your data engine. The Vercel AI SDK is your AI engine. Together, they turn a database into a conversational experience.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Vercel-AI-SDK-Cosmos-DB.png\"><img decoding=\"async\" class=\"size-full wp-image-11880 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Vercel-AI-SDK-Cosmos-DB.png\" alt=\"Vercel AI SDK Cosmos DB image\" width=\"2500\" height=\"988\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Vercel-AI-SDK-Cosmos-DB.png 2500w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Vercel-AI-SDK-Cosmos-DB-300x119.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Vercel-AI-SDK-Cosmos-DB-1024x405.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Vercel-AI-SDK-Cosmos-DB-768x304.png 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Vercel-AI-SDK-Cosmos-DB-1536x607.png 1536w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/02\/Vercel-AI-SDK-Cosmos-DB-2048x810.png 2048w\" sizes=\"(max-width: 2500px) 100vw, 2500px\" \/><\/a><\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li><strong>Nodejs 20+<\/strong><\/li>\n<li>An <strong>Azure Cosmos DB NoSQL<\/strong> account (<a href=\"https:\/\/learn.microsoft.com\/azure\/cosmos-db\/free-tier\">free tier available<\/a>)<\/li>\n<li>An <strong>Azure OpenAI<\/strong> resource <strong><a href=\"https:\/\/azure.microsoft.com\/products\/ai-foundry\/models\/openai\">in Microsoft Foundry<\/a><\/strong> with a GPT-4.1 deployment (or any <a href=\"https:\/\/ai-sdk.dev\/providers\">AI SDK-compatible provider<\/a>)<\/li>\n<li>The <strong><a href=\"https:\/\/github.com\/AzureCosmosDB\/cosmosdb-agent-kit\">Azure Cosmos DB Agent Kit<\/a><\/strong> installed in your IDE\n<pre class=\"prettyprint language-ts\"><code class=\"language-ts\">npx skills add AzureCosmosDB\/cosmosdb-agent-kit<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2>Step 1: Project Setup<\/h2>\n<p>git clone <a href=\"https:\/\/github.com\/sajeetharan\/cosmos-ai-vercel-app.gitcd cosmos-ai-vercel-app\">https:\/\/github.com\/sajeetharan\/cosmos-ai-vercel-app.gitcd cosmos-ai-vercel-app<\/a><\/p>\n<pre class=\"prettyprint language-js\"><code class=\"language-js\">npm install<\/code><\/pre>\n<p>Copy the environment template and fill in your credentials:<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">cp .env.example .env.local<\/code><\/pre>\n<p>You will need your Azure Cosmos DB endpoint and key, along with your Azure OpenAI endpoint, key, and deployment name. Refer to the for full setup instructions.<\/p>\n<h2>Step 2: The Azure Cosmos DB Service \u2014 Agent Kit Best Practices in Action<\/h2>\n<p>The heart of the app is the Azure Cosmos DB service layer. The Azure Cosmos DB Agent Kit guided every function in this module to follow production best practices:<\/p>\n<ul>\n<li><strong>Singleton client<\/strong> <span style=\"font-family: terminal, monaco, monospace;\">(sdk-singleton-client)<\/span> \u2014 One CosmosClient instance reused across all requests, with retry policies for 429 rate limiting (sdk-retry-429)<\/li>\n<li><strong>Parameterized queries<\/strong> <span style=\"font-family: terminal, monaco, monospace;\">(query-parameterize)<\/span> \u2014 All user input goes through query parameters, never string concatenation<\/li>\n<li><strong>Field projection<\/strong> <span style=\"font-family: terminal, monaco, monospace;\">(query-use-projections)<\/span> \u2014 SELECT only the fields needed to minimize RU consumption<\/li>\n<li><strong>Point reads<\/strong> <span style=\"font-family: terminal, monaco, monospace;\">(query-avoid-cross-partition)<\/span> \u2014 When both id and partition key are known, use a direct point read instead of a query<\/li>\n<li><strong>RU monitoring<\/strong> <span style=\"font-family: terminal, monaco, monospace;\">(monitoring-ru-consumption)<\/span> \u2014 Every operation logs its requestCharge for observability<\/li>\n<\/ul>\n<p><a href=\"https:\/\/github.com\/AzureCosmosDB\/cosmosdb-agent-kit\">Agent Kit Highlight:<\/a> With the Agent Kit installed, your AI coding assistant will automatically suggest these patterns as you write Azure Cosmos DB code.<\/p>\n<h2>Step 3: Define AI Tools with the Vercel AI SDK<\/h2>\n<p>The Vercel AI SDK&#8217;s <span style=\"font-family: terminal, monaco, monospace;\">tool()<\/span> abstraction lets you define typed, Zod-validated functions that the LLM can call. We expose four tools:<\/p>\n<table style=\"width: 100%; height: 115px;\" width=\"100%\">\n<thead>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"234\"><strong>Tool<\/strong><\/td>\n<td style=\"height: 23px;\" width=\"390\"><strong>Purpose<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"234\"><span style=\"font-family: terminal, monaco, monospace;\">queryProducts<\/span><\/td>\n<td style=\"height: 23px;\" width=\"390\">Filter by category, price range; returns rated results<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"234\"><span style=\"font-family: terminal, monaco, monospace;\">getProduct<\/span><\/td>\n<td style=\"height: 23px;\" width=\"390\">Point read for a specific product by ID + category<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"234\"><span style=\"font-family: terminal, monaco, monospace;\">getCatalogInsights<\/span><\/td>\n<td style=\"height: 23px;\" width=\"390\">Aggregations \u2014 avg price, inventory, counts by category<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"234\"><span style=\"font-family: terminal, monaco, monospace;\">searchCatalog<\/span><\/td>\n<td style=\"height: 23px;\" width=\"390\">Full-text search across names, descriptions, and tags<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The SDK handles schema generation, input validation, and multi-step orchestration automatically.<\/p>\n<h2>Step 4: The API Route \u2014 Streaming AI Responses<\/h2>\n<p>The API route <strong>wires<\/strong> everything together:<\/p>\n<ol>\n<li><span style=\"font-family: terminal, monaco, monospace;\">streamText()<\/span> sends the conversation to GPT-4.1 with our tool definitions<\/li>\n<li>When the model calls a tool (e.g., <span style=\"font-family: terminal, monaco, monospace;\">queryProducts<\/span>), the SDK automatically executes it and feeds results back<\/li>\n<li>stopWhen: <span style=\"font-family: terminal, monaco, monospace;\">stepCountIs(5)<\/span> allows multi-step reasoning \u2014 the AI can chain tool calls<\/li>\n<li>Results stream back to the client token-by-token via <span style=\"font-family: terminal, monaco, monospace;\">toUIMessageStreamResponse()<\/span><\/li>\n<\/ol>\n<h2>Step 5: The Chat UI<\/h2>\n<p>The frontend uses the AI SDK&#8217;s <span style=\"font-family: terminal, monaco, monospace;\">useChat()<\/span> hook for real-time streaming. It includes a welcome screen with suggested prompts and a polished dark-themed chat interface.<\/p>\n<h2>Step 6: Seed and Run<\/h2>\n<p>Seed sample product data into your Azure Cosmos DB, then start the dev server:<\/p>\n<pre class=\"prettyprint language-js\"><code class=\"language-js\">npx tsx scripts\/seed.tsnpm run dev<\/code><\/pre>\n<p>Open http:\/\/localhost:3000 and try these prompts:<\/p>\n<table style=\"width: 100%; height: 161px;\" width=\"100%\">\n<thead>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"307\"><strong>Prompt<\/strong><\/td>\n<td style=\"height: 23px;\" width=\"317\"><strong>What Happens<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"307\"><em>&#8220;Show me all surfboards&#8221;<\/em><\/td>\n<td style=\"height: 23px;\" width=\"317\">Calls <span style=\"font-family: terminal, monaco, monospace;\">queryProducts<\/span> with category filter<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"307\"><em>&#8220;What&#8217;s the cheapest item in outdoor gear?&#8221;<\/em><\/td>\n<td style=\"height: 23px;\" width=\"317\">Calls <span style=\"font-family: terminal, monaco, monospace;\">queryProducts<\/span> + filters by price<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"307\"><em>&#8220;Give me a catalog overview&#8221;<\/em><\/td>\n<td style=\"height: 23px;\" width=\"317\">Calls <span style=\"font-family: terminal, monaco, monospace;\">getCatalogInsights<\/span> for aggregations<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"307\"><em>&#8220;Find waterproof products&#8221;<\/em><\/td>\n<td style=\"height: 23px;\" width=\"317\">Calls <span style=\"font-family: terminal, monaco, monospace;\">searchCatalog<\/span> with keyword search<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"307\"><em>&#8220;Tell me about the StormShield tent&#8221;<\/em><\/td>\n<td style=\"height: 23px;\" width=\"317\">Calls <span style=\"font-family: terminal, monaco, monospace;\">getProduct<\/span> for a point read<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"height: 23px;\" width=\"307\"><em>&#8220;Compare surfboards and paddleboards under $500&#8221;<\/em><\/td>\n<td style=\"height: 23px;\" width=\"317\">Multi-step: calls <span style=\"font-family: terminal, monaco, monospace;\">queryProducts<\/span> twice and synthesizes<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>What the Azure Cosmos DB Agent Kit Does Behind the Scenes<\/h2>\n<p>With the Agent Kit installed (npx skills add AzureCosmosDB\/cosmosdb-agent-kit), your AI coding assistant automatically applies <strong>45+ best practices<\/strong> while you code. Here&#8217;s what it caught and guided during the development of this project:<\/p>\n<table width=\"100%\">\n<thead>\n<tr>\n<td width=\"275\"><strong>Rule<\/strong><\/td>\n<td width=\"349\"><strong>What It Taught Us<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td width=\"275\"><span style=\"font-family: terminal, monaco, monospace;\">sdk-singleton-client<\/span><\/td>\n<td width=\"349\">Create one CosmosClient and reuse it<\/td>\n<\/tr>\n<tr>\n<td width=\"275\"><span style=\"font-family: terminal, monaco, monospace;\">query-parameterize<\/span><\/td>\n<td width=\"349\">Never concatenate user input into queries<\/td>\n<\/tr>\n<tr>\n<td width=\"275\"><span style=\"font-family: terminal, monaco, monospace;\">query-use-projections<\/span><\/td>\n<td width=\"349\">SELECT only the fields you need<\/td>\n<\/tr>\n<tr>\n<td width=\"275\"><span style=\"font-family: terminal, monaco, monospace;\">query-avoid-cross-partition<\/span><\/td>\n<td width=\"349\">Use point reads when you have id + partition key<\/td>\n<\/tr>\n<tr>\n<td width=\"275\"><span style=\"font-family: terminal, monaco, monospace;\">monitoring-ru-consumption<\/span><\/td>\n<td width=\"349\">Log requestCharge from every operation<\/td>\n<\/tr>\n<tr>\n<td width=\"275\"><span style=\"font-family: terminal, monaco, monospace;\">sdk-retry-429<\/span><\/td>\n<td width=\"349\">Configure retry policies for rate limiting<\/td>\n<\/tr>\n<tr>\n<td width=\"275\"><span style=\"font-family: terminal, monaco, monospace;\">partition-high-cardinality<\/span><\/td>\n<td width=\"349\">Choose \/category for good distribution<\/td>\n<\/tr>\n<tr>\n<td width=\"275\"><span style=\"font-family: terminal, monaco, monospace;\">model-embed-related<\/span><\/td>\n<td width=\"349\">Embed tags inside the product document<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>The Agent Kit doesn&#8217;t just enforce rules \u2014 it teaches you patterns that scale.<\/strong><\/p>\n<h2>Deploy to Vercel<\/h2>\n<pre class=\"prettyprint language-js\"><code class=\"language-js\">npm i -g vercelvercel --prod<\/code><\/pre>\n<p>Set your environment variables in the Vercel dashboard and you&#8217;re live.<\/p>\n<h2>Learn Azure Cosmos DB Visually<\/h2>\n<p>Prefer learning through visuals? Check out the <a href=\"https:\/\/sajeetharan.github.io\/cosmos-graphic\/\">Azure Cosmos DB Visual Storybook\u00a0<\/a> an interactive collection of infographics covering everything from the basics to advanced AI integration. It&#8217;s a great companion to the agent-kit, helping you understand why the best practices exist before Copilot applies them to your code.<\/p>\n<h2><strong>Leave a Review<\/strong><\/h2>\n<p>Tell us about your Azure Cosmos DB experience! Leave a review on PeerSpot and get a $50 gift.\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/azure-cosmos-db-agent-kit-ai-coding-assistants\/\">Get started here<\/a>.<\/p>\n<h2><strong>About Azure Cosmos DB<\/strong><\/h2>\n<p>Azure Cosmos DB is a fully managed and serverless NoSQL and vector database for modern app development, including AI applications. With its SLA-backed speed and availability as well as instant dynamic scalability, it is ideal for real-time NoSQL and MongoDB applications that require high performance and distributed computing over massive volumes of NoSQL and vector data.<\/p>\n<p>To stay in the loop on Azure Cosmos DB updates, follow us on\u00a0<a href=\"https:\/\/twitter.com\/AzureCosmosDB\">X<\/a>,\u00a0<a href=\"https:\/\/aka.ms\/AzureCosmosDBYouTube\">YouTube<\/a>, and\u00a0<a href=\"https:\/\/www.linkedin.com\/company\/azure-cosmos-db\/\">LinkedIn<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Vercel AI SDK is an open-source TypeScript toolkit that provides the core building blocks for integrating AI into any JavaScript application. It works with 20+ AI providers out of the box\u2014including OpenAI, Azure OpenAI, Anthropic, Google, Mistral, and more\u2014so you can write your code once and switch providers by changing a single import. At [&hellip;]<\/p>\n","protected":false},"author":80443,"featured_media":11877,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1610,1980],"tags":[1986,1864,2001,1872,2000,1999],"class_list":["post-11876","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","category-azure-cosmos-db","tag-agentkit","tag-azurecosmosdb","tag-microsoftfoundry","tag-nosql","tag-sdk","tag-vercelai"],"acf":[],"blog_post_summary":"<p>The Vercel AI SDK is an open-source TypeScript toolkit that provides the core building blocks for integrating AI into any JavaScript application. It works with 20+ AI providers out of the box\u2014including OpenAI, Azure OpenAI, Anthropic, Google, Mistral, and more\u2014so you can write your code once and switch providers by changing a single import. At [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/11876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/users\/80443"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=11876"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/11876\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/11877"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=11876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=11876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=11876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}