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 user identification 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 User Identification
Use user identification for deterministic version assignment:Example 4: Recording a Float Metric
Track numerical values like satisfaction scores:Make sure you’ve created the metric definition in the dashboard before recording.
Example 5: Recording a Boolean Metric
Track yes/no events like conversions:Example 6: Recording an Enum Metric
Track categorical values:Example 7: Complete Workflow
Execute a prompt and record metrics:Example 8: String Subject
Use a simple string as subject:Example 9: Error Handling
Handle errors gracefully:Example 10: Multiple Metrics
Record multiple metrics for the same user:Next Steps
Advanced Examples
Explore advanced A/B testing patterns
Error Handling
Learn best practices for error handling
API Reference
View the complete API reference
Core Concepts
Understand key Switchport concepts

