Best LLM API Guide
How to Use an LLM API: First Call to Streaming
Using an LLM API means sending a JSON list of messages over HTTPS and reading the reply. This guide takes you from a key to a first request, then to streaming, JSON output and tool calls.
Updated:

Key points
- The endpoint is OpenAI-compatible: change the base URL and key, keep your SDK.
- Use model ID uncensored and POST to /v1/chat/completions.
- Streaming, JSON mode and tool calling are all supported.
- A 429 means slow down; read the error code to know why.
What an LLM API call is
If you wonder how to use llm api services at all, the idea is small. You send an HTTPS POST with a list of messages. Each message has a role (system, user or assistant) and some text. The server runs the model and sends back the next assistant message. That is the whole contract.
The model has no memory between calls. If you want a conversation, you send the earlier messages again each time. This is why prompts grow, why cost grows with them, and why the 100,000-token context window matters: it is the limit on prompt plus reply together.
This service speaks the same protocol as the OpenAI Chat Completions API. Any OpenAI SDK or compatible client works once you change two things, the base URL and the key. Only text goes in and comes out. There is no image, audio or video generation and no embeddings endpoint.
A few terms are used throughout the rest of this guide. A token is a chunk of text, roughly three quarters of an English word on average. Input tokens are everything you send, and output tokens are what the model writes. You are billed on both, at different rates, and the response tells you exactly how many of each it used. A base URL is the address your client prepends to every path, and an API key is the secret that proves the request is yours. If you know those four words, the rest is routine.
Step 1: get a key and note three values
Create an account with Google, or with an email and password, and open the API key page. There you can copy your key and claim the $0.50 trial credit with one click. No card is needed for the trial.
You need three values for every request:
- Base URL:
https://api.bestllmapi.com/v1 - Model ID:
uncensored - Auth header:
Authorization: Bearer YOUR_KEY
Keep the key out of source control. Put it in an environment variable such as LLM_API_KEY and read it from there. Anyone who has the key can spend your credit.
Step 2: send a first request with curl
Curl is the fastest check that everything works, before any library is involved.
export LLM_API_KEY="paste-your-key-here"
curl https://api.bestllmapi.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 token is in two sentences."}
],
"temperature": 0.7
}'
The reply is JSON. The text is at choices[0].message.content, and a usage object lists prompt and completion tokens, which is what you are billed on. You can also list models with GET https://api.bestllmapi.com/v1/models; you should see uncensored.
The response headers help too. X-Request-Id identifies the call if you contact support, and X-Balance-USD shows what is left in your account.
Reading the response and choosing parameters
A response has a few fields worth knowing before you write any parsing code. choices is a list, and you almost always want the first item. Inside it, message.content holds the text, and finish_reason tells you why the model stopped. A value of stop means it finished naturally. A value of length means it hit your max_tokens cap or ran out of window, so the answer may be cut off mid-sentence.
The usage object gives prompt tokens, completion tokens and a total. Log these for every call from day one. They are the only reliable way to learn what your app really costs, and they make it easy to spot a bug that sends the same long prompt twice.
Choosing parameters is mostly a matter of task type. For extraction, classification and code, use a low temperature such as 0.2, so the same input gives nearly the same output. For brainstorming and stories, 0.8 to 1.0 gives more variety. Change one value at a time, and use seed when you want repeatable comparisons between two prompt versions.
Step 3: use the OpenAI SDK in Python or Node
In practice you will use a library. In Python, install it with pip install openai and point it at the new base URL.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.bestllmapi.com/v1",
api_key=os.environ["LLM_API_KEY"],
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Give me three names for a hiking app."},
],
temperature=0.8,
max_tokens=200,
)
print(resp.choices[0].message.content)
print(resp.usage.prompt_tokens, resp.usage.completion_tokens)
The Node version is nearly identical. Install with npm install openai.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.bestllmapi.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 hiking app." }],
});
console.log(resp.choices[0].message.content);
max_tokens is optional. If you leave it out, the reply may use whatever is left of the 100,000-token window, so set it when you want short answers. The sampling settings temperature, top_p, stop, seed and the penalties are passed through to the model.
Step 4: stream the reply
Without streaming, your user stares at a blank screen until the whole answer is ready. With stream: true the server sends tokens over Server-Sent Events as they are produced, and usage totals arrive at the end.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.bestllmapi.com/v1", api_key=os.environ["LLM_API_KEY"])
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Write a short product description for a desk lamp."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if getattr(chunk, "usage", None):
print("\nTokens:", chunk.usage.total_tokens)
One thing to remember: a streamed request holds its concurrency slot until the stream ends. A full key allows 8 concurrent requests, a trial key 2. If a user closes the tab, close the stream on your side too, or the slot stays busy.
Keeping a conversation going
Because the API has no memory, a chat app is a loop that appends to a list. The pattern below is the core of nearly every chatbot.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.bestllmapi.com/v1", api_key=os.environ["LLM_API_KEY"])
messages = [{"role": "system", "content": "You are a friendly travel planner."}]
while True:
user_text = input("You: ")
if user_text.strip().lower() in ("quit", "exit"):
break
messages.append({"role": "user", "content": user_text})
resp = client.chat.completions.create(model="uncensored", messages=messages)
answer = resp.choices[0].message.content
messages.append({"role": "assistant", "content": answer})
print("Bot:", answer)
Every pass resends the whole list, so cost per turn rises as the chat gets longer. The price is $0.15 per 1M input tokens and $0.50 per 1M output tokens. A turn with 2,000 input tokens and 400 output tokens costs 2,000 / 1,000,000 x $0.15 = $0.0003 plus 400 / 1,000,000 x $0.50 = $0.0002, so $0.0005. At that rate, the $0.50 trial covers about 1,000 turns.
When the list gets long, drop the oldest user and assistant messages but keep the system message at the top. Or ask the model to write a short summary of the early turns and replace them with it.
Step 5: JSON mode and tool calling
When your code needs to parse the answer, ask for JSON. Set response_format to {"type": "json_object"} and also say "JSON" in the prompt so the model knows what shape you want.
import os, json
from openai import OpenAI
client = OpenAI(base_url="https://api.bestllmapi.com/v1", api_key=os.environ["LLM_API_KEY"])
resp = client.chat.completions.create(
model="uncensored",
response_format={"type": "json_object"},
messages=[
{"role": "system", "content": "Reply only with JSON."},
{"role": "user", "content": "Extract name and city: 'Maria lives in Lisbon.' Use keys name and city."},
],
)
print(json.loads(resp.choices[0].message.content))
Tool calling lets the model ask your code to run a function. You describe the function in tools; the model replies with a tool_calls entry instead of text; you run the function and send the result back with role: "tool".
import os, json
from openai import OpenAI
client = OpenAI(base_url="https://api.bestllmapi.com/v1", api_key=os.environ["LLM_API_KEY"])
tools = [{
"type": "function",
"function": {
"name": "get_order_status",
"description": "Look up an order by its id",
"parameters": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
},
},
}]
messages = [{"role": "user", "content": "Where is order A-1042?"}]
first = client.chat.completions.create(
model="uncensored", messages=messages, tools=tools, tool_choice="auto"
)
msg = first.choices[0].message
if msg.tool_calls:
call = msg.tool_calls[0]
args = json.loads(call.function.arguments)
result = {"order_id": args["order_id"], "status": "shipped"}
messages.append(msg)
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps(result),
})
final = client.chat.completions.create(
model="uncensored", messages=messages, tools=tools
)
print(final.choices[0].message.content)
Models can produce malformed arguments now and then, so wrap json.loads in a try block in real code and send an error back as the tool result if parsing fails.
When something goes wrong
Most first-day problems are one of these.
- 401 or authentication error: the key is missing, has a typo, or the header is not in the form
Bearer KEY. - 404: the base URL is missing
/v1, or you called the wrong path. The chat path is/v1/chat/completions. - 429 with code
rate_limited: you passed the requests-per-minute limit (300 on a full key, 60 on a trial key). - 429 with code
concurrency: too many requests at once (8 on a full key, 2 on a trial key). Queue your calls. - 429 with
Retry-After: 5: temporary overload. Wait five seconds and retry. - Request too large: the body limit is 8 MB, and prompt plus reply must fit in 100,000 tokens.
Failed or refused requests are not charged, so retrying carefully costs nothing extra. For every error code and more examples, read the documentation, and see pricing to estimate what a workload costs at $0.15 per 1M input tokens and $0.50 per 1M output tokens.
Retrying politely in code
A script that sends many requests will eventually meet a 429. The fix is a small retry wrapper that waits and tries again. This version respects the five-second pause the API asks for on temporary overload.
import os, time
from openai import OpenAI, RateLimitError
client = OpenAI(base_url="https://api.bestllmapi.com/v1", api_key=os.environ["LLM_API_KEY"])
def ask(prompt, tries=5):
for attempt in range(tries):
try:
r = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": prompt}],
)
return r.choices[0].message.content
except RateLimitError:
time.sleep(5 * (attempt + 1))
raise RuntimeError("still rate limited after retries")
print(ask("List three uses for a paperclip."))
If you run many requests in parallel, cap the worker count at your concurrency limit. A thread pool of 8 matches a full key, and 2 matches a trial key. Going above that only produces concurrency errors.
More guides
Questions and answers
Do I need a special SDK?
No. Any OpenAI SDK or OpenAI-compatible client works. Set the base URL to https://api.bestllmapi.com/v1, use your key, and set the model to uncensored.
Can I try it before paying?
Yes. New users can claim $0.50 of trial credit with one click on the API key page. It needs no card and is valid for 7 days.
Does the API remember earlier messages?
No. Send the conversation history in the messages list on each request. Prompt plus reply must fit in the 100,000-token window.
What does a 429 error mean?
You hit a limit. The code rate_limited means too many requests per minute, concurrency means too many at once, and a Retry-After header means brief overload.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.