Concepts / Inference Servers for Self-Hosted Models

Inference Servers for Self-Hosted Models

The simplest AI application architecture is a relay: a query goes from the application to the model, and the model's response goes back to the user, with no context augmentation, guardrails, or optimization.

  • Programming

Designing the Software Behind an AI Product

Imagine you are asked to design the software behind an AI product that is going into real use. The finished system may end up with many moving parts, and the diagram can look intimidating on first contact. A useful habit is to set the finished system aside and sketch the smallest design that could possibly work. Then you add pieces one at a time, each for a reason you can name. This article starts from that smallest design and follows the same path a team tends to follow in production.

What do you think happens?

A customer asks an AI support assistant whether their repaired bike is ready. In the simplest design, what does the model know about that customer's repair record?

  • The full repair history, because the model is connected to the shop's records

  • Only the sentence the customer typed, so it can only guess or ask for details

  • A summary of the last ten customers, because the model remembers past conversations

Reveal answer
Answer:

Only the sentence the customer typed, so it can only guess or ask for details.

In the simplest design the application sends only that sentence to the model. The model has no way to know the customer's repair record, so the design cannot supply that information on its own.

Tracing One Request Through the Relay

The simplest AI application architecture is a relay. A query goes from the application to the model, and the model's response goes back to the user. There is nothing else in the path. Follow one request step by step: the user submits a question to the application; the application forwards that question to a model; the model produces an answer; and the application passes that answer back to the user. The diagram below traces exactly those parts, in that order.

Usersubmits a questionApplicationrelay with one jobModel APIthird-party or self-hostedqueryforwards querymodel answeranswer passed back
After the user sends a query, the application forwards it to the model API, and the model's answer travels back through the application to the user.

Notice what the application does not do on this path. It does not look anything up, does not screen the text, and does not remember which answers it has already produced. Its job is only to move text between the user and the model.

Three Roles and What the Model API Means

Definition

The simplest AI application architecture is a relay: a query goes from the application to the model, and the model's response goes back to the user, with no context augmentation, guardrails, or optimization.

The simplest architecture has only three roles in play: the person, the application, and the model. The phrase model API covers two different situations. One is a third-party service offered by a model provider, which the application reaches over the network. The other is a model that the team hosts itself. From the application's point of view, both look the same: a place it sends a request and receives a response. How a self-hosted model is actually served is a separate topic handled in the course's inference server material, so this article treats the model API as a destination for requests.

What the Simplest Design Leaves Out

It helps to name what is missing, because each absence corresponds to a later enhancement. The simplest design has three gaps. It has no context augmentation, so the model sees only what the user typed. It has no guardrails, so nothing checks what goes in or comes out for protection. It has no optimization, so every request is sent to the model fresh, and the system does not try to reduce response time or spend.

Worked example

A bicycle shop support assistant on the simple relay

A small bicycle shop builds an assistant. A customer asks whether their repaired bike is ready. Trace what the simplest design can do with that question.

  1. 1
    Step 1: the question enters the application

    The customer's sentence arrives at the application as the only input the design receives.

  2. 2
    Step 2: the application forwards only that sentence

    The relay sends the bare sentence to the model. Nothing is added from the shop's records, because there is no context augmentation step.

  3. 3
    Step 3: the model answers without the repair record

    The model has no way to know this customer's repair record, so it can only guess or ask the customer for details.

  4. 4
    Step 4: the answer returns to the customer

    The application passes the reply back unchanged in purpose: it is relayed, not checked or improved.

Result

The simple design works as a relay, but it cannot answer a question that depends on information the model was never given. That gap is exactly what context augmentation is later added to close.

Reading the Enhancement Menu

From the simple starting point, the material lists enhancements a team might consider: context input enhancement, guardrails, a model router and gateway, caching, and complex logic. Each item answers a different question: where the model gets its information, how the system is protected, how requests are directed, how cost and speed are improved, and how far the system can go beyond answering questions. Monitoring and observability are described as integral to any application, but they are not counted among these enhancements.

