Other Capabilities
Beyond single-image generations, the Switchboard SDK supports multi-size crop bundling, style variation batches, client tuning (custom timeouts/polling), error handling patterns, and detailed capture metadata access.
1. Multi-Size Package Generation
When you need to deliver an image in multiple print sizes (e.g. 4x6 at 1800x1200 and 5x7 at 2100x1500), you can specify multiple target dimensions. The SDK uploads the source file once, and returns all processed dimensions in a single bundle when ready.
var sizes = new[] { (1800, 1200), (2100, 1500) };
var outputs = await client.GeneratePackageAsync(
filter: "claymation-001",
stream: fileStream,
sizes: sizes,
timeout: TimeSpan.FromMinutes(1)
);
int index = 0;
foreach (var outputStream in outputs)
{
using (outputStream)
{
using var dest = File.Create($"output_package_{++index}.jpg");
await outputStream.CopyToAsync(dest);
}
}
2. Creative Variations Generation
To generate multiple distinct, non-deterministic interpretations of a single capture, you can request a batch of variations. A variation batch represents a group of generations originating from a single source capture. The SDK handles triggering this batch and returns a list of the resulting generated image streams/buffers.
var variants = await client.GenerateVariationsAsync(
filter: "claymation-001",
stream: fileStream,
width: 1024,
height: 1024,
variants: 3, // Request 3 distinct versions
timeout: TimeSpan.FromMinutes(2)
);
int index = 0;
foreach (var variantStream in variants)
{
using (variantStream)
{
using var dest = File.Create($"output_variant_{++index}.jpg");
await variantStream.CopyToAsync(dest);
}
}
3. Timeouts & Polling Customization
The SDK's high-level helper methods poll the server automatically. If no polling interval is defined, it defaults to a dynamic delay optimized for network load. You can override this behavior by passing custom configuration.
using var resultStream = await client.GenerateAsync(
filter: "claymation-001",
stream: fileStream,
width: 1024,
height: 1024,
timeout: TimeSpan.FromSeconds(45),
pollingInterval: TimeSpan.FromSeconds(3) // Check static every 3s
);
4. Lifecycle Metadata Inspection
If you need details about processing speeds, model routing, or job execution timestamps, you can retrieve the metadata container for any capture.
var capture = await client.Captures["capture-guid"].GetAsync();
if (capture != null)
{
Console.WriteLine($"Status: {(capture.Errored != null ? "Failed" : "Success")}");
Console.WriteLine($"Filter applied: {capture.Filter}");
Console.WriteLine($"Created: {capture.Datetime}");
Console.WriteLine($"Stored: {capture.Uploaded}");
Console.WriteLine($"AI Model Done: {capture.Generated}");
Console.WriteLine($"Final Output Done: {capture.Processed}");
}
5. SDK Exception Handling
When using the SDK clients, capture pipeline errors are mapped to specific exceptions.
InvalidOperationException: Raised if the AI pipeline or backend fails to process the image (checkex.Messagefor detailed server output).TimeoutException: Raised if the generation takes longer than your configured timeout threshold.HttpRequestException: Raised for network failures, DNS errors, or standard API authentication errors (HTTP 401/403).
try
{
using var processed = await client.GenerateAsync(...);
}
catch (InvalidOperationException ex)
{
Console.WriteLine($"Model error reported by server: {ex.Message}");
}
catch (TimeoutException)
{
Console.WriteLine("The processing cycle timed out.");
}