<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Oluwole Adebiyi</title>
    <description>The latest articles on DEV Community by Oluwole Adebiyi (@mrflamez_).</description>
    <link>https://dev.to/mrflamez_</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F28075%2F366c7825-2def-4e08-af0d-bd563ed931b2.png</url>
      <title>DEV Community: Oluwole Adebiyi</title>
      <link>https://dev.to/mrflamez_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mrflamez_"/>
    <language>en</language>
    <item>
      <title>Why Communication Isn’t Just a Skill—It’s a Product Manager’s Superpower 🚀💬</title>
      <dc:creator>Oluwole Adebiyi</dc:creator>
      <pubDate>Sun, 26 Jan 2025 22:44:30 +0000</pubDate>
      <link>https://dev.to/mrflamez_/why-communication-isnt-just-a-skill-its-a-product-managers-superpower-3cmj</link>
      <guid>https://dev.to/mrflamez_/why-communication-isnt-just-a-skill-its-a-product-managers-superpower-3cmj</guid>
      <description>&lt;p&gt;In the dynamic world of product management, technical skills and strategic thinking are undeniably important. However, one often-overlooked trait distinguishes outstanding Product Managers (PMs) from the rest: exceptional communication. At &lt;a href="https://www.ft.com/content/a1bc5d2e-046e-499b-b27e-4d057f9d8477" rel="noopener noreferrer"&gt;Moniepoint&lt;/a&gt;, one of the core values is &lt;strong&gt;Candour&lt;/strong&gt;, a principle that I have embraced wholeheartedly. Effective communication isn’t just a skill—it’s the secret weapon that can propel a PM from good to great.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Power of Overcommunication&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Overcommunication might sound excessive, but in the realm of product management, it is essential. Clear, consistent communication ensures that everyone—from engineers and designers to executives and stakeholders—is aligned and informed. As Steve Jobs once said, &lt;em&gt;“Great things in business are never done by one person. They’re done by a team of people.”&lt;/em&gt; This underscores the importance of keeping every team member in the loop to foster collaboration and drive success.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Learning from “Disaster Holiday”&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;A vivid illustration of the consequences of poor communication can be seen in the movie &lt;a href="https://www.netflix.com/title/81522482" rel="noopener noreferrer"&gt;&lt;strong&gt;Disaster Holiday&lt;/strong&gt;&lt;/a&gt;. The protagonist, battling for custody of his children, struggles because he fails to communicate effectively with his family. His reluctance to share burdens leads to misunderstandings and the eventual unraveling of relationships. Similarly, in a professional setting, withholding information or failing to communicate can lead to project delays, lost trust, and missed opportunities.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Candour: Embracing Transparency&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Candour&lt;/strong&gt; is more than a value—it’s a practice that I integrate into my daily workflow. Transparency builds trust, fosters accountability, and ensures that everyone understands the "why" behind decisions. For example, when a team member struggles to meet their responsibilities, addressing the issue openly rather than covering it up prevents bigger problems down the line.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Real-World Example: Managing Deadlines and Team Changes&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Imagine you’ve committed to delivering a critical feature by Q4. At the beginning of Q3, your mobile engineer and designer resigned unexpectedly. Here’s how overcommunication can make a difference:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Immediate Transparency:&lt;/strong&gt; Inform your manager immediately about the staffing changes. Explain the impact on the project timeline and discuss potential solutions, such as hiring replacements or reallocating resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Documenting Challenges:&lt;/strong&gt; Clearly document the reasons for delays and share them with your team and stakeholders. This proactive approach prevents misunderstandings and demonstrates your commitment to resolving issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Continuous Updates:&lt;/strong&gt; Keep all relevant parties updated on the progress of finding replacements and any adjustments to the project scope or deadlines. This ongoing dialogue ensures that everyone remains informed and can adjust their expectations accordingly.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By communicating these changes promptly, you maintain trust and demonstrate your capability to handle setbacks effectively. Conversely, failing to communicate these issues can lead to assumptions of incompetence and damage your professional reputation.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Building a Collaborative Team Environment&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Effective communication extends beyond interactions with management. It’s equally important to engage with your team members, ensuring they understand the purpose behind their tasks and feel involved in the project’s success. As Sundar Pichai, CEO of Alphabet, aptly puts it, &lt;em&gt;“A person who is happy is not because everything is right in his life, he is happy because his attitude towards everything in his life is right.”&lt;/em&gt; By fostering a positive and transparent communication culture, you can enhance your team’s morale and productivity.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Engaging Your Team&lt;/strong&gt;
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Explain the "Why":&lt;/strong&gt; When introducing a new feature or change, clearly articulate why it’s necessary. Understanding the bigger picture motivates team members and fosters a sense of ownership.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Encourage Feedback:&lt;/strong&gt; Create an environment where team members feel comfortable sharing their ideas and concerns. This collaborative approach can lead to innovative solutions and strengthen team cohesion.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adapt and Inform:&lt;/strong&gt; If project requirements change, communicate the reasons behind these changes promptly. This ensures that the team can adapt quickly and maintain momentum.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Leveraging Communication to Navigate Challenges&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Communication is not just about sharing information—it’s about effectively navigating challenges and finding solutions collaboratively. When issues arise, such as resource constraints or shifting priorities, clear communication helps in devising strategies to overcome these obstacles.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Example: Adapting to Resource Constraints&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Suppose you’re tasked with launching a new feature, but halfway through the project, budget cuts necessitate reducing the scope. Here’s how communication plays a pivotal role:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Assess and Inform:&lt;/strong&gt; Evaluate which aspects of the feature are essential and which can be scaled back. Communicate these findings to stakeholders, providing a clear rationale for the adjustments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collaborative Decision-Making:&lt;/strong&gt; Involve your team in brainstorming alternative solutions or identifying areas where efficiency can be improved. This collaborative effort ensures that everyone is invested in the revised plan.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Maintain Transparency:&lt;/strong&gt; Keep all parties informed about the progress and any further changes. This ongoing communication prevents surprises and maintains trust.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Conclusion: Communication as Your Secret Weapon&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In product management, communication is more than a tool—it’s a strategic advantage. By embracing overcommunication, fostering transparency, and engaging collaboratively with your team, you can navigate challenges, build trust, and drive your projects to success. At Moniepoint, living our core value of &lt;strong&gt;Candour&lt;/strong&gt; has not only enhanced our internal processes but also strengthened our relationships with stakeholders and customers.&lt;/p&gt;

