LLM Integration Basics
Call AI APIs and build LLM-powered applications
Learn to integrate LLMs into applications using the Anthropic and OpenAI APIs. Covers API calls, streaming, error handling, and building a simple AI-powered feature from scratch.
STEP-BY-STEP GUIDE
How to LLM Integration Basics
Set Up Your API Environment
pip install anthropic openai python-dotenv # .env file ANTHROPIC_API_KEY=sk-ant-... OPENAI_API_KEY=sk-...
Never hardcode API keys. Load them from environment variables using python-dotenv.
Make Your First API Call
import anthropic
import os
from dotenv import load_dotenv
load_dotenv()
client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Analyze this job description and list the top 5 required skills."
}
]
)
print(message.content[0].text)Add Streaming for Better User Experience
with client.messages.stream(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)Handle Errors and Rate Limits
import time
from anthropic import RateLimitError, APIError
def call_with_retry(client, prompt, max_retries=3):
for attempt in range(max_retries):
try:
return client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}]
)
except RateLimitError:
wait = 2 ** attempt # exponential backoff
time.sleep(wait)
except APIError as e:
raise e # don't retry on non-rate-limit errors
raise Exception("Max retries exceeded")PRACTICE
Exercises
Write a Python script that calls the Anthropic API and returns a job description analysis.
Add streaming to your API call so the response appears word-by-word.
Build a retry mechanism with exponential backoff for API rate limit errors.
Create a simple CLI tool that takes a job description and returns a tailored resume summary.
Add Redis caching to your API calls to avoid redundant API costs on repeated queries.
CAREER IMPACT
Career Paths That Use This Skill
| Career Path | How It's Used | Salary Range |
|---|---|---|
| ML Engineer | Building LLM-powered features in production | $140K–$250K |
| AI Software Engineer | Integrating AI into applications | $130K–$220K |
| Prompt Engineer | Building and testing prompt systems via API | $90K–$175K |
| AI Entrepreneur | Building AI-powered products and services | Variable |
FAQ
Common Questions
Which API should I use — Anthropic or OpenAI?+
How much do API calls cost?+
How do I avoid exposing my API key?+
Related Academy Tracks
Put this skill into action
Take our quiz to get your personalized learning path and start applying these skills immediately.
Find My TrackReady to Apply? Use HireKit's Free Tools
AI-powered job search tools for LLM Integration Basics
ATS Resume Checker
Apply what you've learned — check your resume for free
Explore HireKit
AI-powered job search tools to accelerate your career
hirekit.co — AI-powered job search platform