The Definitive Guide to Artificial Intelligence for Programmers: From Chatbot to Autonomous Agent

- Andrés Cruz - ES En español

The Definitive Guide to Artificial Intelligence for Programmers: From Chatbot to Autonomous Agent

Artificial intelligence has stopped being an optional tool to become the core of modern software development. However, to successfully integrate it, it is not enough to just know how to copy and paste from a chat; it is essential to understand what happens "under the hood" of the models we use every day.

There are many tools today that we can use generally and many others designed for software development. This article is meant to take the first steps with tools to use AI as a developer.

1. What is an LLM really?

When we talk about AI in programming, we refer mainly to Large Language Models (LLM). These models are, in essence, neural networks with billions of parameters trained for a specific task: predicting the next token given a context.

We can imagine an LLM as a giant mathematical function to which we pass a context and it returns the most probable answer based on statistical patterns. It does not "think" like a human, but rather simulates intelligence by calculating probabilities over text snippets.

The three phases of model training

  • Pre-training: It is the most expensive phase where massive amounts of data (Wikipedia, GitHub, books) are fed to learn grammar, reasoning, and code. This is where GPUs work at their maximum capacity.
  • Fine-tuning: Once the model knows the language, it is trained specifically to hold conversations and follow useful instructions.
  • RLHF (Reinforcement Learning from Human Feedback): Humans evaluate the responses to refine usefulness, avoid harmful content, and improve response structure.

2. Parameters, Tokens and Context

To choose the right model, we must understand its units of measurement:

  • Parameters: They are the internal "dials" of the model that are adjusted during training. A "30B" model has 30 billion parameters; the higher the number, the greater the capacity, but also the higher the costs and hardware requirements.
  • Tokens: Models do not process complete words, but rather fragments called tokens. A token usually equals about 4 characters in English, but this varies by language and model.
  • Context Window: It is the limit of information that the model can "remember" in a single session. The larger the context, the more files and code we can send to it at once.

3. Prompt Engineering and Security

The quality of the response depends directly on the input ("Garbage in, garbage out"). There are two types of critical messages:

  • System Prompt: Configures the base behavior and restrictions of the model (e.g., "Act only as a security expert").
  • User Prompt: It is the specific user query.

Security: It is vital to be aware of attacks like Prompt Injection, where a user attempts to bypass system restrictions through persuasion techniques or contradictory commands.

4. Tools: AI Levels in Development

We can classify the use of AI into three integration levels:

  1. Inline Completion: Tools like GitHub Copilot suggest code while you write in the same file.
  2. Conversational Assistants with Canvas: Interfaces like Claude or Gemini that allow editing code on a side canvas and previewing changes in real time.
  3. Native AI Editors: Like Cursor or the deep integration of VS Code, where the AI understands the entire project.

5. Visual Studio Code and Copilot or Google Antigravity: Agent Mode

VS Code has evolved to offer agents that not only respond, but also act on the system:

6. Terminal Agents: Cloud Code (Claude Code) and Open Code

For terminal lovers, there are agents like Cloud Code that operate directly on the repository.

// Command to initialize the project context
cloud /init

These agents can perform automatic commits by understanding the changes made, run tests, and execute massive refactorings without the need for a graphical interface.

Difference between MCP and Agent Skills

This distinction is key for AI architects:

  • MCP (Model Context Protocol): They are functionality tools that allow the AI to connect to external sources like Google Chrome, databases, or third-party APIs.
  • Agent Skills: They are reusable knowledge modules (packaged instructions) that the agent loads on demand when it detects that the task requires it (e.g., a frontend design skill).
  • Modern tools like Laravel Boost.

7. Local AI with Ollama

If privacy is a priority or you want to avoid per-token costs, you can use Ollama to run models 100% locally.

It requires powerful hardware, especially in RAM memory (minimum 32GB recommended), since it uses the GPU intensively.

There are many other AIs you can install locally such as jan.ia or LM Studio that we used previously to create a local AI chatbot with FastAPI or Flask.

8. NotebookLM: Source-Based Research

Finally, tools like NotebookLM allow creating assistants that only respond based on specific sources (PDFs, YouTube videos, or URLs). This eliminates external hallucinations and allows generating automatically:

  • Study guides and interactive quizzes.
  • Audio summaries (podcasts) and explanatory videos.
  • Infographics and mind maps of the content.

Master Guide: How to Integrate Artificial Intelligence into Professional Full Stack Development

Artificial intelligence has stopped being a simple query tool to become a fundamental component of software infrastructure. Today we are not going to talk about how to use a chat; we are going to dive deep into how to become an AI Engineer, integrating language models into the backend, optimizing the frontend with streaming techniques, and protecting your resources with robust architectures.

1. Project Architecture: The Multi-Package Monorepo

Before writing a single line of AI code, it is vital to have a structure that scales. The trend in the industry, used by giants like Google, is the Multi-Package Monorepo.

To give you an idea of the magnitude, Google's repository manages close to 86 Terabytes of information and billions of lines of code under a single strategy. In our development, this allows us to have the /backend folder and the /frontend folder sharing dependencies and facilitating deployment.

Configuration with NPM Workspaces

To manage this without dying trying, we use npm workspaces. In the root package.json, we define the workspaces:

{ "name": "ai-project-root", "private": true, "workspaces": [ "frontend", "backend" ] }

