From AI Chatbot to Operating System
Moving past the "Beanie Baby" phase with your first Python API call to a large language model (LLM)
Right now, most people are using AI chatbots superficially. We treat them like novelties, asking for recipes or funny emails. But their true potential isn't as a chatbot; it's as an operating system—a command center that can automate complex research and business workflows.
This functionality is precisely what powers my 13F weekly email, and this post is the first of a series that will teach you how to build your own digital investing buddy, just like I built mine.
To understand the leap we're about to make from "AI toy" to "AI operating system," it helps to look back at the internet's own quirky, "Beanie Baby" phase.
The Internet's "Toy" Phase
In the late '90s, the revolutionary platform of eBay, which created a global, real-time auction house, was famously co-opted by a speculative mania for plush toys. People sank their savings into these collectibles, leveraging a powerful new form of commerce for something that, in hindsight, was utterly trivial. This is where we are with basic chatbots. We have access to an incredibly powerful tool for reasoning and task execution, but we're often using it for the equivalent of flipping a rare "Peanut the Royal Blue Elephant" instead of building a durable, automated research or business process.
Read the full story about the Beanie Babies craze here: https://edition.cnn.com/style/bursting-the-beanie-baby-bubble
Another fascinating example was The Million Dollar Homepage. In 2005, a student launched a website with a simple grid of one million pixels and sold each one for a dollar. The site had no function other than to exist as a mosaic of tiny, user-submitted ads. It was a brilliant gimmick that capitalized on the novelty of the internet itself. This is the perfect analog for the "wow" factor of a chatbot generating a perfect sonnet on command. It’s an impressive demonstration, but it’s a static party trick, not a dynamic, value-creating engine.
The site amazingly still exists: http://www.milliondollarhomepage.com/
Read the story here: https://webdesignerdepot.com/blast-from-the-past-the-million-dollar-homepage/
Finally, consider the world's first webcam: The Trojan Room Coffee Pot. Set up by researchers at Cambridge University, its sole purpose was to remotely monitor the office coffee pot to save people a wasted trip. It became an internet sensation, not because anyone needed to know the coffee level in a random UK office, but because seeing a "live" image from across the world was a miracle.
Full story here: https://en.wikipedia.org/wiki/Trojan_Room_coffee_pot
The Leap to an AI Operating System
This is where I humbly believe the current state of many AI interactions is—we're still mesmerized by the magic of the technology itself. But just as the internet evolved from a coffee cam to powering global video conferencing, LLMs will evolve from simple Q&A bots into the command-and-control center for workflows that analyze data, interact with other software, and execute multi-step strategies.
This idea was brilliantly visualized by Andrej Karpathy in a recent presentation:
You can (and I would dare to say you must) watch the full presentation here:
Using LLMs not as a chatbot but as the autonomous orchestrator of a workflow is what powers the architecture behind the weekly 13F email that you get by subscribing to www.stockpitchai.com for free.
But to build this new operating system, you first need to learn its most fundamental command: how to speak to it directly through code. This is where the API comes in, and it's the first step from being a passive user to an active builder.
LLM API 101 (aka Speaking to Your AI Chatbot from Code)
The core intention of this blog is to empower you in two critical ways.
First, we're going to give you the fundamental building blocks to create your own highly customized—and incredibly cheap—digital investing buddy. Forget paying exorbitant fees for a one-size-fits-all solution. We'll build it ourselves, step-by-step, assuming zero prior technical knowledge and always focusing on keeping the infrastructure as low cost as possible.
Second, as you learn how these tools are made, you'll naturally develop a powerful new skill: the ability to see through the hype. You'll be able to look at a vendor's pitch (or at an AI finance startup investors deck) and instantly discern whether they're offering real, defensible technology or just a fancy wrapper on a simple API call. The goal is to help you go from tech dummy (don't feel bad, that's precisely where I started) to a tech-savvy investor who can both build what they need and intelligently buy what they don't.
Over time, I will walk you through creating your own automated workflow. In this first post, I will help you create your first, extremely simple snippet of python code to call an LLM from your coding environment.
So, what’s an API? Think of it as a backdoor to accessing your favorite AI chatbot (be it ChatGPT, Gemini, Llama… etc). There are two crucial differences between accessing an AI chatbot through an API vs directly through the app or browser:
Billing: API access is billed on a per-token basis (think of a token as roughly a word).
Environment: You need a coding environment to make calls to these APIs.
Setting up your first coding environment
My favorite coding environment is Google Colab. You just need a free Gmail account to use it.
Colab is also free unless you need access to powerful TPUs or GPUs. We don’t need these so Colab will remain free for us going forward.
I might do a post at some stage explaining why it may be a good idea for you to upgrade to paid (chiefly if you need background execution or plan to run ad-hoc AI libraries that you can get from Hugging Face). For now, let’s keep it simple and free.
Go to: https://colab.research.google.com/
Click on “New notebook” in the bottom right.
We will name the notebook “myfirstLLMAPIcall”. Here’s what you should see:
You should be prompted to allow AI-assisted autocompletions. Click “Enable”. If not, click the gear symbol in the top right, go to "AI Assistance", and activate the features. This will help you code much faster.
Adding your Gemini API key
We will be using Gemini, as it currently defines the pareto frontier of cost per token.
https://winston-bosan.github.io/llm-pareto-frontier/
In plain English: Gemini models are the cheapest way to access intelligence today, for a given level of intelligence.
Crucially, it offers a free tier for a limited number of requests per minute. This means we can play around with it for free without the fear of getting billed a silly amount for testing.
To use the Gemini API, you need an API key. Think of it as a car's registration plate—it identifies you for billing.
Here are the required steps:
Go to Google AI Studio to create your key: https://aistudio.google.com/prompts/new_chat
Click “Get API key”, accept the terms, and then click “Create API key”.
Copy the generated key.
NEVER SHARE THIS API KEY WITH ANYONE! THIS IS THE EQUIVALENT OF THE PIN CODE OF YOUR CREDIT CARD!
Back to Google Colab
Colab has a “Secrets” section (key symbol on the left bar).
You can store your API keys here safely. Since we are using Gemini, you can import the key directly by clicking on "Gemini API Keys".
Once it is imported, here’s what you should see:
Making your first API call to Gemini
We will be using gemini-2.5-flash
, which is free for up to 10 requests per minute and less than 500 requests per day (you can see this in the Rate limits box at the bottom of below screenshot):
Now copy the following code into your Colab session:
# Import libraries
import google.generativeai as genai
from google.colab import userdata
# Get the API key
GOOGLE_API_KEY = userdata.get('GOOGLE_API_KEY')
genai.configure(api_key=GOOGLE_API_KEY)
# Make your first API call to Gemini LLM
model = genai.GenerativeModel('gemini-2.5-flash')
prompt = 'Will Berkshire Hathaway beat the market after Warren Buffet retirement?'
response = model.generate_content(prompt)
print(response.text)
Here’s what you should see:
Now click the play button on the top left corner of the code cell and see the result!
Here’s what I got as a reply from Gemini:
Predicting whether Berkshire Hathaway will *consistently beat the market* after Warren Buffett's retirement is complex, but here's a breakdown of the arguments for and against, and what to consider: **Arguments for Continued Strong Performance (or at least Stability):** 1. **Established Succession Plan:** Warren Buffett has meticulously prepared for this transition for decades. Greg Abel is designated as his successor for the overall business, and Ajit Jain for the insurance operations. Both are highly respected, long-time Berkshire executives with deep understanding of the company's culture and operations. 2. **Decentralized Business Model:** Berkshire Hathaway is already a collection of largely autonomous businesses. Buffett's primary role in recent years has been capital allocation and maintaining the culture, rather than day-to-day operational management. The individual businesses have strong managers in place. 3. **Strong Culture:** The culture of frugality, long-term thinking, trust in managers, and a focus on intrinsic value is deeply embedded. This culture is designed to outlive its founder. 4. **Massive Capital Base:** Berkshire sits on an enormous amount of cash and marketable securities (often over $150 billion). This gives them a significant advantage for large acquisitions, share buybacks, or investing during market downturns. 5. **High-Quality, Diversified Businesses:** Berkshire's wholly-owned businesses (BNSF Railway, Geico, Berkshire Hathaway Energy, Precision Castparts, etc.) are generally high-quality, durable assets with strong competitive moats that generate substantial free cash flow. 6. **Investment Team in Place:** Ted Weschler and Todd Combs have been managing significant portions of Berkshire's public equity portfolio for years, operating semi-independently. They have proven their capabilities. 7. **Tax Advantages:** As a holding company, Berkshire benefits from tax deferral on unrealized gains and other structural advantages that are not tied to Buffett himself. **Arguments Against Consistently Beating the Market (or potential challenges):** 1. **Loss of Warren Buffett's Unique Genius:** Buffett is an irreplaceable combination of exceptional capital allocator, shrewd dealmaker, astute investor, and unparalleled communicator. His "halo effect" has allowed Berkshire to strike unique deals and attract capital. This qualitative edge will be lost. 2. **Scale Challenge:** Berkshire Hathaway is enormous (one of the largest companies globally by market capitalization). It becomes increasingly difficult to find investments or acquisitions that are large enough to move the needle meaningfully for a company of its size. Smaller, more nimble funds have an inherent advantage in finding underpriced opportunities. 3. **Successor's Focus:** While Greg Abel is an excellent operator and capital allocator, his track record in public market investing isn't as extensive or public as Buffett's. His strengths lie more in operational excellence and large-scale acquisitions of private businesses, which might lead to a different *type* of growth. 4. **Loss of Investor Confidence/Sentiment:** A portion of Berkshire's valuation has always been attributed to the "Buffett premium." Some investors may sell their shares simply because he's no longer at the helm, regardless of the underlying business quality. 5. **Charlie Munger's Absence:** The recent passing of Charlie Munger also represents the loss of a key intellectual partner and sounding board for Buffett. While his direct impact on operations had lessened, his philosophical guidance was profound. 6. **Return on Massive Cash Pile:** Deploying its vast cash pile effectively will be a major challenge. If it sits idle, it drags on returns. If deployed poorly, it can destroy value. **Conclusion:** It's highly probable that Berkshire Hathaway will remain a **stable, financially strong, and well-managed company** after Warren Buffett's retirement. It will likely continue to generate **solid, above-average returns** over the long term, compounding capital at a respectable rate. However, **consistently "beating the market" (especially a broad index like the S&P 500) year after year will be a much tougher task.** The unique combination of Buffett's investment genius, his unparalleled reputation, and the company's smaller size in its earlier decades allowed for truly exceptional outperformance. The goal for the post-Buffett Berkshire is likely to shift from *spectacular outperformance* to *consistent, compounding returns* that preserve capital and outpace inflation, while minimizing risk. They will likely lean more heavily on large, strategic acquisitions of entire businesses rather than complex public equity trading. In essence, Berkshire Hathaway will likely remain a **fantastic company**, but the days of its legendary market-beating track record might become a historical footnote rather than a consistent future expectation.
You can decide for yourself whether that makes sense or it’s gibberish - for now don’t worry too much about whether you agree or disagree, or whether you think the quality of the output is high or low (we will go deeply into how to improve the quality of LLMs output by using techniques like RAG and smartly leveraging the size of the context window in future posts).
From Chatbot to OS: Your First Step
What you've just done might seem simple, but it's the most critical step. You've moved from using a web interface to giving the machine a direct command. You've opened the door to building workflows that don't just answer questions, but execute tasks.
This simple snippet of code is the foundation for the significantly more sophisticated workflows we'll build together.
In our next posts, we'll build on this foundation to feed the LLM external data, making our automated systems even more powerful.
Ready to Build Your Edge?
This is just the first step. Subscribe for free to get our next tutorial on building automated investment research tools with Python and LLMs. Stop paying for black boxes and start building your own alpha.
Have a question or an idea for a future post? Leave a comment below or email me directly at ceo@stockpitchai.com