&lt;p&gt;Embrace communication as your secret weapon, and watch as it transforms your effectiveness as a Product Manager.&lt;/p&gt;

&lt;p&gt;By investing in your communication skills, you’re not just improving as a Product Manager—you’re equipping yourself with a powerful tool to drive meaningful impact and achieve sustained success.&lt;/p&gt;

</description>
      <category>productmanagement</category>
      <category>leadership</category>
      <category>transparency</category>
      <category>communication</category>
    </item>
    <item>
      <title>Building Your First AI CLI Tool Using OpenAI’s API</title>
      <dc:creator>Oluwole Adebiyi</dc:creator>
      <pubDate>Mon, 16 Dec 2024 06:45:32 +0000</pubDate>
      <link>https://dev.to/mrflamez_/building-your-first-ai-cli-tool-using-openais-api-1d4a</link>
      <guid>https://dev.to/mrflamez_/building-your-first-ai-cli-tool-using-openais-api-1d4a</guid>
      <description>&lt;p&gt;In this tutorial, you’ll walk through creating your first AI-powered Command Line Interface (CLI) tool using OpenAI’s API. You’ll build a tool named Text Summarizer CLI, which takes some text and returns a concise summary. Although this guide focuses on text summarization, the same approach can be applied to a wide range of AI-driven tasks—such as translation, sentiment analysis, code generation, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why build a CLI AI tool?&lt;/strong&gt; Because it streamlines workflows, automates repetitive tasks, and provides simple terminal-based access to advanced capabilities—allowing you to seamlessly integrate AI into your development process or everyday workflows.&lt;/p&gt;

&lt;p&gt;This knowledge will also help you apply OpenAI to any other tool eg an idea for a mobile app&lt;/p&gt;

&lt;h2&gt;
  
  
  What You Will Learn
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How to set up a Node.js project&lt;/li&gt;
&lt;li&gt;How to configure your CLI tool to work with OpenAI’s API&lt;/li&gt;
&lt;li&gt;How to securely store and manage your API key locally&lt;/li&gt;
&lt;li&gt;How to interact with the OpenAI API using HTTP requests&lt;/li&gt;
&lt;li&gt;How to implement a user-friendly CLI interface&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end, you’ll have a working CLI tool that you can run from your terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Node.js and npm:&lt;/strong&gt; Make sure you have Node.js installed. Check by running:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
npm &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If not installed, visit &lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;https://nodejs.org&lt;/a&gt; and follow the instructions to install the stable version, LTS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyk60j5ics2lptcbva3j9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyk60j5ics2lptcbva3j9.png" alt="Open AI API Key page" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Keep this API key private. You will provide it to your CLI tool once, and it will store it locally on your machine for future use.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;p&gt;Let’s create a new project for our CLI tool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;ai-cli-tool
&lt;span class="nb"&gt;cd &lt;/span&gt;ai-cli-tool
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a &lt;code&gt;package.json&lt;/code&gt; file with default settings.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Dependencies
&lt;/h3&gt;

