C# REST API SDK
Need real-time streaming?
This page covers the REST API SDK for file upload and batch transcription. For live microphone or PCM streaming over WebSocket, use the separate C# WebSocket SDK.
SDK Download
Setup
Download the C# SDK archive from SDK Overview, extract it, then reference the generated project from your sample application.
Configure the shared environment variables from Getting Started, and point KOLDAN_FILE_PATH to the audio file you want to transcribe.
Upload And Transcribe With UploadAndTranscribe
The example below keeps the request intentionally minimal: upload one file, start transcription with the general model alias, poll until the job finishes, and print either the transcript or the error details.
using System.Text.Json;
using Koldan.Sdk.Api;
using Koldan.Sdk.Client;
using Koldan.Sdk.Model;
var config = new Configuration
{
BasePath = Environment.GetEnvironmentVariable("KOLDAN_BASE_URL")
};
config.AddApiKey("X-API-Key", Environment.GetEnvironmentVariable("KOLDAN_API_KEY"));
var api = new SpeechTranscriptionsApi(config);
using var stream = File.OpenRead(Environment.GetEnvironmentVariable("KOLDAN_FILE_PATH")!);
var response = api.UploadAndTranscribe(
name: "meeting-recording",
transcription: JsonSerializer.Serialize(new
{
model = "general",
punctuation = false,
capitalization = false
}),
file: stream,
diarization: JsonSerializer.Serialize(new { enabled = false })
);
var job = response.Job!;
while (true)
{
job = api.GetJob(job.Id!.Value);
Console.WriteLine($"Job status: {job.Status}");
if (job.Status is TranscriptionJobStatus.COMPLETED or TranscriptionJobStatus.FAILED or TranscriptionJobStatus.CANCELLED)
{
break;
}
await Task.Delay(TimeSpan.FromSeconds(2));
}
Console.WriteLine(job.Status == TranscriptionJobStatus.COMPLETED
? job.Result?.Text
: JsonSerializer.Serialize(job.Errors));
Run
Expected Result
A successful run prints Job status: ... updates and then the transcription text from your uploaded audio.
If the job fails, the example prints the error array returned by the API.