Examples Setup
This guide explains how to set up and run the Streamblocks examples.
Prerequisites
- Python 3.11+
- uv (recommended) or pip
Installation
Clone the Repository
Install Dependencies
Running Examples
Quick Start
Run all standalone examples (no API keys required):
With API Keys
Set your API keys and run all examples:
export GEMINI_API_KEY="your-key-here" # pragma: allowlist secret
export OPENAI_API_KEY="your-key-here" # pragma: allowlist secret
export ANTHROPIC_API_KEY="your-key-here" # pragma: allowlist secret
uv run python examples/run_examples.py
Runner Options
# Run specific category
uv run python examples/run_examples.py --category adapters
# Dry run (see what would execute)
uv run python examples/run_examples.py --dry-run
# Verbose output
uv run python examples/run_examples.py --verbose
# Run in parallel (faster)
uv run python examples/run_examples.py --parallel
# Custom timeout
uv run python examples/run_examples.py --timeout 60
# JSON output
uv run python examples/run_examples.py --output json
Run Individual Examples
# Basic example (no API key)
uv run python examples/01_basics/01_basic_usage.py
# Gemini example (requires API key)
export GEMINI_API_KEY="your-key-here" # pragma: allowlist secret
uv run python examples/03_adapters/02_gemini_auto_detect.py
API Keys
Google Gemini
export GEMINI_API_KEY="your-key-here" # pragma: allowlist secret
# or
export GOOGLE_API_KEY="your-key-here" # pragma: allowlist secret
Get your key: Google AI Studio
OpenAI
Get your key: OpenAI Platform
Anthropic
Get your key: Anthropic Console
Example Categories
| Directory | Description | Requires API |
|---|---|---|
01_basics/ |
Core concepts | No |
02_syntaxes/ |
Syntax formats | No |
03_adapters/ |
Provider adapters | Some |
04_logging/ |
Logging options | No |
05_ui/ |
UI examples | No |
06_integrations/ |
Framework integrations | Some |
Pytest Integration
Run examples as tests:
# Run all
pytest tests/test_examples.py
# Skip API examples
pytest tests/test_examples.py -m "not api"
# Skip UI examples
pytest tests/test_examples.py -m "not ui"
# Verbose
pytest tests/test_examples.py -v
Troubleshooting
Timeout Issues
Increase the timeout:
Rate Limits
Run sequentially instead of parallel:
Import Errors
Reinstall with all extras:
Next Steps
- Basic Examples - Start here
- Adapter Examples - Provider integration
- Integration Examples - Framework usage