Back to home

Agentic AI / Generative AI

A clear and practical article about artificial intelligence for a professional audience.

Audio reading is not available in this browser
Agentic AI / Generative AI

Tags

Quick summary

A clear and practical article about artificial intelligence for a professional audience.

Agentic AI / Generative AI

The artificial intelligence landscape is undergoing a fundamental shift from passive content generation to active autonomous execution. Generative AI established the foundation by enabling machines to produce coherent text, realistic images, and functional code. Agentic AI builds upon that foundation, transforming models from static generators into dynamic systems that plan, reason, use tools, and iterate toward goals. The result is a new class of software that does not merely answer questions but completes workflows.

Organizations across the industry are advancing both paradigms. OpenAI, Anthropic, Microsoft, and NVIDIA each contribute to the evolving technical discourse through their respective research and engineering channels. Their work spans foundation model training, safety alignment, cloud infrastructure, and hardware acceleration. As these layers mature, developers are gaining practical access to agentic capabilities that were previously confined to research labs. This article provides a hands-on guide to building with generative and agentic AI, moving from environment setup to a working ReAct agent.

Understanding the Landscape

Generative AI refers to models—typically large transformers or diffusion networks—that learn patterns from training data and synthesize novel outputs. Whether producing marketing copy, debugging code, or rendering synthetic data, the core interaction is request-and-response. The model receives a prompt and returns a completion.

Agentic AI extends this interaction loop by introducing autonomy. An agentic system perceives a goal, breaks it into sub-tasks, selects appropriate tools, observes intermediate results, and adjusts its plan. This architecture often relies on a language model as the reasoning engine, but the intelligence is distributed across the loop rather than concentrated in a single forward pass. Tool use, memory, and control logic become first-class components.

The convergence of these approaches is where modern application development is heading. A generative model provides the semantic reasoning; an agentic framework provides the state machine and tool bindings. Together, they enable applications that interact with APIs, query databases, execute code, and validate their own outputs. The following sections walk through the practical construction of such a system.

Requirements

Before installing software, ensure your environment meets the baseline criteria. You will need a modern operating system—Linux, macOS, or Windows Subsystem for Linux (WSL)—with Python 3.9 or newer installed. The tutorial uses pip for package management, so verify that pip is available alongside your Python interpreter.

You will also need an API key from OpenAI. This key allows access to the chat completions endpoint, which serves as the reasoning backbone for both the generative and agentic examples. If your organization uses Azure OpenAI Service, the code can be adapted by swapping the client initialization, though this guide assumes the standard OpenAI platform.

Hardware requirements are modest. CPU execution is sufficient for the orchestration layer because the heavy inference runs remotely on OpenAI’s infrastructure. However, ensure you have at least 2 GB of available RAM and a stable internet connection. Disk space requirements are minimal; the Python environment and libraries will consume less than 500 MB.

Optional but recommended tools include Git, for version control, and a virtual environment manager such as venv. These are not strictly necessary, but they prevent dependency conflicts and make the setup reproducible.

Step-by-Step Installation

Start by creating a dedicated directory for the project. Isolating your work avoids cluttering existing folders with new dependencies.

```bash mkdir agentic-ai-lab && cd agentic-ai-lab ```

Create a Python virtual environment inside this directory. A virtual environment ensures that the packages you install do not interfere with your system-wide Python installation.

```bash python3 -m venv venv ```

Activate the virtual environment so that subsequent pip commands install packages into this isolated context rather than the global environment.

```bash source venv/bin/activate ```

On Windows systems using PowerShell or Command Prompt, run the activate script located in the Scripts directory instead.

```bash venv\Scripts\activate ```

With the environment active, upgrade pip to the latest version. This minimizes compatibility issues during installation.

```bash pip install --upgrade pip ```

Install the core libraries required for generative AI access and agentic orchestration. You will need the official OpenAI client, LangChain bindings for OpenAI, and LangGraph for the agent framework.

```bash pip install openai langchain langchain-openai langgraph ```

To keep your API key out of source code, create a local environment file. The following command generates a hidden `.env` file in your project root.

```bash touch .env ```

Open the `.env` file in your preferred text editor and add your OpenAI API key. Replace the placeholder with your actual key.

```bash echo "OPENAI_API_KEY=sk-your-key-here" > .env ```

Export the key into your current shell session so the Python scripts can read it directly during this tutorial.

```bash export OPENAI_API_KEY=$(grep OPENAI_API_KEY .env | cut -d '=' -f2) ```

Verify that the key is correctly loaded by printing the first few characters. Never print the entire key in a shared terminal.

```bash echo $OPENAI_API_KEY | cut -c1-10 ```

Confirm that all packages installed correctly by running a quick import test. This command should complete silently with no output if everything is properly linked.

```bash python -c "import openai, langchain, langgraph; print('OK')" ```

Your environment is now ready. The remaining steps involve writing and executing Python scripts that exercise both generative and agentic patterns.

Usage Examples

Example 1: Foundational Generative AI

The simplest entry point is direct interaction with a large language model through the OpenAI client. This establishes that your API key, network access, and library versions are functioning. Create a file named `generate.py` and populate it with the following code.

This script imports the OpenAI client and initializes a connection using the API key you exported earlier.

```python from openai import OpenAI

client = OpenAI() ```

The client sends a chat completion request to the `gpt-4o-mini` model. This model offers a strong balance of capability and latency for prototyping.

```python response = client.chat.completions.create( model="gpt-4o-mini", messages=[ {"role": "system", "content": "You are a concise technical assistant."}, {"role": "user", "content": "Explain the difference between generative AI and agentic AI in one paragraph."} ], temperature=0.2 ) ```

Finally, extract and print the generated text from the response object.

```python print(response.choices[0].message.content) ```

Run the script from your terminal.

```bash python generate.py ```

You should receive a coherent paragraph distinguishing generative AI as a content creation technology and agentic AI as a goal-driven, tool-using system. This confirms that your generative pipeline is operational.

Example 2: Agentic AI with Tools and Reasoning

Moving beyond single-turn generation requires an agentic framework. This example uses LangGraph to construct a ReAct agent—an architecture that interleaves Reasoning and Acting. The model thinks through a problem, decides whether to use a tool, observes the tool output, and repeats until it reaches a final answer.

Create a new file named `agent.py`. Begin by importing the necessary modules. `ChatOpenAI` provides the model interface, `tool` decorates custom functions, and `create_react_agent` builds the state machine.

```python from langchain_openai import ChatOpenAI from langchain_core.tools import tool from langgraph.prebuilt import create_react_agent ```

Define a simple calculator tool. The `@tool` decorator exposes the function to the agent with a name and description derived from the docstring.

```python @tool def multiply(a: float, b: float) -> float: """Multiply two numbers and return the product.""" return a * b ```

Define a second tool that sim

Sources

FAQ

What is this article about?

This article covers “Agentic AI / Generative AI” in the AI agents category. A clear and practical article about artificial intelligence for a professional audience.

Who is this useful for?

It is useful for readers who want a practical understanding of AI tools, models, and workflows.

What should I do next?

Read the article, review the listed sources, and test the most relevant ideas in your own workflow.