{"id":216,"date":"2026-01-23T07:43:47","date_gmt":"2026-01-23T07:43:47","guid":{"rendered":"https:\/\/anubhavtiwari.dev\/blog\/?p=216"},"modified":"2026-01-23T07:43:47","modified_gmt":"2026-01-23T07:43:47","slug":"how-to-get-a-free-ai-api-key-step-by-step-guide-2026","status":"publish","type":"post","link":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/","title":{"rendered":"How to Get a Free AI API Key (Step-by-Step Guide 2026)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Looking to integrate AI in your project. But confused about how to find an api key and use it in your project. So let&#8217;s come directly to the point. If you are using it for learning or have less usage you can use <a href=\"https:\/\/openrouter.ai\/\">openrouter<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Just visit this link <a href=\"https:\/\/openrouter.ai\/\">https:\/\/openrouter.ai\/<\/a> and sign up for a free account.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once logged in now click on explore model.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"475\" src=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-4-1024x475.png\" alt=\"\" class=\"wp-image-222\" srcset=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-4-1024x475.png 1024w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-4-300x139.png 300w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-4-768x356.png 768w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-4-1536x712.png 1536w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-4.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here you will see a list of Models available. Then on the search bar search for free. You will get a list of free AI\u2019s you can use.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Select The Model-<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"990\" height=\"737\" src=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-2.png\" alt=\"\" class=\"wp-image-220\" srcset=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-2.png 990w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-2-300x223.png 300w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-2-768x572.png 768w\" sizes=\"auto, (max-width: 990px) 100vw, 990px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Select as per your requirement whether you want text based output or image based. For My project I used Meta: Llama 3.2 3B Instruct (free)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"507\" src=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-3-1024x507.png\" alt=\"\" class=\"wp-image-221\" srcset=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-3-1024x507.png 1024w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-3-300x148.png 300w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-3-768x380.png 768w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-3.png 1318w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">With this I have built a simple app for leads management. In this I have passed the user message to AI and give commands to identify the message and give the output of the message.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Like this if&nbsp; lead is spam or real. So with this I manage to automate some of my team members&#8217; tasks. To read each message and mark its status.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Get API keys<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s see how we can integrate it in our project. Once you selected the AI copy the name-<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>meta-llama\/llama-3.2-3b-instruct:free<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now to get API key, go to keys section from profile icon and Click on keys<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"281\" height=\"528\" src=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image.png\" alt=\"\" class=\"wp-image-218\" srcset=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image.png 281w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-160x300.png 160w\" sizes=\"auto, (max-width: 281px) 100vw, 281px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Click on Create API key button, here you will get the API key, save it for later use.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"190\" src=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-1-1024x190.png\" alt=\"\" class=\"wp-image-219\" srcset=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-1-1024x190.png 1024w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-1-300x56.png 300w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-1-768x142.png 768w, https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/image-1.png 1334w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now let\u2019s see the code, I have used PHP for it, you can use as per your requirement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1 Call &amp; Pass your API key here-<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">$classifier = new EnquiryClassifier(OPENROUTER_API_KEY);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$result = $classifier-&gt;classify(&#8220;I want a website for my business&#8221;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">var_dump($result);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\/*<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&#8220;type&#8221; =&gt; &#8220;real&#8221;,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&#8220;confidence&#8221; =&gt; 0.92<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">*\/<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2 Define Class and Build prompt<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;?php<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">class EnquiryClassifier<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">{<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;private string $apiKey;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;private string $model;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;private string $endpoint = &#8216;https:\/\/openrouter.ai\/api\/v1\/chat\/completions&#8217;;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;public function __construct(string $apiKey, string $model = &#8216;meta-llama\/llama-3.3-70b-instruct:free&#8217;)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;{<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!$apiKey) {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new InvalidArgumentException(&#8216;API key is required&#8217;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;apiKey = $apiKey;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;model&nbsp; = $model;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;public function classify(string $message): ?array<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;{<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$payload = [<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8216;model&#8217; =&gt; $this-&gt;model,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8216;messages&#8217; =&gt; [<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8216;role&#8217; =&gt; &#8216;user&#8217;,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8216;content&#8217; =&gt; $this-&gt;buildPrompt($message)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8216;temperature&#8217; =&gt; 0.0,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8216;max_tokens&#8217; =&gt; 200<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;];<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$response = $this-&gt;callApi($payload);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!$response) {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return null;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return json_decode($response, true);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Build Prompt here-<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;private function buildPrompt(string $message): string<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;{<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return &lt;&lt;&lt;PROMPT<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You are an assistant that classifies an enquiry message.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Return a JSON object ONLY (no explanation, no markdown) with this exact structure:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">{<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&#8220;type&#8221;: &#8220;real | spam | job | other&#8221;,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&#8220;confidence&#8221;: 0.0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Classification rules:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. type = &#8220;job&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the message is about job application, hiring, vacancy, career.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. type = &#8220;spam&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the message promotes unrelated services, includes suspicious links, crypto, gambling, or spammy phrases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. type = &#8220;real&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the message is a genuine business enquiry for products or services.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4. type = &#8220;other&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the message is unclear or not actionable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Message:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\\&#8221;\\&#8221;\\&#8221;$message\\&#8221;\\&#8221;\\&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PROMPT;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Call the API here<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;private function callApi(array $payload): ?string<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;{<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ch = curl_init($this-&gt;endpoint);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_setopt_array($ch, [<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CURLOPT_RETURNTRANSFER =&gt; true,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CURLOPT_POST =&gt; true,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CURLOPT_HTTPHEADER =&gt; [<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8216;Content-Type: application\/json&#8217;,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8216;Authorization: Bearer &#8216; . $this-&gt;apiKey<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CURLOPT_POSTFIELDS =&gt; json_encode($payload),<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CURLOPT_TIMEOUT =&gt; 20<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$response = curl_exec($ch);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curl_close($ch);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($response === false || $httpCode &lt; 200 || $httpCode &gt;= 300) {<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return null;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$json = json_decode($response, true);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $json[&#8216;choices&#8217;][0][&#8216;message&#8217;][&#8216;content&#8217;] ?? null;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Just pass your message here &#8211;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$result = $classifier-&gt;classify(&#8220;I want a website for my business&#8221;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And you will get the response. So with these simple steps you can integrate AI in your project.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Looking to integrate AI in your project. But confused about how to find an api key and use it in your project. So let&#8217;s come directly to the point. If you are using it for learning or have less usage you can use openrouter. Just visit this link https:\/\/openrouter.ai\/ and sign up for a free [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":217,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-216","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Get a Free AI API Key (Step-by-Step Guide 2026) - Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Get a Free AI API Key (Step-by-Step Guide 2026) - Blog\" \/>\n<meta property=\"og:description\" content=\"Looking to integrate AI in your project. But confused about how to find an api key and use it in your project. So let&#8217;s come directly to the point. If you are using it for learning or have less usage you can use openrouter. Just visit this link https:\/\/openrouter.ai\/ and sign up for a free [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-23T07:43:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/how-to-get-free-ai-api-key.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Anubhav Tiwari\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anubhav Tiwari\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/\"},\"author\":{\"name\":\"Anubhav Tiwari\",\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/#\\\/schema\\\/person\\\/e427973c306e35da9874678360b9226f\"},\"headline\":\"How to Get a Free AI API Key (Step-by-Step Guide 2026)\",\"datePublished\":\"2026-01-23T07:43:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/\"},\"wordCount\":1134,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/01\\\/how-to-get-free-ai-api-key.webp\",\"articleSection\":[\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/\",\"url\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/\",\"name\":\"How to Get a Free AI API Key (Step-by-Step Guide 2026) - Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/01\\\/how-to-get-free-ai-api-key.webp\",\"datePublished\":\"2026-01-23T07:43:47+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/#\\\/schema\\\/person\\\/e427973c306e35da9874678360b9226f\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/#primaryimage\",\"url\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/01\\\/how-to-get-free-ai-api-key.webp\",\"contentUrl\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/01\\\/how-to-get-free-ai-api-key.webp\",\"width\":1200,\"height\":628,\"caption\":\"How to Get a Free AI API Key (Step-by-Step Guide 2026)\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Get a Free AI API Key (Step-by-Step Guide 2026)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/\",\"name\":\"Blog\",\"description\":\"Anubhav Tiwari\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/#\\\/schema\\\/person\\\/e427973c306e35da9874678360b9226f\",\"name\":\"Anubhav Tiwari\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/95c45b41431f9c91f7ec9ce2a116c0792b799b9e2139e485da90043f0c219450?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/95c45b41431f9c91f7ec9ce2a116c0792b799b9e2139e485da90043f0c219450?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/95c45b41431f9c91f7ec9ce2a116c0792b799b9e2139e485da90043f0c219450?s=96&d=mm&r=g\",\"caption\":\"Anubhav Tiwari\"},\"sameAs\":[\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\"],\"url\":\"https:\\\/\\\/anubhavtiwari.dev\\\/blog\\\/author\\\/anubhavtiwari-at72gmail-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Get a Free AI API Key (Step-by-Step Guide 2026) - Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/","og_locale":"en_US","og_type":"article","og_title":"How to Get a Free AI API Key (Step-by-Step Guide 2026) - Blog","og_description":"Looking to integrate AI in your project. But confused about how to find an api key and use it in your project. So let&#8217;s come directly to the point. If you are using it for learning or have less usage you can use openrouter. Just visit this link https:\/\/openrouter.ai\/ and sign up for a free [&hellip;]","og_url":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/","og_site_name":"Blog","article_published_time":"2026-01-23T07:43:47+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/how-to-get-free-ai-api-key.webp","type":"image\/webp"}],"author":"Anubhav Tiwari","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Anubhav Tiwari","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/#article","isPartOf":{"@id":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/"},"author":{"name":"Anubhav Tiwari","@id":"https:\/\/anubhavtiwari.dev\/blog\/#\/schema\/person\/e427973c306e35da9874678360b9226f"},"headline":"How to Get a Free AI API Key (Step-by-Step Guide 2026)","datePublished":"2026-01-23T07:43:47+00:00","mainEntityOfPage":{"@id":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/"},"wordCount":1134,"commentCount":0,"image":{"@id":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/#primaryimage"},"thumbnailUrl":"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/how-to-get-free-ai-api-key.webp","articleSection":["Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/","url":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/","name":"How to Get a Free AI API Key (Step-by-Step Guide 2026) - Blog","isPartOf":{"@id":"https:\/\/anubhavtiwari.dev\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/#primaryimage"},"image":{"@id":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/#primaryimage"},"thumbnailUrl":"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/how-to-get-free-ai-api-key.webp","datePublished":"2026-01-23T07:43:47+00:00","author":{"@id":"https:\/\/anubhavtiwari.dev\/blog\/#\/schema\/person\/e427973c306e35da9874678360b9226f"},"breadcrumb":{"@id":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/#primaryimage","url":"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/how-to-get-free-ai-api-key.webp","contentUrl":"https:\/\/anubhavtiwari.dev\/blog\/wp-content\/uploads\/2026\/01\/how-to-get-free-ai-api-key.webp","width":1200,"height":628,"caption":"How to Get a Free AI API Key (Step-by-Step Guide 2026)"},{"@type":"BreadcrumbList","@id":"https:\/\/anubhavtiwari.dev\/blog\/how-to-get-a-free-ai-api-key-step-by-step-guide-2026\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/anubhavtiwari.dev\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Get a Free AI API Key (Step-by-Step Guide 2026)"}]},{"@type":"WebSite","@id":"https:\/\/anubhavtiwari.dev\/blog\/#website","url":"https:\/\/anubhavtiwari.dev\/blog\/","name":"Blog","description":"Anubhav Tiwari","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/anubhavtiwari.dev\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/anubhavtiwari.dev\/blog\/#\/schema\/person\/e427973c306e35da9874678360b9226f","name":"Anubhav Tiwari","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/95c45b41431f9c91f7ec9ce2a116c0792b799b9e2139e485da90043f0c219450?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/95c45b41431f9c91f7ec9ce2a116c0792b799b9e2139e485da90043f0c219450?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/95c45b41431f9c91f7ec9ce2a116c0792b799b9e2139e485da90043f0c219450?s=96&d=mm&r=g","caption":"Anubhav Tiwari"},"sameAs":["https:\/\/anubhavtiwari.dev\/blog"],"url":"https:\/\/anubhavtiwari.dev\/blog\/author\/anubhavtiwari-at72gmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/posts\/216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/comments?post=216"}],"version-history":[{"count":1,"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/posts\/216\/revisions"}],"predecessor-version":[{"id":223,"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/posts\/216\/revisions\/223"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/media\/217"}],"wp:attachment":[{"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/media?parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/categories?post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anubhavtiwari.dev\/blog\/wp-json\/wp\/v2\/tags?post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}