&lt;p&gt;We’ll need a few packages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;axios: For making HTTP requests to the OpenAI API.&lt;/li&gt;
&lt;li&gt;commander: For handling CLI commands and arguments.&lt;/li&gt;
&lt;li&gt;fs and os: Core Node.js modules for file system operations and user directory handling (no need to install, they come with Node.js).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Install the external dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;axios commander
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcfzns4vb4l169n6q5lfc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcfzns4vb4l169n6q5lfc.png" alt="Installed successfully" width="744" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Storing the API Key Securely
&lt;/h3&gt;

&lt;p&gt;Instead of using environment variables, we’ll store the API key in a configuration file located in the user’s home directory. The configuration file approach allows portability without requiring environment variable setup for every terminal session. However, you should ensure that .ai-cli-tool-config.json is not shared publicly or included in version control systems to protect your API key. This way, you don’t have to rely on a .env file, and the key remains local and private.&lt;/p&gt;

&lt;h4&gt;
  
  
  Our approach:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;When the user first sets their API key using a CLI command (e.g., &lt;code&gt;ai-cli-tool set-key &amp;lt;your-api-key&amp;gt;&lt;/code&gt;), you’ll store it in a file &lt;code&gt;~/.ai-cli-tool-config.json&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Each time the tool runs, it will read from this file to retrieve the saved key.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Implementing the CLI Tool
&lt;/h2&gt;

&lt;p&gt;Create a file named &lt;code&gt;index.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following code in &lt;code&gt;index.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cp"&gt;
#!/usr/bin/env node
&lt;/span&gt;
&lt;span class="c1"&gt;// The line at the top is a shebang.  It tells the operating system which interpreter to use to execute the file. This is especially useful for scripts that need to be run as standalone executable programs.&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Command&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;commander&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;axios&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;axios&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;os&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;os&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;program&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Command&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Path to the config file in the user's home directory&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;configPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;homedir&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.ai-cli-tool-config.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Load the API key from the config file (if it exists)&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;loadApiKey&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;configPath&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;configData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;configPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf-8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;configData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Save the API key to the config file&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;saveApiKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;configData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;configPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;configData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf-8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Command to set the API key&lt;/span&gt;
&lt;span class="nx"&gt;program&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;command&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;set-key &amp;lt;key&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;description&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Set your OpenAI API key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;action&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;saveApiKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;API key has been saved successfully!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Command to summarize text&lt;/span&gt;
&lt;span class="nx"&gt;program&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;command&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;summarize &amp;lt;text&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;description&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Summarize the provided text using OpenAI&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;action&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;summary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;summarizeText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="s1"&gt;Summary:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error from OpenAI API:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;summarizeText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inputText&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;loadApiKey&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;API key not set. Run `ai-cli-tool set-key &amp;lt;your-api-key&amp;gt;` first.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.openai.com/v1/chat/completions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gpt-4o-mini&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Model used for completion&lt;/span&gt;
  &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;system&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;You are a helpful assistant that summarizes text, make it very easy to understand and make it concise.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Please summarize the following text: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;inputText&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;temperature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.7&lt;/span&gt; &lt;span class="c1"&gt;// Controls creativity; lower values are more deterministic&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Authorization&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Bearer &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;axios&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;apiUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;headers&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;program&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What’s Happening Here?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Storing the API Key: We created two helper functions, &lt;code&gt;loadApiKey()&lt;/code&gt; and &lt;code&gt;saveApiKey()&lt;/code&gt;, to read and write the API key from a JSON file in the user’s home directory.&lt;/li&gt;
&lt;li&gt;Setting the API Key: The &lt;code&gt;set-key&lt;/code&gt; command allows the user to input their API key once. The tool saves it locally, so you don’t need to pass the key every time.&lt;/li&gt;
&lt;li&gt;Summarize Command: The &lt;code&gt;summarize&lt;/code&gt; command sends the user’s input to the OpenAI API and returns a summary. It reads the previously stored API key so you don’t have to repeat it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Making the Tool Executable
&lt;/h2&gt;

