How to Use an LLM: A Practical Guide for Developers
Using a large language model comes down to three things: getting access to one, sending it well-structured input, and handling the output correctly in your product. For casual use, that means typing into a chat interface. For building anything real — a feature, a bot, an internal tool — it means calling an API, managing prompts, and dealing with streaming, errors, and cost.
This guide covers both, but focuses on the part most people actually search for once they move past "chatting with a bot": how to integrate an LLM into code you control.
Two ways to use an LLM
Chat interface. You open a web app (Claude, ChatGPT, Gemini, etc.), type a question, and read the answer. No setup, no code. Good for research, writing help, debugging a snippet, or brainstorming. This is where most people start, and it's fine for one-off tasks.
API access. You send requests programmatically and get structured responses back — text, JSON, tool calls — that your application uses directly. This is what you need if you're building a feature: a support bot, a document summarizer, a code review assistant, a data extraction pipeline. The rest of this article is about this path.
Step 1: Get API access
Most LLM providers require a separate API account, billing setup, and key management, even if you already pay for a chat subscription. That's an extra account to create and an extra invoice to track.
Some tools solve this by exposing your existing Claude access as a normal HTTPS API instead of making you sign up separately. SubToAPI does this: you get an application key (sub_live_...), a dashboard for usage, and team seats, without opening a second billing relationship with the model provider. Sign up at /signup and follow the quickstart to get your first key.
Whichever provider you use, you'll end up with:
- An API key or token
- A base URL for requests
- Rate limits and usage quotas tied to your plan
Step 2: Send your first request
Every LLM API follows roughly the same shape: you send a list of messages (system instructions plus user/assistant turns), and you get back generated text. Here's what that looks like with SubToAPI's Messages API:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-sonnet",
"max_tokens": 300,
"messages": [
{"role": "user", "content": "Explain what a race condition is, in two sentences."}
]
}'
The response contains the model's reply plus usage metadata (input/output token counts), which you need for cost tracking. See /docs/messages for the full request/response schema.
Step 3: Write a clear system prompt
The single biggest lever for output quality is the system prompt — the instructions that set the model's role, tone, and constraints before it sees the user's message.
A good system prompt:
- States the task plainly ("You summarize support tickets into three bullet points")
- Specifies format ("Respond in JSON with keys
summary,priority,tags") - Sets boundaries ("If the ticket is not in English, translate the summary")
- Gives one or two examples if the format is unusual
Avoid vague instructions like "be helpful and smart." Specificity gets you consistent output; vagueness gets you variance.
Step 4: Handle streaming for interactive use
If you're building anything a user waits on — a chat UI, a live assistant — stream the response instead of waiting for the full completion. Streaming sends tokens as they're generated, so the user sees text appear immediately instead of staring at a spinner.
const response = await fetch("https://api.subtoapi.app/v1/messages", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "claude-3-5-sonnet",
max_tokens: 500,
stream: true,
messages: [{ role: "user", content: "Write a short changelog entry for a bug fix." }]
})
});
const reader = response.body.getReader();
// read chunks and append to your UI as they arrive
Details on event format and error handling are in /docs/streaming.
Step 5: Let the model use tools when needed
LLMs can't look things up or take actions on their own — but they can call functions you define, and you execute them. This is how you connect a model to a database, a search index, or an internal API.
You define a tool schema (name, description, input parameters), the model decides when to call it, and your code runs the actual logic and returns the result. This pattern — often called function calling or tool use — is what turns a text generator into something that can check inventory, book a meeting, or query a ticketing system. See /docs/tools for schema examples and multi-turn tool call flows.
Step 6: Manage cost, limits, and reliability
Once you're past a prototype, three things matter:
- Token usage. Track input and output tokens per request; they determine cost. Trim unnecessary context and cap
max_tokensto avoid runaway bills. - Rate limits. Know your plan's request-per-minute ceiling and handle 429 responses with backoff.
- Team access. If more than one person or service needs a key, use separate keys per environment (dev/staging/prod) and per team member rather than sharing one. SubToAPI's Team and Scale plans support per-seat keys for exactly this.
Common mistakes to avoid
- Sending the entire conversation history on every request without trimming — costs grow linearly and you'll hit context limits.
- Skipping error handling for rate limits and timeouts, which are normal at scale, not edge cases.
- Using one shared API key across a whole team, which makes usage impossible to attribute or limit.
Questions
Do I need to know how to code to use an LLM? No. Chat interfaces require no code at all. Coding is only necessary if you want to embed the model in an app, automate a workflow, or connect it to your own data and tools via an API.
What's the difference between using an LLM in a chat app versus an API? A chat app is a finished product with a UI built around one model. An API gives you raw programmatic access — you control the prompts, formatting, streaming, and integration with your own systems.
How do I keep LLM costs predictable? Set a max_tokens cap on responses, trim conversation history you send each request, and monitor token usage per key. Flat per-seat pricing, like SubToAPI's plans, also makes budgeting more predictable than raw token billing.