AI agents and RAG are the layer of software through which an app uses an AI model. An app rarely sends a question straight to a model. In between, a gateway chooses which model to use, a framework gives the model tools so that it can act, and a retrieval system hands it the right passages from the company's own documents. RAG stands for retrieval-augmented generation.
Take, for example, the HR assistant of a large hospital chain in Gurugram. A nurse types: 'How many days of my earned leave carry over to next year, and how many do I have left?' Three things happen before she gets an answer.
First, retrieval-augmented generation (RAG) searches the chain's leave policy and finds the paragraph on carrying leave over. It searches by meaning, not by exact words, using a vector database. The page on vector embeddings explains how meaning is turned into numbers.
Second, an AI agent framework lets the assistant act. The framework describes a tool to the model: 'get the leave balance of an employee'. The model decides to use the tool, and the framework calls the HR system, which returns '14 days'. An assistant that can use tools in this way is called an AI agent. The limits on what it may do are explained on the page on AI agent guardrails.
Third, an LLM gateway sends the request, together with the passage and the balance, to a model. The gateway is one API, a single agreed way for apps to send requests, placed in front of many model providers. It picks the provider, switches to another if one is down and records the cost. Sometimes the right model is a specialist, one of the domain-specific language models trained for one field, such as medicine, finance or law.
The model then writes: 'Up to 30 days carry over. You have 14 days left.' The nurse never sees the three steps. Without them, though, the model would not know the policy and could not check her balance. And the hospital could not switch to another model without rewriting its app.