Step-by-Step: Three Essential APIs to Interact With LLMs
With three exercises: build a simple chatbot (Lovable + Chat Completions API), a chatbot with file search (Lovable + Threads API), and a chatbot that can browse the web (Replit + Responses API).
Hey, Paweł here.
I continue adding content to the C10. LLM Systems Practitioner PM of our AI PM Learning Program, so that we can learn AI PM by doing.
Soon, the program will be converted into a set of self-paced courses. After submitting the exercises (individual or as a group), you will receive a digital certificate for each module.
In this post, we discuss:
Three Essential APIs to Interact With LLMs
🔒Exercise 1: Build a Simple Chatbot: Lovable and Chat Completions API
🔒Exercise 2: Build a Chatbot That Can Search PDFs: Lovable and Threads API
Phase 1: Without streaming
Phase 2: With streaming
Tomorrow, I’ll add Exercise 3: Build a Chatbot That Can Search PDFs and Browse the Web: Replit and Responses API. I’ve promised two exercises today, and wanted to add one extra :)
Before we continue, you might have missed:
Consider subscribing and upgrading your account for the full experience:
1. Three Essential APIs to Interact With LLMs
Chat Completions API
This is the industry baseline. It’s used by virtually all commercial LLM agents, coding agents, and by default in all agentic frameworks such as n8n, LangChain, LangGraph.
We send a list of messages, the model replies.
You can test it with different LLMs using OpenRouter. That’s the cheapest way to compare different LLMs without multiple subscriptions or hosting models yourself.
Short demo (I ran a prompt to compare three LLMs):
Things to keep in mind:
It’s stateless: if you want memory, you resend the last few turns yourself (chatbots do it by default).
It’s portable across vendors (Google, Anthropic, xAI, DeepSeek, etc.).
Solutions like OpenRouter can act as proxies for vendor/model selection.
You can add custom tools/functions via JSON schema, but not OpenAI’s built-in tools like Web Search or Code Interpreter.
More: Chat Completions reference
OpenAI Assistants
Assistants are “pre-configured AIs” with instructions, models, and built-in tools.
You can configure and test them directly in the OpenAI Platform > Assistants (requires a credit card, but you pay only for the tokens you consume, it’s symbolic, <$1 for dozens or hundreds of ChatGPT-4o-mini requests).
A quick demo. I created a new Recipe Assistant and uploaded 5 PDFs with recipes:
Assistants API v1 (legacy)
The first version. Deprecated, will shut down Aug 26, 2026.
More: Migration guide
Assistants API v2 (Threads)
The current way to run assistants with memory + built-in tools (RAG, Code Interpreter, file handling). You create a thread, add messages, then start a run with assistant_id.
OpenAI doesn’t promote it and recommends Responses API, but that’s the easiest way for you to build a real RAG chatbot with truly persistent threads.
We will later call it with the assistant ID:
More: Threads reference
OpenAI Prompts + Responses API
The Responses API is the new standard for calling models or prompts.
While stateless, you can get multi-turn conversations (and even conversations with branches) by providing previous_response_id in API calls
For many use cases, you want to combine Responses API with prompts.
Prompts are reusable, versioned templates. They can carry variables and also include tools: File Search (retrieval), Code Interpreter, MCP, Web Search, and Image Generation.
You can configure Prompts directly in the OpenAI Platform > Chat.
A quick, simple demo. I created a new Healthy Recipes prompt without any predefined messages and uploaded 5 PDFs with recipes (no sound):
Things to keep in mind:
After saving a prompt, you can use prompt_id + version in Responses API calls. This gives you a full prompt versioning and control over how prompt versions are deployed.
Those “conversation threads” do not persist long-term. A common piece of information I found was 30 days. So for persistent threads, you still might want to use Threads API or use a custom database.
More: Responses guide
LLM APIs Comparison
A brief overview of the available options:
TLDR;
As the primary focus was on LLMs, I didn’t include OpenAI’s:
Images API: Create new images from text prompts, can use a mask.
Video API: A new API for text-to-video generation
Audio API: They can convert speech-to-text, text-to-speech. Baked in Responses API, but also available as standalone endpoints.
And many others, such as:
Image APIs: Stability AI API, Google Imagen in Vertex AI
Video APIs: Runway, Google Veo
Audio APIs: ElevenLabs, AssemblyAI
We’ll discuss some of them when building AI agents.
2. Exercise 1: Build a Simple Chatbot: Lovable and Chat Completions API
You will learn:
Starting with Lovable
Building a simple chatbot with Chat Completions API, no backend
Step-by-step video
Keep reading with a 7-day free trial
Subscribe to The Product Compass to keep reading this post and get 7 days of free access to the full post archives.