{"id":53348,"date":"2024-08-27T13:05:00","date_gmt":"2024-08-27T20:05:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=53348"},"modified":"2024-08-29T13:54:13","modified_gmt":"2024-08-29T20:54:13","slug":"introducing-pinecone-dotnet-sdk","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/introducing-pinecone-dotnet-sdk\/","title":{"rendered":"Introducing the Pinecone .NET SDK"},"content":{"rendered":"<p>The AI ecosystem in .NET is constantly growing. Today, we&#8217;re excited to announce the newest member of the community: Pinecone.<\/p>\n<p>In this post, we introduce the Pinecone .NET SDK and show how you can quickly get started building AI applications with it.<\/p>\n<h2>What is Pinecone?<\/h2>\n<p>Pinecone is a robust vector database designed to efficiently handle and query large-scale vector data. With Pinecone, engineers and data scientists can effortlessly build vector-based AI applications that require efficient similarity search and ranking.<\/p>\n<p>To learn more about Pinecone, visit their <a href=\"https:\/\/www.pinecone.io\/\">website<\/a>.  <\/p>\n<h2>What is a vector database?<\/h2>\n<p>Building AI applications requires efficient vector data processing.  <\/p>\n<p>A vector database indexes and stores embedding vectors for fast retrieval and similarity search.<\/p>\n<p>Embeddings are numerical representations of data such as text, images, and audio. They capture semantic meaning and relationships, making them essential in AI applications.<\/p>\n<p>Due to the complexity of vector embeddings, you need a database designed specifically for handling this data type.<\/p>\n<p>To learn more, see the <a href=\"https:\/\/learn.microsoft.com\/dotnet\/ai\/conceptual\/embeddings\">Embeddings in .NET<\/a> and <a href=\"https:\/\/learn.microsoft.com\/dotnet\/ai\/conceptual\/vector-databases\">Vector Databases for .NET<\/a> documentation.<\/p>\n<h2>Get started with the Pinecone .NET SDK<\/h2>\n<p>Getting started with Pinecone in .NET is easy:<\/p>\n<ol>\n<li>Set up your Pinecone account and database, if you haven\u2019t already, and create an API key. For more details, see the <a href=\"https:\/\/docs.pinecone.io\/guides\/get-started\/quickstart\">documentation<\/a>.<\/li>\n<li>Download the <a href=\"https:\/\/aka.ms\/pinecone-dotnet-sdk\">Pinecone .NET SDK<\/a> from NuGet.<\/li>\n<li>\n<p>After downloading the SDK, connect the .NET client to your Pinecone database:<\/p>\n<pre><code class=\"language-csharp\">using Pinecone;\n\nvar pinecone = new PineconeClient(\"PINECONE_API_KEY\");<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2>Create an index<\/h2>\n<p>An index is the high-level structure that stores vector data in Pinecone.<\/p>\n<p>An index serves queries over vectors it contains; and does other vector operations over its contents. For more details, wee the <a href=\"https:\/\/docs.pinecone.io\/guides\/indexes\/understanding-indexes\">Pinecone index documentation<\/a>.  <\/p>\n<pre><code class=\"language-csharp\">var createIndexResponse = await pinecone.CreateIndexAsync(new CreateIndexRequest\n {\n    Name = indexName,\n    Dimension = 3,\n    Metric = CreateIndexRequestMetric.Cosine,\n    Spec = new ServerlessIndexSpec\n    {\n    Serverless = new ServerlessSpec\n    {\n        Cloud = ServerlessSpecCloud.Azure,\n        Region = \"eastus2\"\n    }\n    }\n });<\/code><\/pre>\n<h2>Add records<\/h2>\n<p>To start adding records your data store:<\/p>\n<pre><code class=\"language-csharp\">var index = pinecone.Index(indexName);\n\nvar upsertResponse = await index.UpsertAsync(new UpsertRequest {\n    Vectors = new[]\n    {\n        new Vector\n        {\n            Id = \"v1\",\n            Values = new[] { 0.1f, 0.2f, 0.3f }\n        },\n        new Vector\n        {\n            Id = \"v2\",\n            Values = new[] { 0.4f, 0.5f, 0.6f }\n        },\n        new Vector\n        {\n            Id = \"v3\",\n            Values = new[] { 0.7f, 0.8f, 0.9f }\n        }\n    }\n });\n\nawait Task.Delay(10000);<\/code><\/pre>\n<h2>Query records<\/h2>\n<p>Once you have records in your data store, you can query them:<\/p>\n<pre><code class=\"language-csharp\">var queryResponse = await index.QueryAsync(\n   new QueryRequest\n   {\n       Id = \"v1\",\n       TopK = 1,\n       IncludeValues = true,\n   });<\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>We can&#8217;t wait to see what you build. Try out the <a href=\"https:\/\/aka.ms\/pinecone-dotnet-sdk\">Pinecone .NET SDK<\/a> and give us feedback!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Get started building AI applications in .NET using the Pinecone Vector DB and the Pinecone .NET SDK.<\/p>\n","protected":false},"author":26108,"featured_media":53393,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685,7781],"tags":[568,7864,7806],"class_list":["post-53348","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-ai","tag-ai","tag-pinecone","tag-vectordb"],"acf":[],"blog_post_summary":"<p>Get started building AI applications in .NET using the Pinecone Vector DB and the Pinecone .NET SDK.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/53348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/26108"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=53348"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/53348\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/53393"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=53348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=53348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=53348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}