This allows us to run npm install only once and let it handle all dependencies. In addition, we can create scripts at the root to lift both environments simultaneously using commands like npm run dev -w backend.

2. Backend: OpenAI API Integration and Environment Management

The current standard for communicating with language models is the OpenAI API. Even open-source models like DeepSeek or Kimi usually use structures compatible with this standard to ease migration.

Loading environment variables without dependencies

In modern versions of Node.js, you no longer need external libraries like dotenv. You can load your .env file natively:

import { process } 
from 'node'; process.loadEnvFile(); 
// Automatically loads the .env file

AI Router Configuration

When creating an endpoint to generate summaries or process data, it is critical to configure the System Prompt. This message defines the personality and restrictions of the AI, preventing the model from wandering off or responding with unnecessary information.

const systemPrompt = "You are a technical assistant that summarizes job offers. Respond only in Markdown and avoid additional comments.";

It is fundamental to implement a try/catch block. Communication with the AI can fail due to lack of credit, latency, or provider errors. Golden safety rule: Never send the raw system error to the client, as it could reveal details of your infrastructure.

3. Advanced Security: Rate Limiting and IP Protection

AI is an expensive resource. Without protection, a malicious user could make thousands of requests and drain your budget in a matter of minutes. The solution is to implement a Rate Limit.

Using the express-rate-limit middleware, we can configure time windows. For example, allowing only 5 requests per minute for each IP address. However, there is a catch: if your server is behind a proxy (like Vercel, Cloudflare, or Nginx), all requests will appear to come from the same IP.

To fix this, we must trust the proxy:

app.set('trust proxy', 1); 
// Trusts the first proxy hop to obtain the real IP

This ensures that the limit is applied to the real user and does not accidentally block all your legitimate traffic.

4. User Experience: The Power of Streaming

Waiting for an AI to generate a full paragraph can take 2 or 3 seconds. For the user, this feels like a slow application. The Streaming technique allows sending text fragments (tokens) as the model generates them.

Server Configuration

We must change the response headers to indicate that the data will arrive in chunks:

  • Content-Type: text/plain; charset=utf-8
  • Transfer-Encoding: chunked

In the backend code, we enable stream: true mode in the API call and use an asynchronous for await loop to write each chunk to the response immediately.

5. Frontend: Reading Streams and Rendering Markdown

On the client side (React/Vite), we can no longer use a simple await response.json(). We need a reader for the response body:

const reader = response.body.getReader(); 
const decoder = new TextDecoder(); 
while (true) { 
  const { done, value } = await reader.read(); 
  if (done) break; 
  const chunk = decoder.decode(value); 
  setSummary(prev => prev + chunk); // Progressive state update }

Progressive Rendering with Streamdown

If the AI responds in Markdown, using dangerouslySetInnerHTML directly will make the layout look "broken" while the text arrives. The Streamdown library is perfect for this, as it renders the Markdown in an animated and progressive way, maintaining visual coherence throughout the entire data flow.

6. Gateways: Do not marry a single model

Relying exclusively on OpenAI is a risk. If the service goes down, your application becomes useless. An AI Gateway (like the one provided by Vercel AI SDK) acts as an intermediary pipeline. It allows you to switch between Google (Gemini), Anthropic (Claude), or free open-source models simply by changing a single line of code, without rewriting the streaming logic of your backend.

7. Fundamentals: The Alk0.dev Resource

Although AI is powerful, as programmers we cannot forget the fundamentals. Alk0.dev has been launched, an interactive and visual resource in Spanish to master data structures and algorithms. From recursion to complex algorithms like the Sudoku Solver or Babel Sort, this resource allows you to see step-by-step how variables execute, reminding us that solid logic is the foundation upon which AI is built.


Frequently Asked Questions and Technical Queries

How can I integrate the OpenAI API into a Node.js project?

First, install the official library with npm install openai. You must obtain an API Key from the OpenAI dashboard and save it in your .env file. In your code, create an instance of the client and use the chat.completions.create method. It is fundamental to define the 'system' (instructions) and 'user' (the query) roles to get accurate results.

What are the key differences between using an LLM and an autonomous agent?

An LLM (Large Language Model) is the statistical engine that predicts text and answers questions based on its training. An autonomous agent, on the other hand, is a system that uses the LLM as its "brain" but has "hands": it can execute commands in the terminal, browse files, or make external API calls to complete a complex task without constant supervision.

What tools do you recommend for running artificial intelligence models locally?

The leading tool is Ollama, which allows you to download and run models like Llama 3 or Mistral on your own machine for free and privately. There are also choices like Open Code to integrate these local models directly into your code development workflow.

What is the Model Context Protocol (MCP)?

It is a standard that makes it easier for AI models to access the context of your development tools. It allows the model to "understand" your current workspace, your databases, or your browser in a standardized way.

Why does my Rate Limit block all users?

It is probably because your server is behind a proxy and you have not configured trust proxy. Without this, the server sees the proxy's IP (which is the same for everyone) instead of each user's individual IP, hitting the global limit almost immediately.

Master Artificial Intelligence for programmers: from the workings of LLMs, tokens and context windows, to the creation of autonomous agents and the use of tools such as VS Code, Cursor and Cloud Code.


Únete a la comunidad de desarrolladores que han decidido dejar de picar código y empezar a construir productos reales. Recibe mis mejores trucos de arquitectura cada semana:

I agree to receive announcements of interest about this Blog.