From selection to first response
Build your first free LLM API request
without guessing.
This guide is for providers with OpenAI-compatible APIs. Select a provider, get your key from the official dashboard, set environment variables, and send a request with curl, Python, or Node.js.
Standard path
Four steps that should not be mixed
A website loading or an endpoint returning a status code does not prove that an account can be created or a model request will succeed. Each step must be performed and verified separately.
- 1Choose a provider
Compare use case, free-tier type, limits, models, and regional access.
- 2Sign up and get an API key
Use the official signup page and the official API key dashboard only.
- 3Set three values
API key, Base URL, and exact model ID — all from official documentation.
- 4Send a real request
Check HTTP status, JSON body, and model response content.
Before coding
Get these three values from official docs
LLM_API_KEY
Your secret key. Never commit it to Git, paste it in public code, or expose it in the browser frontend.
LLM_BASE_URL
The API base URL. For OpenAI-compatible services this usually ends with /v1.
LLM_MODEL
The exact model identifier — not the marketing name. Copy it from your account dashboard or the official docs.
Setting environment variablesLinux / macOS / Git Bash
export LLM_API_KEY="YOUR_API_KEY"
export LLM_BASE_URL="https://provider.example/v1"
export LLM_MODEL="MODEL_ID"
Ready-to-copy examples
Send a simple Chat Completions request
These examples work with any provider labeled OpenAI-compatible in the catalog. If the service has a proprietary API, use its native SDK and schema. The test message is kept short so connection, auth, and model errors surface quickly.
curlno SDK required
curl "$LLM_BASE_URL/chat/completions" \
-H "Authorization: Bearer $LLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "'"$LLM_MODEL"'",
"messages": [
{"role": "user", "content": "Only respond with: Connection successful"}
]
}'
PythonOpenAI SDK
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["LLM_API_KEY"],
base_url=os.environ["LLM_BASE_URL"],
)
response = client.chat.completions.create(
model=os.environ["LLM_MODEL"],
messages=[
{"role": "user", "content": "Only respond with: Connection successful"}
],
)
print(response.choices[0].message.content)
python -m pip install openaiNode.jsOpenAI SDK + ESM
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.LLM_API_KEY,
baseURL: process.env.LLM_BASE_URL,
});
const response = await client.chat.completions.create({
model: process.env.LLM_MODEL,
messages: [
{ role: "user", content: "Only respond with: Connection successful" },
],
});
console.log(response.choices[0].message.content);
npm install openaiDefining success
How do I know I am connected?
Successful HTTP status
Usually 200, but status alone is not enough — verify the body too.
Valid JSON body
The response must be the expected API JSON, not a login page or CDN error.
Correct model
The response should reference the model ID you sent in the request.
Readable content
The model response content should be accessible in the expected SDK path or JSON field.
Quick error reference
What common errors mean
401 Unauthorized
The API key is missing, invalid, or not accepted for this endpoint. Check the variable name and Authorization header.
403 Forbidden
Your account, region, model, or service policy does not allow access. Do not confuse this with a network issue.
404 Not Found
The Base URL, API version, chat/completions path, or model ID may be incorrect.
429 Too Many Requests
Quota or rate limit exceeded. Retry with backoff and check the rate-limit headers.
Timeout / TLS
The issue is likely before the API layer: check DNS, network path, TLS, and firewall separately.
200 + HTML
You received a web page instead of an API response. Check Content-Type and the Base URL.
For details, read the 401/403/Model guide and the 429 rate-limit guide.
Ready to find your provider?
Use the API Finder to match providers to your use case, budget, and constraints.