&lt;p&gt;Update your &lt;code&gt;package.json&lt;/code&gt; to include a &lt;code&gt;bin&lt;/code&gt; field:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ai-cli-tool"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"bin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ai-cli-tool"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./index.js"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"axios"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"commander"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^9.0.0"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, link the package so you can run &lt;code&gt;ai-cli-tool&lt;/code&gt; from your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;link&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using the CLI Tool
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Remember the API key you got from OpenAI; use this command to set the API Key (once per machine or whenever you need to update it):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ai-cli-tool set-key YOUR_OPENAI_API_KEY
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Summarize Some Text:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ai-cli-tool summarize &lt;span class="s2"&gt;"In recent years, the global economy has experienced significant fluctuations, driven by a variety of factors such as technological advancements, changes in trade policies, and the ongoing challenges of the COVID-19 pandemic. As businesses adapt to new conditions, many have shifted toward digital platforms, automating processes to increase efficiency and streamline operations. This transformation has also led to the rise of e-commerce, with online shopping becoming more prevalent than ever. While these changes have opened up new opportunities, they have also presented challenges related to cybersecurity, privacy, and the need for continuous innovation. Moving forward, companies must remain agile, staying ahead of trends and evolving customer expectations to maintain a competitive edge in the market."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faiefmh4cdlcyltxpbq9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faiefmh4cdlcyltxpbq9h.png" alt="ai-cli-tool summarize result" width="800" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should see a concise summary of the provided text printed to your terminal.&lt;/p&gt;

&lt;p&gt;You can extend this approach for other tasks by changing the system and user messages sent to the OpenAI API:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Translation:&lt;/strong&gt; Instruct the model to translate text to another language.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ai-cli-tool translate &lt;span class="s2"&gt;"Bonjour tout le monde"&lt;/span&gt; &lt;span class="nt"&gt;--to&lt;/span&gt; en
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sentiment Analysis:&lt;/strong&gt; Ask the model to determine the sentiment of the input text.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ai-cli-tool analyze-sentiment &lt;span class="s2"&gt;"I love learning new things!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Code Generation: Prompt the model to generate or refactor code snippets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By modifying the prompt and possibly adding new commands, you can create an entire suite of AI-powered CLI tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adapting This Knowledge Beyond the CLI
&lt;/h2&gt;

&lt;p&gt;The approach you’ve learned here—integrating OpenAI’s API, managing API keys securely, and interpreting responses—goes far beyond building a CLI tool. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Web Applications:&lt;/strong&gt; You can use the same logic within a Node.js backend for a web application. Your server endpoints could accept text data from a frontend, summarize it using the OpenAI API, and return the results to be displayed in the browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mobile Apps:&lt;/strong&gt; If you’re building a mobile app (either native or using frameworks like React Native or Flutter), you can set up a backend service powered by Node.js. Your mobile app would send requests to the server’s API, which would then leverage the OpenAI API to process data and return insights or summaries directly to the user’s phone.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Desktop Clients:&lt;/strong&gt; The same code could also serve as the core logic for a desktop app. For example, an Electron-based application could offer text summarization directly on the user’s desktop without needing to open a browser or terminal.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In essence, the fundamental principles—obtaining an API key, sending requests to OpenAI’s endpoints, and handling responses—apply across various environments. Whether it’s a CLI tool, a web service, a mobile app, or a desktop client, you can integrate AI functionalities anywhere you need them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Experiment with Parameters:&lt;/strong&gt; Adjust &lt;code&gt;temperature&lt;/code&gt; and &lt;code&gt;model&lt;/code&gt; to control the style and creativity of responses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Version Control Your Code (But Not Your Key):&lt;/strong&gt; While you can commit your code to a repository, remember that the API key should stored locally on each user’s machine and not committed to Git.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Publishing to npm:&lt;/strong&gt; If you want to share your CLI tool with others, you can publish it to npm. Check out the &lt;a href="http://-%20https://docs.npmjs.com/creating-and-publishing-unscoped-public-packages" rel="noopener noreferrer"&gt;npm documentation on publishing packages&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You’ve now built a simple AI-powered CLI tool and learned how to securely store your API key without relying on environment variables. You can run the tool from anywhere on your system and easily adapt it for a variety of AI-driven use cases.&lt;br&gt;
Whether you’re summarizing text, translating languages, or performing sentiment analysis, you now have a strong foundation for building and sharing your AI-powered command-line utilities.&lt;/p&gt;

&lt;p&gt;Feel free to experiment, iterate, and create the AI-powered tools you’ve always envisioned!&lt;/p&gt;

</description>
      <category>openai</category>
      <category>chatgpt</category>
      <category>ai</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
