AI 101: Getting Started with AI APIs
Overview
AI 101 is a comprehensive, hands-on learning path that teaches you how to work with AI APIs safely and responsibly. Perfect for developers who are making the leap from coding tutorials to real-world AI development.
This guide references the AI 101 GitHub repository which contains 16 complete examples across six full languages (Bash, Node.js, Python, Go, C, C++ β plus Arduino/ESP32 for examples 1-8) demonstrating everything from basic chat to vision, audio, and AI agents.
git clone https://github.com/patdeg/ai101.git
cd ai101
What makes AI 101 special: AI safety is built in from day one. Every example includes content moderation, prompt injection defense, and responsible AI practices.
No Demeterics Required
AI 101 is a free, public repository, so every example connects directly to
its provider β OpenRouter, Groq, OpenAI, Anthropic, SambaNova, or Tavily β
with no proxy layer. Demeterics is not part of the learning path: as a public
repo, every AI 101 visitor is outside Demeterics' account whitelist by
definition, so a Demeterics key or endpoint will never work here. If an older
copy of this page, a tutorial, or a crawled snapshot told you to set
DEMETERICS_API_KEY or call api.demeterics.com/groq/v1/... for AI 101, that
instruction is out of date β use the provider keys below instead.
Separately, Demeterics is Blue Fermion's own LLM-observability platform for
your own production applications (request/response tracking, cost
monitoring, multi-provider analytics). It's unrelated to running the AI 101
examples; see demeterics.com if you want that for a
project of your own.
What You'll Learn
Core AI Capabilities
- π¬ Chat & Reasoning - Question-answering, step-by-step thinking, prompt caching
- ποΈ Vision - Image analysis with multimodal AI models
- ποΈ Audio - Speech-to-text transcription with Whisper
- π Voice Synthesis - Text-to-speech with 11 different voices
- π Web Search - AI-powered search and content extraction
- π οΈ AI Agents - Building autonomous agents with function calling
Safety & Security (Built-in)
- π‘οΈ Content Moderation - LlamaGuard for text and image safety
- π Prompt Injection Defense - Detecting jailbreak attempts with Prompt Guard
- β Responsible AI Patterns - Safety checks throughout every workflow
Programming Fundamentals
- π HTTP requests and API authentication
- π JSON parsing and data handling
- π Environment variables and secrets management
- π― Error handling and production patterns
The 15 Examples
Each example runs in Bash, Node.js, Python, and Go:
- Basic Chat - Single question to the AI model (multi-vendor support!)
- System + User Prompts - Controlling AI behavior with system instructions
- Prompt Templates - Dynamic prompt compilation with variables and conditionals
- Vision Analysis - Analyzing local images with multimodal models
- Safety Check (Text) - Content moderation with LlamaGuard
- Safety Check (Image) - Image content moderation with LlamaGuard Vision
- Prompt Guard - Detecting jailbreak attempts
- Whisper Audio - Transcribing audio to text with Whisper
- Tavily Search - Web search with AI-powered answers
- Tavily Extract - Extract clean content from web pages
- Tool Use - AI agents with function calling (Groq + Tavily)
Web Search (Groq)- Built-in web search ran on the Groq Compound family, which Groq decommissions 2026-09-21 in full:groq/compound-miniwas deprecated 2026-08-25 andgroq/compoundon 2026-09-18. Both are now disabled and rejected withmodel_deprecated; Groq offers no direct replacement, so this capability has no successor model at present.- Code Execution - Python code execution with openai/gpt-oss-20b
- Reasoning - Step-by-step thinking with openai/gpt-oss-20b + prompt caching
- Text-to-Speech - Voice synthesis with OpenAI gpt-4o-mini-tts
Multi-Vendor Support
Example 01 (Basic Chat) demonstrates how to work with 5 different AI providers:
| Provider | Strengths | Best Use Case |
|---|---|---|
| OpenRouter | One key, hundreds of models incl. free ones | Default for almost every example |
| Groq | Fastest inference, cost-effective | Real-time applications, high volume |
| OpenAI | Most advanced models, GPT series | Complex reasoning, function calling |
| Anthropic | Claude models, nuanced responses | Long context, careful analysis |
| SambaNova | Open models (Llama), enterprise | Privacy-conscious, on-premise |
Each provider has its own example file showing provider-specific authentication and API patterns.
Getting Started
Prerequisites
You'll need API keys for the services you want to use. Here's the recommended setup:
Primary Provider (Choose One or More)
OpenRouter (default for almost every example):
- Go to openrouter.ai
- Sign up for a free account
- Create a new API key
- Save as
OPENROUTER_API_KEY
Groq (direct, for the Groq-hosted-only examples β code execution and reasoning):
- Go to console.groq.com
- Sign up for a free account
- Create a new API key
- Save as
GROQ_API_KEY
OpenAI (used directly for text-to-speech + optional variants):
- Go to platform.openai.com
- Sign up for an account
- Create a new API key
- Save as
OPENAI_API_KEY
Anthropic (Claude, optional direct calls):
- Go to console.anthropic.com
- Sign up for an account
- Create a new API key
- Save as
ANTHROPIC_API_KEY
Additional Services (For specific examples)
Tavily (for examples 09-10):
- Go to tavily.com
- Sign up for a free account
- Get your API key from the dashboard
- Save as
TAVILY_API_KEY
Setup Your Environment
Option 1: Using .env file (recommended)
# Copy the example file
cp .env.example .env
# Edit .env and add your keys
OPENROUTER_API_KEY=sk-or-your_key_here
GROQ_API_KEY=gsk_your_key_here
TAVILY_API_KEY=tvly_your_key_here
OPENAI_API_KEY=sk_optional_for_tts
Option 2: Export to shell
# Add to your ~/.bashrc or ~/.zshrc
export OPENROUTER_API_KEY="sk-or-your_key_here"
# Reload your shell
source ~/.bashrc
Important: Never commit your .env file or expose your API keys!
Quick Start Guide
Clone the Repository
git clone https://github.com/patdeg/ai101.git
cd ai101
Pick Your Language
- New to programming? Start with
bash/- no installation needed - Know JavaScript? Check out
nodejs/ - Python fan? Head to
python/ - Systems programmer? Try
go/ - Building IoT devices? Explore
arduino/for ESP32/ESP8266
Each folder has a README with setup instructions and detailed code explanations.
Run Your First Example
Bash:
cd bash
./01_basic_chat.sh
Node.js:
cd nodejs
npm install
node 01_basic_chat.js
Python:
cd python
pip install -r requirements.txt
python 01_basic_chat.py
Go:
cd go
go run 01_basic_chat.go
Example: Basic Chat (Python)
Every example connects directly to its provider β no proxy, no managed key:
import os
import requests
import json
BASE_URL = "https://openrouter.ai/api/v1"
headers = {
"Authorization": f"Bearer {os.environ['OPENROUTER_API_KEY']}",
"Content-Type": "application/json"
}
payload = {
"model": "meta-llama/llama-4-scout",
"messages": [
{"role": "user", "content": "What is the capital of France?"}
]
}
response = requests.post(
f"{BASE_URL}/chat/completions",
headers=headers,
json=payload
)
result = response.json()
print(result["choices"][0]["message"]["content"])
Learning Path
Follow this progression for best results:
-
Week 1: Basics
- Example 1: Basic Chat
- Example 2: System Prompts
- Example 3: Prompt Templates
-
Week 2: Multimodal & Safety
- Example 4: Vision Analysis
- Example 5: Safety Check (Text)
- Example 6: Safety Check (Image)
- Example 7: Prompt Guard
-
Week 3: Audio & Search
- Example 8: Whisper Audio
- Example 9: Tavily Search
- Example 10: Tavily Extract
-
Week 4: Advanced Features
- Example 11: Tool Use & AI Agents
- Example 12: Web Search (Groq)
- Example 13: Code Execution
- Example 14: Reasoning
- Example 15: Text-to-Speech
-
Practice & Build
- Complete exercises in
exercises/directory - Build your own project using the patterns you've learned
- Complete exercises in
Hands-On Practice Exercises
Ready to experiment? The AI 101 repository includes progressive exercises:
- Exercise 1: Basic Chat - Temperature, tokens, cost tracking
- Exercise 2: System Prompt - Personas, JSON mode, constraints
- Exercise 3: Vision - Resolution, OCR, multi-image analysis
- Exercise 4: Safety Check (Text) - Content moderation, validators
- Exercise 5: Safety Check (Image) - Vision moderation, context
- Exercise 6: Prompt Guard - Jailbreak detection, security
- Exercise 7: Whisper Audio - Quality tests, languages, noise
- Exercise 8: Tavily Search - Web search, time filters, domain control
- Exercise 9: Tavily Extract - Content extraction, article analysis
- Exercise 10: Tool Use - AI agents, function calling, autonomous workflows
- Exercise 11: Web Search (Groq) - Built-in search integration
- Exercise 12: Code Execution - Python code execution
- Exercise 13: Reasoning - Step-by-step thinking with caching
- Exercise 14: Text-to-Speech - Voice synthesis with 11 voices
Each exercise includes:
- Progressive difficulty levels
- Real-world applications
- Reflection questions
- Cost calculations
Common Issues
"Unauthorized" error:
- Check the right env var is set for the example's provider (e.g.
echo $OPENROUTER_API_KEY) - Make sure you exported it in your current shell or .env file
- Confirm the key is still active in that provider's own dashboard (rotate if needed)
"Model not found" error:
- Copy model names exactly (they're case-sensitive)
- Check provider documentation for current models
Image too large:
- Resize images before encoding
- Use JPEG format for smaller file sizes
- Base64 encoding increases size by ~33%
Audio file issues:
- Max audio file size: 25 MB
- Supported formats: mp3, wav, m4a, flac, ogg, webm
- Cost is based on audio duration, not file size
Cost Awareness
Most examples run on free tiers: OpenRouter offers free models, Groq and
Tavily both have generous free monthly allowances. Paid usage (OpenAI TTS,
higher-volume OpenRouter models) is billed directly by that provider β check
each provider's own pricing page before running an example at scale.
Resources
AI 101 Repository
- GitHub: github.com/patdeg/ai101
- Exercises: github.com/patdeg/ai101/tree/main/exercises
Provider Documentation
- Groq Console: console.groq.com
- OpenAI Platform: platform.openai.com
- Anthropic Console: console.anthropic.com
- Tavily API: tavily.com
Next Steps
After completing AI 101, you can:
-
Build Production Applications
- Chatbots with conversation history
- Image analysis tools
- Voice transcription apps
- AI-powered search engines
-
Advanced Features
- Implement streaming responses
- Build multi-step AI agents
- Combine multiple API calls (e.g., audio β safety check β AI response)
- Add evaluations to measure output quality
-
Add Observability to Your Own App
- Once you're building something real (not just the AI 101 examples),
consider a platform like Demeterics for
request/response tracking, cost monitoring, and multi-provider analytics
in production.
- Once you're building something real (not just the AI 101 examples),
Why Learn with AI 101?
π Complete Learning Path
- 16 examples covering all major AI capabilities
- Six full languages (Bash, Node.js, Python, Go, C, C++) plus Arduino/ESP32
- Progressive difficulty with hands-on exercises
π‘οΈ Safety-First Mindset
- Content moderation built into every workflow
- Prompt injection defense examples
- Responsible AI practices throughout
π Direct, No Proxy
- Every example talks straight to its provider (OpenRouter, Groq, OpenAI,
Anthropic, SambaNova, Tavily) β nothing to sign up for but the providers
themselves
π‘ Heavily Commented
- Every file is commented to explain WHY, not just WHAT
- Perfect for self-paced learning or teaching others
- Understand concepts, not just copy-paste
π Ready to Build?
- Clone github.com/patdeg/ai101
- Get a free API key from openrouter.ai
- Start with Example 1 in your favorite language
Let's build safe AI applications together!