Free LLM API for Beginners: Zero to Your First AI API Call in 10 Minutes
Never made an API call before? This beginner guide walks you through using a free LLM API step by step — in Python, JavaScript, and with no code at all.
What Is an LLM API?
An API (Application Programming Interface) is a way for your code to talk to another service over the internet. An LLM API lets your code send text to an AI model and receive a response — programmatically, without using a web interface like ChatGPT.
Instead of typing in a chat box, you write code that sends a message and reads the reply. This lets you build apps, automate tasks, process data in bulk, and integrate AI into any software you write.
What You Need
- A free API key from FreeLLMKeys.com (takes 5 seconds — just copy it)
- Python 3.8+ or Node.js 18+ installed
- That is it
Option A — Python (Recommended for Beginners)
Install the library
pip install openai
Write your first AI call
Create a file called hello_ai.py and paste this:
from openai import OpenAI
# 1. Create the client — paste your key from FreeLLMKeys.com
client = OpenAI(
base_url="https://aiapiv2.pekpik.com/v1",
api_key="sk-paste-your-key-here"
)
# 2. Send a message to the AI
response = client.chat.completions.create(
model="gpt-4o", # which AI model to use
messages=[
{"role": "user", "content": "What is Python used for?"}
]
)
# 3. Print the reply
print(response.choices[0].message.content)
Run it
python hello_ai.py
You should see GPT-4o's response printed in your terminal within a few seconds. That is your first AI API call.
Understanding What Just Happened
Let us break down the code line by line:
client = OpenAI(
base_url="https://aiapiv2.pekpik.com/v1", # WHERE to send the request
api_key="sk-your-key" # PROOF that you're allowed to use it
)
response = client.chat.completions.create(
model="gpt-4o", # WHICH AI model to use
messages=[ # The CONVERSATION so far
{
"role": "user", # Who is speaking ("user" = you, "assistant" = AI, "system" = instructions)
"content": "..." # What is being said
}
]
)
response.choices[0].message.content # The AI's reply text
Option B — JavaScript / Node.js
npm install openai
// hello_ai.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://aiapiv2.pekpik.com/v1",
apiKey: "sk-paste-your-key-here"
});
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [
{ role: "user", content: "What is JavaScript used for?" }
]
});
console.log(response.choices[0].message.content);
node hello_ai.js
Option C — No Code (cURL)
If you just want to test the API without installing anything, use this terminal command:
curl https://aiapiv2.pekpik.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer sk-your-key-here" -d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Say hello!"}]
}'
Making a Simple Conversation (Multi-Turn)
To have a back-and-forth conversation, add each message to the messages list:
messages = [] # Start with empty history
while True:
user_input = input("You: ")
if user_input.lower() == "quit":
break
messages.append({"role": "user", "content": user_input})
response = client.chat.completions.create(
model="gpt-4o",
messages=messages
)
reply = response.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
print(f"AI: {reply}\n")
Giving the AI a Personality (System Prompt)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "system", # System message sets the AI's behavior
"content": "You are a pirate. Respond to everything in pirate speak."
},
{
"role": "user",
"content": "What time is it?"
}
]
)
print(response.choices[0].message.content)
# "Arrr, I know not the exact hour, but the sun be high in the sky, matey!"
Switching Between AI Models
The only thing you change to use a different AI model is the model string:
model="gpt-4o" # OpenAI — fast, great general purpose
model="claude-opus-4-7" # Anthropic Claude — best writing quality
model="deepseek-chat" # DeepSeek — best for coding
model="gemini-2.5-flash" # Google — fastest, 1M token context
model="grok-4" # xAI Grok — real-time knowledge
Everything else in your code stays exactly the same. That is the power of an OpenAI-compatible API — write once, run on any model.
What to Build Next
Now that you can make an API call, here are beginner-friendly projects to try:
- Text summarizer: Paste a long article, get a 3-sentence summary
- Email reply generator: Paste an email, get 3 draft reply options
- Language translator: Type in English, get output in any language
- Study quiz generator: Paste your notes, get 10 multiple choice questions
- Code explainer: Paste any code snippet, get a plain-English explanation
All of these are 20–30 lines of Python using the exact same pattern you just learned. Go build something.