Overview
This guide demonstrates the fundamental operations of the Switchport SDK:- Initializing the client
- Executing prompts
- Recording metrics
- Working with different metric types
Setup
First, install the SDK and set your API key:Example 1: Simple Prompt Execution
Execute a prompt without context or variables:Example 2: Prompt with Variables
Pass dynamic variables to your prompt:Make sure your prompt template in the dashboard includes the variables like
{{customer_name}} and {{product}}.Example 3: Prompt with Subject
Use subject for deterministic version assignment:Example 4: Recording a Float Metric
Track numerical values like satisfaction scores:Example 5: Recording a Boolean Metric
Track true/false events like conversions:Example 6: Recording an Enum Metric
Track categorical values like sentiment:Example 7: Complete Workflow
Execute a prompt and record metrics together:Example 8: Multiple Users
See how different users might get different versions:Example 9: Response Time Tracking
Track how long operations take:Example 10: String vs Dictionary Subject
Subject can be a simple string or a dictionary:Complete Example Script
Here’s a complete script you can run:Next Steps
Advanced Examples
Learn about A/B testing and advanced patterns
Error Handling
Learn how to handle errors gracefully

