What Are LLM APIs? How They Work, With Examples
So, what are llm apis? They are web services that let your code send text to a large language model and get generated text back, using ordinary HTTP requests instead of a chat window.
Updated

The idea in one paragraph
A large language model is a program that predicts text. Running one yourself needs a powerful GPU, a lot of memory and some operations work. An LLM API puts that program behind a web address. Your application sends a request over HTTPS, the provider runs the model on its hardware, and the answer comes back a moment later. You never see the model weights, and you do not manage servers.
From the developer's side, an LLM API looks like any other web API. There is a URL, a secret key that identifies you, a JSON body that describes what you want, and a JSON response. The difference is that the work behind the URL is text generation, and the price is based on how much text goes in and comes out.
If you have ever used a chat website, you have already seen the result. Typing a question into a chat box and watching an answer appear is the same exchange, except the website made the API call for you. When you call the API directly, you decide what the prompt says, how the answer is used and where it ends up: in a script, a game, a support tool, a writing app or a pipeline that processes thousands of files overnight.
This site offers one such API. It is hosted, OpenAI-compatible and text only, and it serves a single open-weight model tuned to answer without content refusals for lawful adult use. The rest of this page uses it for examples, but the concepts apply to nearly every provider of chat models.
What a request contains
Most LLM APIs follow the chat completions format that OpenAI popularised. You send a POST request to /v1/chat/completions with a JSON body. Three parts matter most.
- model: which model should answer. On this service the ID is
uncensored. - messages: the conversation so far, as a list of objects with a
roleandcontent. - options: settings such as
temperature,max_tokensandstream.
The roles are simple. system sets standing instructions, like a persona or a format. user is what the person asked. assistant is what the model said earlier. A tool role is used when your code returns the result of a function call. Here is a complete request in curl:
curl https://api.hermesllmapi.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [
{"role": "system", "content": "You explain things in plain words."},
{"role": "user", "content": "What is a base URL?"}
],
"temperature": 0.5,
"max_tokens": 200
}'
The Authorization: Bearer header carries your key. That key is how the provider knows whose balance to charge, so treat it like a password: keep it out of public repositories and browser code.
What comes back
The response is JSON too. The part you care about is the first item in choices, and the token counts live in usage. The values below are illustrative, since your exact text and numbers will differ:
{
"id": "chatcmpl-example",
"object": "chat.completion",
"model": "uncensored",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A base URL is the common starting address for all of an API's endpoints."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 31,
"completion_tokens": 19,
"total_tokens": 50
}
}
finish_reason tells you why the model stopped: stop means it finished naturally, and length means it ran into a token limit. The usage block is the basis for your bill. This service also returns headers such as X-Request-Id, useful when you contact support, and X-Balance-USD, which shows your remaining credit.
Base URL, key and model: the three settings
Every client library for an LLM API asks for the same few values, and knowing them lets you switch tools quickly.
Base URL
This is the address prefix shared by all endpoints. Here it is https://api.hermesllmapi.com/v1. The client adds paths such as /chat/completions and /models to it. When a tool has a field named API base, OpenAI base URL or custom endpoint, this is where it goes.
API key
A secret string created in your account. You send it as a bearer token. New users can claim $0.50 of trial credit on the API key page, with no card needed.
Model ID
A name that selects the model. The list of available IDs comes from GET /v1/models. Here it contains uncensored.
The phrase OpenAI-compatible means the request and response shapes match OpenAI's, so any OpenAI SDK or compatible app works after you change those three values. It does not mean the model is made by OpenAI. This service is an independent provider and is not the official API of OpenAI, Meta, Mistral, Qwen, DeepSeek, xAI, Google, Anthropic or any other vendor. The documentation has copy-paste setup for Python and Node.
Why you resend the whole conversation
A beginner's surprise is that LLM APIs are stateless. The server does not remember your last call. If you want a chatbot to recall what was said two turns ago, your code must include those turns in the messages list of the next request.
from openai import OpenAI
client = OpenAI(base_url="https://api.hermesllmapi.com/v1", api_key="YOUR_API_KEY")
history = [{"role": "system", "content": "You are a friendly tutor."}]
def chat(user_text):
history.append({"role": "user", "content": user_text})
r = client.chat.completions.create(model="uncensored", messages=history)
reply = r.choices[0].message.content
history.append({"role": "assistant", "content": reply})
return reply
print(chat("What is an API?"))
print(chat("Give me a one-line example."))
The second call works because history now holds the first question and answer. This design has a cost consequence: longer conversations mean more input tokens on every call. It also has a limit. The context window here is 100,000 tokens, counting the prompt and the reply together. Past that point you must shorten the history, for instance by summarising older turns.
Features beyond plain chat
Modern LLM APIs add options on top of the basic call. This service supports the ones most projects need:
- Streaming. Set
stream: trueand the reply arrives piece by piece as server-sent events, with token usage at the end. Chat interfaces use this so text appears while it is being written. - Tool calling. You describe functions with
tools, the model answers with atool_callsrequest, your code runs the function, and you send the result back as arole: "tool"message. This is how model-driven agents work. - JSON mode.
response_format: {"type":"json_object"}makes the model return valid JSON, handy for extraction tasks. - Sampling controls.
temperature,top_p,stop,seedand the penalties are passed through.
What it does not do is also worth knowing. It is text only: no image, audio or video generation, no embeddings and no fine-tuning. If a project needs those, plan to pair this service with another one.
Limits, errors and cost
Every API caps how fast you can call it. On a full key here you get 8 concurrent requests and 300 requests per minute, and a trial key gets 2 and 60. If you exceed them the API replies with HTTP 429 and a code: rate_limited for requests per minute, concurrency for too many at once. A temporary overload also returns 429 with a Retry-After: 5 header, which means wait five seconds and try again. The maximum request body is 8 MB.
Cost is counted in tokens, small chunks of text, each roughly three quarters of an English word long on average. The price is $0.15 per 1M input tokens and $0.50 per 1M output tokens, paid from prepaid credit with no subscription. As a quick example, a call with 1,000 input tokens and 300 output tokens costs 0.001 x $0.15 + 0.0003 x $0.50 = $0.00015 + $0.00015 = $0.0003. Failed or refused requests are not charged. See the pricing page for top-ups, which run from $20 to $500 with bonuses from $50.
When should you choose a hosted API over running a model yourself? A hosted API wins when you want no hardware to manage, usage that is spiky, and a quick start. Self-hosting can make sense when you need full control over weights and infrastructure, or have steady heavy traffic and a team to run it. Prompts sent to this service are not used for training, which is worth comparing across any providers you consider.
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 it that your code calls to generate text.
Do I need to be a machine learning expert to use one?
No. If you can send an HTTP request or use a client library such as the OpenAI SDK, you can use an LLM API.
What does OpenAI-compatible mean?
The API accepts and returns the same JSON formats as OpenAI's, so OpenAI SDKs and apps work after you change the base URL and key. It does not mean the model comes from OpenAI.
Does the API remember my previous messages?
No. It is stateless, so your code sends the relevant conversation history with each request.
How is an LLM API priced?
By tokens. Here input costs $0.15 per 1M tokens and output costs $0.50 per 1M tokens, paid from prepaid credit.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.