AI 101: Getting Started with AI APIs

Learn how to integrate Demeterics into your workflows with step-by-step guides and API examples.

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:

  1. Basic Chat - Single question to the AI model (multi-vendor support!)
  2. System + User Prompts - Controlling AI behavior with system instructions
  3. Prompt Templates - Dynamic prompt compilation with variables and conditionals
  4. Vision Analysis - Analyzing local images with multimodal models
  5. Safety Check (Text) - Content moderation with LlamaGuard
  6. Safety Check (Image) - Image content moderation with LlamaGuard Vision
  7. Prompt Guard - Detecting jailbreak attempts
  8. Whisper Audio - Transcribing audio to text with Whisper
  9. Tavily Search - Web search with AI-powered answers
  10. Tavily Extract - Extract clean content from web pages
  11. Tool Use - AI agents with function calling (Groq + Tavily)
  12. Web Search (Groq) - Built-in web search ran on the Groq Compound family, which Groq decommissions 2026-09-21 in full: groq/compound-mini was deprecated 2026-08-25 and groq/compound on 2026-09-18. Both are now disabled and rejected with model_deprecated; Groq offers no direct replacement, so this capability has no successor model at present.
  13. Code Execution - Python code execution with openai/gpt-oss-20b
  14. Reasoning - Step-by-step thinking with openai/gpt-oss-20b + prompt caching
  15. 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):

  1. Go to openrouter.ai
  2. Sign up for a free account
  3. Create a new API key
  4. Save as OPENROUTER_API_KEY

Groq (direct, for the Groq-hosted-only examples β€” code execution and reasoning):

  1. Go to console.groq.com
  2. Sign up for a free account
  3. Create a new API key
  4. Save as GROQ_API_KEY

OpenAI (used directly for text-to-speech + optional variants):

  1. Go to platform.openai.com
  2. Sign up for an account
  3. Create a new API key
  4. Save as OPENAI_API_KEY

Anthropic (Claude, optional direct calls):

  1. Go to console.anthropic.com
  2. Sign up for an account
  3. Create a new API key
  4. Save as ANTHROPIC_API_KEY

Additional Services (For specific examples)

Tavily (for examples 09-10):

  1. Go to tavily.com
  2. Sign up for a free account
  3. Get your API key from the dashboard
  4. 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:

  1. Week 1: Basics

    • Example 1: Basic Chat
    • Example 2: System Prompts
    • Example 3: Prompt Templates
  2. Week 2: Multimodal & Safety

    • Example 4: Vision Analysis
    • Example 5: Safety Check (Text)
    • Example 6: Safety Check (Image)
    • Example 7: Prompt Guard
  3. Week 3: Audio & Search

    • Example 8: Whisper Audio
    • Example 9: Tavily Search
    • Example 10: Tavily Extract
  4. 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
  5. Practice & Build

    • Complete exercises in exercises/ directory
    • Build your own project using the patterns you've learned

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

Provider Documentation

Next Steps

After completing AI 101, you can:

  1. Build Production Applications

    • Chatbots with conversation history
    • Image analysis tools
    • Voice transcription apps
    • AI-powered search engines
  2. 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
  3. 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.

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?

  1. Clone github.com/patdeg/ai101
  2. Get a free API key from openrouter.ai
  3. Start with Example 1 in your favorite language

Let's build safe AI applications together!