{"id":2601,"date":"2024-05-03T14:51:57","date_gmt":"2024-05-03T21:51:57","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=2601"},"modified":"2024-05-06T08:09:20","modified_gmt":"2024-05-06T15:09:20","slug":"generating-api-manifests-for-semantic-kernel","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/generating-api-manifests-for-semantic-kernel\/","title":{"rendered":"Generating API Manifests for Semantic Kernel"},"content":{"rendered":"<p><span data-contrast=\"auto\">Hi everyone!<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p>Today we\u2019re featuring a guest author from another team in Microsoft on our Semantic Kernel blog. Today&#8217;s topic will cover how to utilize API&#8217;s manifests. An <a href=\"https:\/\/github.com\/microsoft\/openapi.apimanifest\">API manifest<\/a> is a way to store the dependencies that an application has on HTTP APIs. It contains characteristics of those dependencies including links to API descriptions, specifics of the types of HTTP API requests made by the application and related authorization information. We will turn it over to Vincent Biret to dive into Generating API Manifests for Semantic Kernel in a follow up from the blog on <a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/introducing-api-manifest-plugins-for-semantic-kernel-2\/\">Introducing API Manifest Plugins for Semantic Kernel.<\/a><\/p>\n<p><span data-contrast=\"auto\">In <\/span><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/introducing-api-manifest-plugins-for-semantic-kernel-2\/\"><span data-contrast=\"none\">our last blog post<\/span><\/a><span data-contrast=\"auto\">, we detailed how you can use semantic kernel and API manifests to build intelligent agents thanks to sematic kernel and a little bit of code.<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><span data-contrast=\"auto\">However, building API manifests by hand can be time consuming and cumbersome, it also requires you to have basic level of the OpenAPI specification.<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><span data-contrast=\"auto\">In this blog post, we\u2019ll show you how you can use preview features of <\/span><a href=\"https:\/\/aka.ms\/kiota\"><span data-contrast=\"none\">Kiota<\/span><\/a><span data-contrast=\"auto\">, your modern API consumption army knife, to generate semantic kernel API manifests for you.<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p aria-level=\"1\"><strong>Getting the Tools\u00a0<\/strong><\/p>\n<p><span data-contrast=\"auto\">The only tool you\u2019ll need is kiota, there are multiple <\/span><a href=\"https:\/\/aka.ms\/get\/kiota\"><span data-contrast=\"none\">ways to install kiota<\/span><\/a><span data-contrast=\"auto\"> on your machine, just make sure you have v1.14.0 or above installed to get the plugins generation capabilities.<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><span data-contrast=\"auto\">If you have dotnet installed, the simplest way to get kiota is by running<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">dotnet tool install -g Microsoft.OpenApi.Kiota\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Once you have installed kiota, open a terminal, the plugins generation features are hidden behind a feature flag.<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">If you\u2019re running in PowerShell run the following command:<\/span><\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">$Env:KIOTA_CONFIG_PREVIEW = $true <\/code><\/pre>\n<p>In Bash, run the following command line:<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">KIOTA_CONFIG_PREVIEW=\"true\"<\/code><\/pre>\n<p>In Windows, run the following command line:<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">set KIOTA_CONFIG_PREVIEW=true<\/code><\/pre>\n<p><strong>Generating Semantic Kernel Plugins Manifests<\/strong><\/p>\n<p>Now that you have all the tools you need, let\u2019s generate manifests. We\u2019ll generate manifests for the same APIs that were used in the previous blog post: GitHub and Microsoft Graph.<\/p>\n<p><strong>Finding the Description<\/strong><\/p>\n<p>The first hurdle you might face while building manifests is the need for an OpenAPI description for the API you want to integrate into semantic kernel. Finding such descriptions can be difficult and time consuming, but thankfully kiota offers a search command.\nLet\u2019s start by finding the description for GitHub\u2019s API<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">kiota search github<\/code><\/pre>\n<p>Which will return:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/05\/GeneratingAPIManifests.png\"><img decoding=\"async\" class=\"alignnone wp-image-2609 size-full\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/05\/GeneratingAPIManifests.png\" alt=\"Image GeneratingAPIManifests\" width=\"624\" height=\"282\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/05\/GeneratingAPIManifests.png 624w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2024\/05\/GeneratingAPIManifests-300x136.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p>Let\u2019s take apisguru::github.com:api.github.com and run:<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">kiota search apisguru::github.com:api.github.com<\/code><\/pre>\n<p>This will give us the following URL for the description, which we can write down, as we\u2019ll need it for later.\n<a href=\"https:\/\/raw.githubusercontent.com\/APIs-guru\/openapi-directory\/gh-pages\/v2\/specs\/github.com\/api.github.com\/1.1.4\/openapi.json\">https:\/\/raw.githubusercontent.com\/APIs-guru\/openapi-directory\/gh-pages\/v2\/specs\/github.com\/api.github.com\/1.1.4\/openapi.json<\/a><\/p>\n<p><strong>Finding the Operation<\/strong><\/p>\n<p>Now that we found the description, let\u2019s try to get the operation that\u2019d allow us to generate markdown. Kiota allows us to easily explore a description through its show command.\nRunning the following command will display the API tree with the matching API paths<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">kiota show -k apisguru::github.com:api.github.com -i **\/markdown<\/code><\/pre>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/05\/Picture4.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-2608\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2024\/05\/Picture4.png\" alt=\"Image Picture4\" width=\"136\" height=\"50\" \/><\/a><\/p>\n<p><strong>Generating the plugin<\/strong><\/p>\n<p>Now that we have identified the description and found the right API operation, we\u2019re ready to generate a plugin for sematic kernel.\nThe following command<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">kiota plugin add -d https:\/\/raw.githubusercontent.com\/APIs-guru\/openapi-directory\/gh-pages\/v2\/specs\/github.com\/api.github.com\/1.1.4\/openapi.json -i **\/markdown --pn github --type apimanifest -o .\/github<\/code><\/pre>\n<p>Will generate the plugin manifest for GitHub<\/p>\n<p><strong>Generating a manifest for Microsoft Graph<\/strong><\/p>\n<p>Now that we understand the basics of kiota, let\u2019s fast track through the generation of an API manifest for Microsoft Graph.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">kiota search \"microsoft graph\"\r\nkiota search github::microsoftgraph\/msgraph-metadata\/graph.microsoft.com\/v1.0\r\n# gives us https:\/\/raw.githubusercontent.com\/microsoftgraph\/msgraph-metadata\/master\/openapi\/v1.0\/openapi.yaml\r\nkiota show -k github::microsoftgraph\/msgraph-metadata\/graph.microsoft.com\/v1.0 -i \/me\/messages#GET\r\nkiota plugin add -d https:\/\/raw.githubusercontent.com\/microsoftgraph\/msgraph-metadata\/master\/openapi\/v1.0\/openapi.yaml -i \/me\/messages#GET --pn \"microsoft.graph\" --type apimanifest -o .\/graph<\/code><\/pre>\n<p><strong>Results<\/strong><\/p>\n<p>Thanks to kiota plugin manifests generation capabilities, you\u2019ll find a graph and a github directory each containing:<\/p>\n<ul>\n<li>A json api manifest file<\/li>\n<li>A sliced API description containing only the selected operations<\/li>\n<\/ul>\n<p>Example with GitHub<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">{\r\n  \"applicationName\": \"application\",\r\n  \"apiDependencies\": {\r\n    \"github\": {\r\n      \"apiDescriptionUrl\": \"https:\/\/raw.githubusercontent.com\/APIs-guru\/openapi-directory\/gh-pages\/v2\/specs\/github.com\/api.github.com\/1.1.4\/openapi.json\",\r\n      \"apiDeploymentBaseUrl\": \"https:\/\/api.github.com\/\",\r\n      \"requests\": [\r\n        {\r\n          \"method\": \"POST\",\r\n          \"uriTemplate\": \"markdown\"\r\n        }\r\n      ]\r\n    }\r\n  }\r\n}<\/code><\/pre>\n<p>Both files can be fed to semantic kernel in order to build intelligent agents capable of orchestrating multiple API calls.<\/p>\n<p><strong>Future Plans<\/strong><\/p>\n<p>Thank you for trying kiota to generate semantic kernel API manifests. Don\u2019t hesitate to reach out if you have any feedback about the latest preview features. We\u2019re working to add other plugin manifests type generation support in kiota. We\u2019re also working to update kiota\u2019s <a href=\"https:\/\/aka.ms\/kiota\/extension\">Visual Studio Code extension<\/a> so you can get a rich Graphical User Interface (GUI) to build your manifests. Thanks for reading and stay tuned!<\/p>\n<p>From the Semantic Kernel team, we want to thank Vincent for his time. We\u2019re always interested in hearing from you. If you have feedback, questions or want to discuss further, feel free to reach out to us and the community on the <a href=\"https:\/\/github.com\/microsoft\/semantic-kernel\/discussions\/categories\/general\">Semantic Kernel GitHub Discussion Channel<\/a>! We would also love your support, if you\u2019ve enjoyed using Semantic Kernel, give us a star on\u00a0<a href=\"https:\/\/github.com\/microsoft\/semantic-kernel\">GitHub<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi everyone!\u00a0 Today we\u2019re featuring a guest author from another team in Microsoft on our Semantic Kernel blog. Today&#8217;s topic will cover how to utilize API&#8217;s manifests. An API manifest is a way to store the dependencies that an application has on HTTP APIs. It contains characteristics of those dependencies including links to API descriptions, [&hellip;]<\/p>\n","protected":false},"author":149071,"featured_media":2302,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[48,69,70,63,9],"class_list":["post-2601","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-semantic-kernel","tag-ai","tag-api","tag-api-manifest-plugin","tag-microsoft-semantic-kernel","tag-semantic-kernel"],"acf":[],"blog_post_summary":"<p>Hi everyone!\u00a0 Today we\u2019re featuring a guest author from another team in Microsoft on our Semantic Kernel blog. Today&#8217;s topic will cover how to utilize API&#8217;s manifests. An API manifest is a way to store the dependencies that an application has on HTTP APIs. It contains characteristics of those dependencies including links to API descriptions, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/2601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/149071"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=2601"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/2601\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/2302"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=2601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=2601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=2601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}