Skip to content

Latest commit

 

History

History

README.md

Examples

This directory contains standalone, runnable examples demonstrating the TypeSafe C++ SDK features.

Most examples run against either the native TypeSafe AI API (via TYPESAFE_API_KEY) or OpenRouter's Jev 1.13 endpoint (via OPENROUTER_API_KEY); the shared helper prefers TYPESAFE_API_KEY and falls back to OPENROUTER_API_KEY. Exceptions: 05 and 06 run offline with no key at all, 07 requires TYPESAFE_API_KEY (GET /v1/models is a native endpoint; the example prints a notice under OpenRouter), and 08 requires OPENROUTER_API_KEY.


Example Index

Executable Description Primitives / Focus
01_classify_message Binary classification with confidence Noul
02_triage_ticket Multi-question ticket categorization and urgency Noul, Choice, Score
03_custom_model Type deserialization directly into custom C++ structs systemOneAs<T>
04_parallel_classification Concurrent asynchronous evaluation across 4 messages systemOneAsync
05_error_handling Client error hierarchy, local validation rejection TypeSafeError, ValidationError
06_custom_transport In-memory mock transport for testing without network Custom Transport
07_list_models Fetching model aliases and version metadata listModels(), GET /v1/models
08_openrouter Dedicated OpenRouter synchronous evaluation OpenRouter typesafe/jev-1.13
09_openrouter_sync Sequential (sync) evaluation of 5 messages with latency measurement Non-async timing
10_openrouter_async Concurrent evaluation of 5 messages with latency measurement Concurrency speedup
11_openrouter_suite Comprehensive 6-test integration suite testing all primitives live Full regression test suite

Running Examples

Using OpenRouter (OPENROUTER_API_KEY)

export OPENROUTER_API_KEY="sk-or-v1-..."

# Run the synchronous sequential evaluation:
./build/examples/09_openrouter_sync

# Run the asynchronous concurrent evaluation:
./build/examples/10_openrouter_async

# Run the complete live integration test suite:
./build/examples/11_openrouter_suite

Using TypeSafe AI (TYPESAFE_API_KEY)

export TYPESAFE_API_KEY="ts_live_..."

# Run any example directly:
./build/examples/01_classify_message
./build/examples/02_triage_ticket
./build/examples/04_parallel_classification