API design and inference serving
Design validated and resilient interfaces for model-backed services.
Validate inputs, enforce quotas and monitor latency before exposing inference publicly.
Interview questions
Choose a question to reveal its answer.
01EasyCoreWhat does REST mean for API design?
Answer
What does REST mean for API design?
Architectural style centered on resources, stateless interactions and uniform interfaces.
Expose a prediction resource with documented HTTP behavior.
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Input(BaseModel):
value: float
@app.post('/predict')
def predict(data: Input):
return {'prediction': data.value * 2}Minimal typed endpoint; add authentication and operational controls for deployment.
02EasyCoreWhen should an inference endpoint use POST?
Answer
When should an inference endpoint use POST?
Method commonly used to submit data or create processing requests.
Send an inference input in a request body.
03EasyCoreWhy validate inference requests with Pydantic?
Answer
Why validate inference requests with Pydantic?
Uses declared models to parse and validate Python data.
Reject malformed request fields before running inference.
04MediumHigh priorityHow do you authenticate API callers?
Answer
How do you authenticate API callers?
Establishes the identity of a caller.
Verify a signed session token on a request.
05MediumHigh priorityHow does authorization differ from authentication?
Answer
How does authorization differ from authentication?
Decides whether an identified caller may perform an action.
Permit a user to read only their own saved tests.
06MediumWhy apply rate limits to model inference?
Answer
Why apply rate limits to model inference?
Restricts request frequency or consumption per identity or other key.
Protect expensive inference from bursts of requests.
07MediumHow do streaming responses improve perceived latency?
Answer
How do streaming responses improve perceived latency?
Sends response data incrementally instead of waiting for the complete result.
Deliver generated text as tokens arrive.
08MediumWhy set timeouts on upstream model calls?
Answer
Why set timeouts on upstream model calls?
Maximum duration allowed for an operation before cancellation or failure handling.
Stop waiting indefinitely for an unavailable upstream service.
09HardWhat should an inference cache key include?
Answer
What should an inference cache key include?
Stores reusable results under an appropriate key and expiration policy.
Reuse embeddings for identical normalized input and model version.
10HardWhen should a model workload run in a background queue?
Answer
When should a model workload run in a background queue?
Decouples long-running work from synchronous request handling.
Submit a model training job and poll its status.
11MediumHigh priorityHow do you make a retryable POST request idempotent?
Answer
How do you make a retryable POST request idempotent?
Client-supplied identifier used to recognize repeated requests and avoid duplicate effects.
Retry a test submission after a network timeout without inserting another attempt.
12MediumHigh priorityWhat HTTP status should an API return for rate limiting?
Answer
What HTTP status should an API return for rate limiting?
Status indicating that the caller has exceeded a request limit under the server's policy.
Return an appropriate response when a quota is exhausted.
13MediumHigh priorityWhy should large API collections be paginated?
Answer
Why should large API collections be paginated?
Returns a bounded subset of results using a cursor or offset and a limit.
Fetch test history in manageable pages.
14MediumHigh priorityHow can you evolve an API without breaking clients?
Answer
How can you evolve an API without breaking clients?
Manages compatibility as request and response contracts evolve.
Add an optional response field without breaking existing clients.
15MediumHigh priorityHow do liveness and readiness checks support reliable deployment?
Answer
How do liveness and readiness checks support reliable deployment?
Endpoint or probe indicating service liveness or readiness according to specified criteria.
Exclude a worker that cannot load its model from traffic.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.
1. Which status code indicates a request limit was exceeded?
2. What should a server do with malformed inference payloads?
3. Which pattern suits an hour-long training job?
Authentication and secure AI APIs
Continue to the next set of interview questions.