UserUserContext sourceApplicationApplicationGuardrailsModel APICacheModel router andgatewayModel APIqueryforwards queryqueryusesusesusessends requestroutes to model
The simple relay passes the query straight to the model API. The enhanced design lets the application use extra parts, and the model router and gateway is the only addition placed between the application and the model.

The listed order is a typical progression, not a required one. The source is explicit that everyone's needs differ, and that the right order is whichever order makes the most sense for the application being built. Treat the list as a menu with a suggested typical order, and decide from your own requirements which entries you need at all.

Matching an Enhancement to a Problem

Each enhancement is chosen to answer one question. When a team has a specific problem, the useful move is to name the problem first and then pick the enhancement that answers it. The comparison below pairs three stated problems with the enhancement that addresses each one. The pairings are a teaching illustration of the question each enhancement answers, not a complete design rule.

Answers lack neededfactsOutputs needscreeningRequests needdirectingContext inputenhancementGuardrailsModel router andgatewayaddressed byaddressed byaddressed by
Each stated problem on the left points to the enhancement that answers its question on the right.
Worked example

Choosing an enhancement for the bicycle shop

The bicycle shop assistant keeps answering repair-status questions with guesses. Which enhancement matches this stated problem, and why?

  1. 1
    Step 1: name the missing ingredient

    The model cannot know a customer's repair record because that record never reaches it. The problem is missing information, not unsafe output or routing.

  2. 2
    Step 2: match the problem to the question each enhancement answers

    The enhancement that answers where the model gets its information is context input enhancement, which is the one that brings outside information into the path.

  3. 3
    Step 3: check what the other enhancements would and would not fix

    Guardrails protect against what goes in or comes out, and a model router and gateway directs requests. Neither gives the model the repair record it lacks.

Result

Context input enhancement is the enhancement that matches this problem. Guardrails and routing are real additions a team might make later, but they answer different questions.

Mistakes When Reading the Architecture

  • Common mistake

    Assuming the list of enhancements must be built in the order shown

    Why it fails

    The source describes the list as a typical progression, not a mandatory order, and says the right order depends on the application being built.

    Do this instead

    Treat the list as a menu. Decide which entries you need, then sequence them by your own requirements.

  • Common mistake

    Treating the model API as necessarily a remote third-party service

    Why it fails

    The model API can be a third-party service or a model the team hosts itself. From the application's view, both are a place it sends requests.

    Do this instead

    Describe the model API as a destination for requests, and handle how a self-hosted model is served as a separate topic.

  • Common mistake

    Expecting the application in the simple design to remember past answers or check text

    Why it fails

    The simplest design's application does not look anything up, does not screen the text, and does not remember which answers it has already produced.

    Do this instead

    Add caching, guardrails, or context augmentation only when a stated need calls for them.

  • Common mistake

    Counting monitoring and observability as one of the enhancements

    Why it fails

    The source calls monitoring and observability integral to any application, and discusses them after the enhancement components rather than listing them among the enhancements.

    Do this instead

    Treat monitoring as a standing requirement for any system, separate from the enhancement choices.

Trying the Trace Yourself

MEDIUM

A team is building an assistant for a small library. A patron asks whether a book is on the shelf right now. The simple relay forwards only that sentence to the model. Which part of the relay is missing the information needed to answer, which enhancement would supply it, and where would that enhancement attach in the path?

Hints
  • Start from the three roles: the person, the application, and the model.
  • Ask which question the enhancement answers: where the model gets its information.
  • Remember that only the model router and gateway is drawn between the application and the model.

Key Takeaways

  • The simplest AI application architecture is a relay: a query goes from the application to the model, and the response goes back to the user.
  • The simple design omits context augmentation, guardrails, and optimization, and each omission corresponds to a later enhancement.
  • Enhancements such as context input enhancement, guardrails, a model router and gateway, caching, and complex logic each answer a different question, and each should be justified by a stated need.
  • The listed enhancement order is a typical progression, not a requirement, so teams choose and sequence entries according to their own application.

More concepts starting with I