Lesson 122 — Advanced
The Three Ways to Consume a Model
AI app banate waqt sabse pehla bada decision code ka nahi hota — model aayega kahan se ye hota hai. Is lesson mein hum teeno raaston ko mechanism samjhenge: public API, managed platform, open weights — aur har raasta kis wajah se chunta hai ya reject hota hai.
Model consume karne ke teen raaste
Kya hai?
Koi bhi AI workload teen tarikon se model chala sakta hai: (1) provider ki public API call karo, (2) apne cloud account ke andar managed platform use karo, (3) open weights lo aur inference ya toh khud host karo ya kisi inference provider se karwao.
Kab kaam aata hai?
Architecture design ke shuruwaat mein — jab tum decide karo ki data kahan jaayega, identity kaisi hogi, bill kis account se aayega. Ye decision quality se pehle aata hai, kyunki ye constraint define karta hai ki aage kya possible hai.
Kahan milta hai?
Design docs aur architecture reviews mein, procurement discussions mein, aur security review ke pehle wale page par. Tumhara har AI feature ek in teeno paths mein se kisi ek par baithta hai.
Funda ye hai: model ka naam nahi, uski "sewa ki jagah" decide karti hai ki architecture kaisi banegi. Public API pe app simple hai, par data account se bahar jaata hai. Managed platform pe identity, network aur billing cloud ke rules se chalti hain. Open weights mein control tumhare paas hai, par operations tumhare sar par.
Raasta 1 — provider ki public API
tumhari app ──HTTPS──▶ provider ka endpoint (public internet)
│
request authenticate (API key)
model provider ke servers pe chalta hai
response wapas tumhari app ko
bill: per token, provider ke account se
ops: provider ka — tum sirf call karo
- Sabse tez start: account banao, key lo, call chalu. Naye models provider pe pehle aate hain — tumhe sabse pehle un tak pahunch milti hai.
- Data boundary: har request provider ke servers jaati hain. Tumhari policy ko isi baat ko likhna padta hai — kya bhej sakte ho, kya nahi.
- Identity: ek shared API key aksar. Key leak hui toh service ruk jaayegi — rotation aur scoping tumhara kaam hai.
- Lock-in angle: request format provider ka apna ho sakta hai — SDK badalne par code bhi badalta hai.
Raasta 2 — apne cloud ka managed platform
Is path mein tum cloud provider (AWS, GCP, Azure) ke AI platform service use karte ho — Bedrock, Vertex AI, Azure AI Foundry. Model wahi do providers ya open-weight options hain, par sewa tumhare cloud account ke andar chalti hai.
tumhari app ──cloud-internal──▶ managed AI platform (tumhara account)
│
identity: roles / service accounts / managed identity
network: private path mumkin, public egress rok sakte ho
billing: tumhare cloud bill mein, tags se attribution
audit: cloud audit log mein har invoke recorded
- Identity cloud-native: API key ki jagah roles, service accounts, workload identity — least privilege cloud ke apne tools se lagti hai.
- Data path control: private connectivity se request public internet pe nahi jaati; region bhi tum chunta ho.
- Bill consolidation: model ka kharcha tumhare cloud bill mein — finance ko ek jagah, tags se team-wise split.
- Catalog, par apne account mein: closed models bhi, open-weight models bhi ek hi catalog mein — swap karna configuration jaisa hota hai.
Raasta 3 — open weights, hosting ke saath
# Open weights ka matlab: model files tumhare paas aa sakte hain
# Inference teen tarikon se:
# 1. Serverless inference provider — per token pay, GPU kabhi dikhta nahi
resp = provider.chat(model="open-weights-model", messages=msgs)
# 2. GPU platform — tum serving stack laate ho, wo hardware schedule karte hain
# (vLLM / TGI container tumhara, scaling unki)
# 3. Apne GPUs — poori control, poori responsibility
# vLLM serve open-weights-model --port 8000
- Open weights = files + licence, GPU nahi: model ke daam (weights) khule hain — lekin unhe chalane ke liye GPU chahiye, aur wo GPU khud ka ho ya kiraye ka, ye alag decision hai.
- Data boundary: weights tumhare boundary mein, inference tumhare control mein — sensitive data ke liye ye sabse strong guarantee hai.
- Version control: kaunsa checkpoint chal raha hai, wo tum decide karte ho — platform kabhi version khud retire nahi karega tumhare bina poochhe.
- Operations: batching, scaling, GPU utilisation, updates — sab tumhara ya tumhara hosting partner ka.
Teen raaston ka comparison — kis param pe kya
param public API managed platform open weights
---------------------------------------------------------------------
data jaati hai provider ke tumhara account tumhara boundary
servers pe (cloud ke andar) (khud ya partner)
identity API key cloud roles cloud roles ya VM creds
region control provider ki marzi tum chunte ho poori tumhari
price model per token per token / per GPU-hour ya
committed per token (provider)
ops effort zero kam sabse zyada
naye models sabse pehle catalog lag checkpoint aane do
billing alag invoice cloud bill + tags hardware bill
- Identity: API key se cloud roles — audit aur rotation dono behtar hote hain.
- Data handling: public internet vs cloud-internal vs tumhara pura boundary — risk appetite isi column se decide hota hai.
- Price per token: teeno paths mein billing model alag hai — per token, committed capacity, ya per GPU-hour. Volume ke hisaab se winner badalta hai (agle lessons mein exact math).
- Model freshness: public API pe naye model sabse pehle; managed catalog thoda peeche; open weights checkpoint aane par turant — par evaluation tumhari.
Platform, gateway, ya dono
Ek sawaal aksar confusion deta hai — managed platform aur model gateway ek hi cheez hain? Nahi. Gateway ek aisa layer hai jo bahut se providers ke peeche baith kar ek deta hai — ek endpoint, ek request format, ek usage view. Platform tumhare cloud ka AI service hai. Teeno combinations mumkin hain:
- Platform hi gateway hai: cloud platform ka apna unified endpoint hi sab model ke liye ek format leta hai — chhote setup ke liye kaafi.
- Platform gateway ke peeche: team ek self-hosted proxy (LiteLLM jaisa) lagati hai jo platform aur doosre providers dono ko route kare — flexibility chahiye toh.
- Platform gateway ke aage ek provider hai: gateway kai providers ko route karta hai, aur unmein se ek managed platform ho sakti hai.
Exercise
Question: Regulated team sabse pehle kaunsa raasta reject karti hai, kyunki data unke account se bahar jaata hai?
Question: Managed platform ka matlab — model tumhare cloud account ke andar chalta hai ya provider ke apne servers pe?
Question: Open weights chalane ke liye apne GPUs khareedne honge hi — ye baat true hai ya false? (serverless providers open weights bhi serve karte hain)
Question: Naye models sabse pehle kaunse raaste par aksar milte hain — public API, managed platform, ya open weights checkpoint?
Common mistakes
- Quality pehle, compliance baad mein: Best model chun kar architecture bana li, phir security review mein pata chala data hi nahi bhej sakte. Fix: pehle identity-data-region constraints likho, phir unke andar model choose karo.
- Open ko free samajhna: Open weights ka licence, hosting ka GPU kharcha aur operations ka time — teeno alag cost hain. Fix: per-token vs per-GPU-hour math apne volume pe chalao, assumption pe nahi.
- Sirf per-token price se decide karna: Price ek column hai, poori table nahi. Identity, audit, residency aur ops effort bhi cost hain — hidden wali. Fix: saate columns bharo decision se pehle.
- Platform aur gateway ko ek samajhna: Platform cloud service hai, gateway routing layer hai. Confusion se architecture galat ban jaata hai. Fix: pehle poochho — mujhe boundary chahiye ya routing flexibility?
Bijli bhi teen tarike se milti hai — seedha grid connection (public API), society ka common inverter jo tumhari building ke andar hai (managed platform), ya apna khud ka generator (open weights). Generator par control poora tumhara hai par service tumhara kaam hai:
grid connection -> bijli board ka bill, line kabhi kabhi gayab
society inverter -> andar hi andar, society ke rules se
apna generator -> load tumhara, maintenance bhi tumhara
sawaal: aapko bijli chahiye ya generator chalana seekhna hai?- Q: Model consume karne ke teen raaste batao? — Public API, managed platform in your cloud, open weights (self-hosted ya inference provider).
- Q: Regulated team public API kyun avoid karti hai? — Data unke boundary se bahar jaata hai, audit aur residency control kam hota hai.
- Q: Open weights ka matlab kya hai? — Model ke parameters khule hain, licence ke saath; GPU khud ka ya kiraye ka ho, ye alag decision hai.
- Q: Managed platform aur gateway mein farq? — Platform cloud ka AI service hai; gateway ek routing layer hai jo kai providers ke peeche ek endpoint deta hai.
Teeno raaste clear — ab tum kisi bhi workload ko sahi consumption path par place kar sakte ho. Agla lesson — Platform Anatomy — mein Bedrock, Vertex AI aur Azure AI Foundry ki andar ki structure dekhenge.