What Is an LLM API? How It Works and When to Use One
An LLM API is a web service that runs a large language model for you. Your code sends text over HTTP, the model sends text back, and you pay for what you use.
Updated

Key points
- An LLM API is an HTTP endpoint: you POST messages, you receive a completion.
- Billing is per token, counted separately for input and output.
- OpenAI-compatible APIs share one request format, so switching providers is mostly a base URL change.
- Streaming, tool calling and JSON mode turn a plain chat endpoint into a building block for real software.
The short version
So, what is an LLM API? It is a service that exposes a language model through a web address. You do not download the model, you do not own a GPU, and you do not manage inference software. You send a request that contains a conversation, and the service returns the next message in that conversation.
Think of it the way you think of a payment API or a maps API. Somebody else runs the hard infrastructure, and you call it from your own program with a key that identifies you. The model is the product, and the API is the door to it.
That door is plain HTTP with JSON bodies, which means it works from Python, Node, Go, a shell script, a spreadsheet macro or a VS Code extension. Nothing about it is tied to one language or one framework.
How a request and response look
Most LLM APIs today copy the shape that OpenAI introduced for chat. You call one endpoint, POST /v1/chat/completions, and send a list of messages. Each message has a role and some content.
systemsets the rules and the persona for the whole conversation.useris what the person (or your program) says.assistantis what the model said earlier, which you send back so it remembers the thread.toolcarries the result of a function the model asked you to run.
The key detail is that the model has no memory between calls. Every request must carry the whole conversation you want it to consider. If you want a chatbot that remembers the last ten turns, your code stores those ten turns and sends them each time.
Here is the smallest useful call with curl. It uses this site's endpoint, the model ID uncensored, and a bearer token.
curl https://api.codingllmapi.com/v1/chat/completions \
-H "Authorization: Bearer $LLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Explain what a mutex is in two sentences."}
]
}'
The response is JSON. The text you want sits at choices[0].message.content. Next to it you get a usage object that reports how many tokens went in and how many came out, which is what the bill is based on.
Tokens: the unit everything is measured in
A model does not read characters or words. It reads tokens, which are chunks of text that are often a short word or a piece of a longer one. English prose averages a bit under one token per word, and code tends to use more tokens per line because of punctuation and indentation. Treat any exact conversion as an estimate and read the usage field for the real count.
Tokens matter for three reasons.
- Price. You pay per million tokens, with one rate for input (your prompt) and a higher rate for output (the model's answer).
- Context window. The prompt and the answer share one limit. On this API the window is 100,000 tokens in total.
- Speed. Output is produced one token after another, so a long answer takes longer than a short one.
With the rates on this site, $0.15 per 1M input tokens and $0.50 per 1M output tokens, a request with 2,000 input tokens and 500 output tokens costs 2,000 x $0.15 / 1,000,000 = $0.0003 for input plus 500 x $0.50 / 1,000,000 = $0.00025 for output. That is $0.00055 in total, so a thousand such requests cost $0.55. Current rates always live on the pricing page.
Calling an LLM API from code
You can write the HTTP call by hand, but an SDK saves effort. Because this API is OpenAI-compatible, the official OpenAI libraries work after you change two values: the base URL and the key.
Python
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.codingllmapi.com/v1",
api_key=os.environ["LLM_API_KEY"],
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a careful code reviewer."},
{"role": "user", "content": "What is wrong with: for i in range(len(x)): print(x[i])"},
],
temperature=0.3,
)
print(resp.choices[0].message.content)
print(resp.usage.prompt_tokens, resp.usage.completion_tokens)
Node
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.codingllmapi.com/v1",
apiKey: process.env.LLM_API_KEY,
});
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Give me three names for a CLI that renames files." }],
});
console.log(resp.choices[0].message.content);
Keep the key in an environment variable or a secret store. A key pasted into front-end code or a public repository can be used by anyone who finds it, and the charges land on you.
Features that turn a chat box into a building block
A bare completion is useful, but most real programs use at least one of the following.
Streaming
Set stream: true and the server sends the answer as server-sent events, token by token. Users see text appear right away instead of waiting for the full reply. Usage figures arrive at the end of the stream.
JSON mode
Pass response_format: {"type": "json_object"} and the model is steered to return valid JSON. This is how you extract fields from messy text, classify tickets or produce structured data for the next step in a pipeline. Still validate the result in your code and tell the model in the prompt which keys you expect.
Tool calling
You describe functions in the tools array. The model may answer with a request to call one, with arguments filled in. Your code runs the function and sends the result back as a message with role: "tool". The model never executes anything itself. It only asks, and you decide what actually runs. This is the mechanism behind coding agents that read files and run tests.
Sampling controls
temperature, top_p, stop, seed and the repetition penalties are passed through. Low temperature gives steadier answers for code and extraction. Higher values give more varied prose.
Hosted API or running a model yourself
The alternative to an API is to run an open-weight model on your own hardware. That is a fair choice, and it is worth being honest about when it wins.
| Question | Hosted API | Self-hosted |
|---|---|---|
| Upfront cost | None, you pay per token | GPU purchase or rental |
| Setup time | Minutes | Hours to days |
| Scaling | Limited by your key's rate limits | Limited by your hardware |
| Data leaves your machine | Yes, to the provider | No |
| Idle cost | Zero | You pay even when nothing runs |
If you send a few thousand requests a day, or your usage is bursty, per-token pricing is usually the easier path. If you have steady heavy load and strict rules that forbid sending text to any third party, local hosting can make more sense. Many teams start on an API to validate the idea and revisit the question later.
Limits, errors and good habits
Every API has limits, and knowing them early saves debugging time. On this service a full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 and 60. The maximum request body is 8 MB. A streamed request keeps its concurrency slot until the stream finishes, which catches people who open many streams and forget to close them.
Going over a limit returns HTTP 429. The error code rate_limited means too many requests per minute, and concurrency means too many at once. A 429 with a Retry-After: 5 header signals temporary overload. In all three cases the right response is to wait and retry with backoff, not to hammer the endpoint.
- Read
X-RateLimit-Limit-RequestsandX-RateLimit-Limit-Concurrencyfrom response headers to see your ceilings, andX-Balance-USDto watch your credit. - Log
X-Request-Idwith every call. It makes support questions much faster to answer. - Set a sensible timeout and cap on conversation length so a runaway loop cannot spend your balance.
- Trim old turns of a chat before they fill the context window.
Failed or refused requests are not charged on this API, and credit does not expire, so a mistake in testing costs little.
Getting started with this API
This service is a hosted, OpenAI-compatible text API for one open-weight model, run by an independent provider and tuned to answer without content refusals for lawful adult use. It is text only: no images, audio, embeddings or fine-tuning. It is not the official API of any model vendor. Prompts are not used for training.
New users can claim $0.50 of trial credit with one click on the API key page after signing up with Google or with email and password. It needs no card and lasts 7 days. After that you top up with any whole amount from $20 to $500, with a bonus of 5% from $50, 10% from $100 and 15% from $200. You can pay by card (Visa, Mastercard, Apple Pay, Google Pay) or with crypto (USDT on TRC20, USDC on Base).
The steps are short: create your API key, follow the quickstart in the docs, and run the Python snippet above. If your main use is programming help, the page on an uncensored model for coding agents covers that case in more detail.
More guides
Questions and answers
Is an LLM API the same as a chatbot?
No. A chatbot is an application with an interface. An LLM API is the service behind such an application, and you call it from your own code to build the interface or workflow you want.
Do I need to know machine learning to use one?
No. If you can send an HTTP request or use an SDK, you can use an LLM API. You need to understand prompts and tokens, but not how the model was trained.
What does OpenAI-compatible mean?
It means the API accepts the same request format as OpenAI's chat endpoint. Existing OpenAI SDKs and tools work after you change the base URL and the key.
How much does an LLM API cost?
Providers usually charge per million tokens, with separate rates for input and output. Here it is $0.15 per 1M input tokens and $0.50 per 1M output tokens, from prepaid credit with no subscription.
Is my data used to train the model?
On this service, prompts are not used for training. For any other provider, read their data policy before sending sensitive text.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.
Get API key