Framework or thin client: picking the right layer for your AI project

APIFreeGroqKey · Updated 2026-11-22 · 8 min read

Box of construction bricks beside a carved wooden piece
Frameworks give you ready parts; the plain SDK gives you raw material.

Showcase projects built on fast inference APIs often list an impressive stack: a voice assistant on LangChain with FastAPI, a multi-agent code reviewer on LangGraph with retrieval and a specialised code model, a document agent with long-term memory. Newcomers reasonably conclude that a framework is the normal way to build with LLMs. Experienced developers are often more divided; plenty of production apps call the model through a thin client and a few hundred lines of their own code.

This comparison is for developers starting an LLM project, or reconsidering one, who want to choose between a framework such as LangChain or LangGraph and the plain OpenAI-compatible SDK. We compare them on learning curve, flexibility, debugging, multi-step agents and provider switching, show the same task both ways, and suggest when each is the better fit. The examples run against the keyless free-ai endpoint on this site and work with Groq or other providers through configuration.

Frequently asked questions

What is LangChain?

LangChain is an open-source framework that provides building blocks for LLM applications: model wrappers, prompt templates, output parsers, retrievers, tool integrations and ways to chain them. It supports many providers behind a common interface.

How does LangGraph differ from LangChain?

LangGraph, from the same ecosystem, focuses on stateful multi-step workflows modelled as graphs of nodes and edges, with explicit state passed between steps. It suits agents and multi-agent systems where control flow, loops and checkpoints matter.

What does the plain SDK mean here?

Using the official OpenAI client library, or plain HTTP, to call any OpenAI-compatible endpoint directly. You write prompts, parsing, retries and orchestration yourself, with full visibility into every request.

Which is better for beginners?

The plain SDK teaches what is actually happening: messages in, text out. Frameworks can feel faster at first, but their abstractions hide details that matter when something goes wrong. Many people learn on the SDK and adopt a framework later for specific needs.

Can I switch providers easily with either?

Yes. Frameworks wrap many providers behind one interface. The plain SDK works with any OpenAI-compatible service by changing the base URL, key and model. For providers that use other formats, a framework saves more work.

Do frameworks slow down requests?

The overhead per call is small compared with model latency. Slowdowns usually come from hidden extra calls, such as automatic retries, output-fixing passes or verbose agent loops, which you may not notice without tracing.

Is it possible to mix both?

Yes, and it is common. Teams use plain SDK calls for simple features and a framework for one complex agent workflow, or use only a framework's retrievers or document loaders while handling model calls themselves.

Do frameworks work with models that refuse less?

Yes. A framework does not change the model's behaviour; it only builds the requests. Any OpenAI-compatible model, including free-ai with its two hard rules, can sit behind a framework wrapper or a plain client in exactly the same way.

What each approach gives you

A framework gives you vocabulary and parts. Prompt templates, chains, retrievers, memory helpers, tool-calling agents and integrations with vector stores and document loaders all come ready to plug together. For common patterns, especially retrieval and tool use, you can get a demo running quickly, and the community has examples for nearly everything.

The plain SDK gives you one function: send messages, get a response. Everything else is your code. That sounds like more work, and for some features it is, but the code does exactly what you wrote and nothing else. For many apps, the extra code is smaller than expected, because the core of most LLM features is a prompt, a call and some parsing.

The abstraction trade

Every abstraction saves typing and costs visibility. When a chain produces a bad answer, you need to see the exact prompt the model received. Frameworks provide tracing tools for this, but it is one more thing to learn and run.

Integrations are the real draw

For many teams the deciding factor is not chains but connectors: loaders for dozens of file types, adapters for vector stores and ready tool wrappers. If you need many of those, a framework saves a lot of glue code.

The same task, two ways

Consider a tiny feature: summarize a support ticket into one sentence and a priority label. With the plain SDK, it is a system prompt, a call and a split. With LangChain, it is a chat model wrapper, a prompt template and an invoke call. Both are short; the difference is in what is hidden.

What the comparison shows

For single calls, neither is meaningfully shorter. The framework's value appears when you compose many steps, swap retrievers or reuse integrations. For a single feature like this, the plain SDK has fewer dependencies and nothing to upgrade.

# Plain SDK
from openai import OpenAI

client = OpenAI(base_url="https://api.apifreegroqkey.com/v1", api_key="free")
ticket = "The export button does nothing since this morning and our report is due at 5pm."

r = client.chat.completions.create(
    model="free-ai",
    temperature=0,
    messages=[
        {"role": "system", "content": "Summarize the ticket in one sentence, then a new line with LOW, MEDIUM or HIGH."},
        {"role": "user", "content": ticket},
    ],
)
summary, _, priority = r.choices[0].message.content.strip().rpartition("\n")
print(summary, "|", priority)

# LangChain (pip install langchain-openai langchain-core)
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate

llm = ChatOpenAI(base_url="https://api.apifreegroqkey.com/v1", api_key="free", model="free-ai", temperature=0)
prompt = ChatPromptTemplate.from_messages([
    ("system", "Summarize the ticket in one sentence, then a new line with LOW, MEDIUM or HIGH."),
    ("user", "{ticket}"),
])
result = (prompt | llm).invoke({"ticket": ticket})
print(result.content)
Two open notebooks with sketches side by side
The same feature written two ways reveals what each approach hides.

