<?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: Anand Vikkath</title>
    <description>The latest articles on DEV Community by Anand Vikkath (@anandvikkath).</description>
    <link>https://dev.to/anandvikkath</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%2F2859253%2Fc371af30-48ac-4f44-b7bc-16f5b38da3bb.jpg</url>
      <title>DEV Community: Anand Vikkath</title>
      <link>https://dev.to/anandvikkath</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anandvikkath"/>
    <language>en</language>
    <item>
      <title>Install ShellGPT with Gemini API</title>
      <dc:creator>Anand Vikkath</dc:creator>
      <pubDate>Fri, 13 Feb 2026 09:46:06 +0000</pubDate>
      <link>https://dev.to/anandvikkath/install-shellgpt-with-gemini-api-48go</link>
      <guid>https://dev.to/anandvikkath/install-shellgpt-with-gemini-api-48go</guid>
      <description>&lt;h2&gt;
  
  
  1. Install System Dependencies
&lt;/h2&gt;

&lt;p&gt;Ensure your Ubuntu system is ready with Python and the required virtual environment tools.&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;sudo &lt;/span&gt;apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;python3 python3-pip python3-venv &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Set Up a Virtual Environment
&lt;/h2&gt;

&lt;p&gt;Installing in a virtual environment prevents ShellGPT from interfering with other system tools.&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="c"&gt;# Create and enter the directory&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/shellgpt &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; ~/shellgpt

&lt;span class="c"&gt;# Create the environment&lt;/span&gt;
python3 &lt;span class="nt"&gt;-m&lt;/span&gt; venv venv

&lt;span class="c"&gt;# Activate it (you must do this every time you work in this folder)&lt;/span&gt;
&lt;span class="nb"&gt;source &lt;/span&gt;venv/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Install ShellGPT with LiteLLM
&lt;/h2&gt;

&lt;p&gt;ShellGPT needs the &lt;code&gt;litellm&lt;/code&gt; extra to talk to Google's API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"shell-gpt[litellm]"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Configure Your API Keys
&lt;/h2&gt;

&lt;p&gt;ShellGPT has a quirk: it was built for OpenAI, so it &lt;strong&gt;crashes&lt;/strong&gt; if it doesn't find an OpenAI key, even if you are using Gemini. We bypass this by giving it a "placeholder" key.&lt;/p&gt;

&lt;h3&gt;
  
  
  Set the environment variables
&lt;/h3&gt;

&lt;p&gt;Add these to your &lt;code&gt;.bashrc&lt;/code&gt; so they load automatically when you log in:&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;echo&lt;/span&gt; &lt;span class="s1"&gt;'export GEMINI_API_KEY="your_actual_ai_api_key_here"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'export OPENAI_API_KEY="placeholder"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Permanent VENV activation
&lt;/h3&gt;

&lt;p&gt;Open your &lt;code&gt;.bashrc&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Scroll to the bottom and add this line:&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;alias &lt;/span&gt;&lt;span class="nv"&gt;sgpt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'~/shellgpt/venv/bin/sgpt'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save and exit (&lt;code&gt;Ctrl+O&lt;/code&gt;, &lt;code&gt;Enter&lt;/code&gt;, &lt;code&gt;Ctrl+X&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Apply the changes:&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;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the &lt;code&gt;sgpt&lt;/code&gt; command will work instantly every time you log in, without needing to run the &lt;code&gt;source&lt;/code&gt; command.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Configure ShellGPT (&lt;code&gt;.sgptrc&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;Run a quick command to ensure the configuration folder is created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sgpt &lt;span class="s2"&gt;"init"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;[!NOTE]&lt;br&gt;
Output for this command will have API error. Ignore it&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now, open the configuration file to tell ShellGPT to use Gemini:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano ~/.config/shell_gpt/.sgptrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Update the following lines (or add them if they are missing):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="c"&gt;# Use LiteLLM to bridge to Google&lt;/span&gt;
&lt;span class="py"&gt;USE_LITELLM&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="c"&gt;# Set your preferred Gemini model&lt;/span&gt;
&lt;span class="py"&gt;DEFAULT_MODEL&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="err"&gt;gemini/gemini&lt;/span&gt;&lt;span class="mf"&gt;-2.5&lt;/span&gt;&lt;span class="err"&gt;-flash&lt;/span&gt;

&lt;span class="c"&gt;# This MUST be here to satisfy the internal code check&lt;/span&gt;
&lt;span class="py"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="err"&gt;placeholder&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. How to Use Your New Tool
&lt;/h2&gt;

&lt;p&gt;Now that everything is linked, here is how you can use it in your day-to-day sysadmin tasks:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Command&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Usage&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sgpt "Hello"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;General chat/question.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sgpt --code "python script to ping servers"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Generates only code (no conversational text).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sgpt --shell "list all docker containers"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Generates a command and asks if you want to run it.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>ai</category>
      <category>cli</category>
      <category>gemini</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
