Breaking

AI Integration

RSS →

Production Node.js patterns for OpenAI APIs, RAG, streaming, retries, cost controls, and vector search. Start here when an AI feature needs to behave like the rest of your backend: observable, testable, bounded, and safe to deploy.

Wiring an LLM into a Node.js backend is mostly unglamorous engineering: streaming, retries, token budgets, and the failure modes nobody mentions in the quickstart. This section keeps that part front and center. You will find practical integrations with the OpenAI and Claude APIs, function and tool calling, response streaming with the Vercel AI SDK, retrieval-augmented generation backed by Postgres and pgvector, LangChain.js when orchestration earns its weight, and building an MCP server in TypeScript. Every guide notes the rate limits and the ways a call can fail before it shows you the happy path, because in production the happy path is the part you spend the least time on. The code targets current Node.js LTS and the SDKs as they actually behave today, not the marketing version.

Related sections: Tutorials · Deploy & DevOps

FAQ

OpenAI or Claude for a Node.js integration?

The SDKs are close enough that you can wrap both behind one interface and switch on cost or capability. Start with whichever you already have keys for — the OpenAI and Claude guides use the same shape.

How do I stream responses instead of waiting for the whole thing?

Stream tokens over Server-Sent Events or use a toolkit that handles the transport for you. The Vercel AI SDK streaming guide covers both the server and client halves.

What is RAG and do I need it?

Retrieval-augmented generation feeds the model relevant chunks of your own data at query time instead of fine-tuning. You need it when answers must come from your documents. The RAG guide builds one on pgvector.

How do I handle rate limits and failures?

Expect 429s and timeouts as normal traffic: retry with exponential backoff and jitter, set a token budget per request, and degrade gracefully when the provider is down. Treat the model as an unreliable network dependency, because it is.