Unit 01.01: When the provider SDK is the better choice
The framework earns its place when you are composing several pieces. For a single call it is a layer between you and a well-documented API.
Five situations, three of them plain SDK
Composition and provider-swapping are what the abstraction is for. One prompt, one response, one provider is not.
The code sorts five situations.
CASES = [
("one prompt, one response, one provider", "SDK",
"the framework adds a layer and saves nothing"),
("swap providers behind one interface", "LangChain", "that is the abstraction"),
("retrieval, parsing, and retries composed", "LangChain", "composition is the value"),
("a provider feature the abstraction lacks", "SDK", "you will fight the wrapper"),
("a one-off script you will delete", "SDK", "no future to design for"),
]
print(f"{'situation':44} {'use':10} why")
for situation, choice, why in CASES:
print(f"{situation:44} {choice:10} {why}")
sdk = sum(1 for _, c, _ in CASES if c == "SDK")
print(f"\n{sdk} of {len(CASES)} are better served by the provider SDK directly.")
# The fourth row is the one that hurts later. Abstractions expose the
# intersection of what providers offer, so a feature only one provider has is
# either missing or bolted on -- and you find out mid-project.
The fourth row is the one that hurts later. An abstraction exposes roughly the intersection of what providers offer, so a feature only one provider has is either missing from the interface or bolted on awkwardly - and you discover which halfway through a project.
The fifth is worth stating too. A script you will delete next week has no future to design for, and every abstraction is an investment in a future.
The mistake this prevents
The mistake is adopting the framework for a single call because you might need composition later. You might; adding it later is an afternoon, and the layer you carry in the meantime shows up in every stack trace.
Takeaway
Use the framework when composing or swapping providers. For one call against one provider, the SDK is fewer moving parts and a shorter stack trace.
