aregmi.net
Resume

GenAI in Python — OpenAI SDK, LangChain, and plain Python patterns

python openai langchain ai framework

Python AI

Python is where most of the GenAI ecosystem lives. Two paths here:

Neither replaces the other. Learn the SDK first, then LangChain makes more sense.

When to use which?

OpenAI SDK LangChain
Tools / function calling Native support Wraps it + adds agent tooling
RAG You build the retrieval Built-in retrievers + vector stores
Chat memory You manage the message list Built-in memory classes
Structured output JSON mode + response_format Output parsers + Pydantic
Agents Assistants API AgentExecutor, LangGraph
Learning curve Low — just API calls Medium — lots of abstractions

Simple rule: if you can do it with the SDK in under 50 lines, do that. If you're wiring up RAG + memory + tools + routing, LangChain saves you time.

What's covered here

  1. Getting Started — install, first API call, message structure
  2. Prompts — system prompts, templates, few-shot
  3. Agents — routing, chains, LangChain AgentExecutor
  4. Tools — function calling with SDK and LangChain
  5. Chat Memory — conversation state management
  6. RAG — retrieval-augmented generation
  7. Structured Output — JSON mode, Pydantic, strict schemas

Resources