Learning curve and documentation

The OpenAI-style API is small and stable: a handful of parameters, a message list and a response object. Once you know it, you know how to call dozens of providers. Frameworks have a much larger surface area, and fast-moving ones change their recommended patterns between versions, so tutorials from a year ago may use deprecated interfaces.

That churn is a real cost for small teams. Pin versions, read the changelog before upgrading, and prefer the framework's current recommended patterns over older blog posts.

Know the underlying API anyway

Even if you use a framework, learn the raw request format. Debugging, reading provider docs and handling errors such as 429 rate limits all require it.

Team familiarity counts

If everyone on the team already knows a framework well, its learning cost is gone and its conventions help code reviews. If nobody does, the plain SDK lets the team move without a learning detour.

Multi-step agents and orchestration

Frameworks shine most in complex orchestration. A multi-agent code review system, for example, might have one agent that retrieves related files, another that checks style, another that looks for bugs and a final one that merges findings. Modelling this as a graph with explicit state, checkpoints and conditional edges is exactly what LangGraph was designed for, and building that machinery yourself takes effort.

On the other hand, many agents are simpler than they look: a loop that calls the model, runs a tool if requested and repeats until done. That loop is about thirty lines with the plain SDK, and writing it yourself makes the behaviour easy to follow.

When the graph earns its keep

Branching workflows, human approval steps, resumable long-running tasks and many cooperating agents are where a graph framework saves real time and bugs.

When a loop is enough

A single agent with a few tools, a retry on invalid output and a step limit rarely needs a framework. Keep it plain until the control flow genuinely becomes a graph.

Model railway with branching tracks
Graph frameworks suit workflows with branches, loops and checkpoints.

Debugging and observability

The most common complaint about frameworks is debugging. A chain fails or answers badly, and the cause is buried in a template, a parser or an automatic retry. Framework tracing tools help a lot, and serious users should run them, but they add moving parts.

With the plain SDK, you can log the exact messages you send and the exact text you get back in two lines. When a user reports a bad answer, you look at the logged request and usually see the problem immediately: a missing piece of context, a truncated document or an ambiguous instruction.

Hidden calls cost quota

Some framework components make additional model calls, for example to fix malformed output or summarize memory. On a rate-limited endpoint like the keyless one here, one request per second per IP, those extra calls can trigger 429 responses you did not expect.

  • Log full request messages and responses in development
  • Record token usage per call to spot hidden extra calls
  • Tag each call with a feature name for later analysis
  • Keep prompts in versioned files, not scattered strings

Provider switching and fast inference

Developers pick fast inference providers such as Groq for responsive assistants and voice apps. Groq offers an OpenAI-compatible endpoint, so both approaches work with it; frameworks also ship dedicated integrations. Check Groq's documentation for current models and rate limits. This site is not affiliated with Groq, and the keyless endpoint serves free-ai, an independent open-weight model of about 35B parameters, not one of Groq's hosted models.

With the plain SDK, switching between Groq, the keyless endpoint and a local server is a matter of three configuration values. With a framework, it is a different wrapper class or the same OpenAI-compatible wrapper with a different base URL. Either way, keep keys in environment variables and never commit them; for splitting traffic between providers, see our routing guide.

Voice assistants and latency

For voice apps, every hidden step adds delay before speech starts. Thin clients make it easier to stream the first sentence to text-to-speech immediately. Our article on time to first token explains why that first chunk matters most.

Inspection lamp lighting the gears of an open machine
Seeing the exact request makes debugging much faster.

Dependencies, security and long-term maintenance

Frameworks pull in many packages, which increases install size, upgrade work and exposure to supply-chain issues. For a small service, the plain SDK plus a web framework may be the entire dependency list. That matters for container size, cold start time in serverless functions and how often you need to react to security advisories.

Frameworks also evolve quickly. A project that is not upgraded for a year may need significant changes to catch up. Plain SDK code tends to keep working, because the underlying API format changes slowly.

Retrieval components are a good middle ground

Document loaders and text splitters from a framework can be used on their own while model calls stay plain. Our guide to building a document Q&A service shows a fully plain approach you can compare against.

Which should you choose?

Choose the plain SDK when the app has a few well-defined LLM features, when you value transparency and small dependencies, when you are learning, or when latency is critical. Choose a framework when you need many integrations, complex multi-step or multi-agent workflows with state and checkpoints, or when your team already knows it well.

Whichever you start with, keep prompts in files, log requests and test on real inputs. Those habits matter more than the library, and they make it straightforward to change your mind later.

Revisit the choice at milestones

A prototype on a framework can be simplified later, and a plain app can adopt a framework for one complex feature. Reassess when the app's shape changes, not only at the start.

  • Small app, few features: plain SDK
  • Learning LLM development: plain SDK first
  • Many data sources and tools: framework
  • Complex agent graph with human steps: graph framework
  • Latency-critical voice or game features: plain SDK with streaming
Small backpack beside a large suitcase on a platform
Pick the amount of luggage your project actually needs.
Try the free API

Send a request to the keyless free-ai endpoint from the home page and see how it fits your project, no sign-up needed.

Read also