Skip to content

C SDK

SDK Download

Setup

Download the C SDK archive from SDK Overview, extract it, then build and install it.

cd <PATH_TO_EXTRACTED_C_SDK>
mkdir build && cd build
cmake ..
make
sudo make install

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 SpeechTranscriptionsAPI_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.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include "apiClient.h"
#include "SpeechTranscriptionsAPI.h"

int main(void) {
    const char *base_url  = getenv("KOLDAN_BASE_URL");
    const char *api_key   = getenv("KOLDAN_API_KEY");
    const char *file_path = getenv("KOLDAN_FILE_PATH");

    apiClient_t *client = apiClient_create_with_base_path(base_url, NULL, NULL);
    apiClient_setApiKey(client, api_key);

    const char *transcription = "{\"model\":\"general\",\"punctuation\":false,\"capitalization\":false}";
    const char *diarization   = "{\"enabled\":false}";

    upload_and_transcribe_200_response_t *resp =
        SpeechTranscriptionsAPI_uploadAndTranscribe(
            client,
            "meeting-recording",
            transcription,
            NULL,
            file_path,
            NULL,
            NULL,
            NULL,
            diarization,
            NULL,
            NULL,
            NULL
        );

    if (!resp) {
        fprintf(stderr, "Upload failed\n");
        apiClient_free(client);
        return 1;
    }

    job_t *job = resp->job;
    while (1) {
        job = SpeechTranscriptionsAPI_getJob(client, job->id);
        printf("Job status: %s\n", job->status);

        if (strcmp(job->status, "COMPLETED") == 0 ||
            strcmp(job->status, "FAILED")    == 0 ||
            strcmp(job->status, "CANCELLED") == 0) {
            break;
        }
        sleep(2);
    }

    if (strcmp(job->status, "COMPLETED") == 0) {
        printf("%s\n", job->result->text);
    } else {
        printf("Job did not complete successfully.\n");
    }

    apiClient_free(client);
    return 0;
}

Run

gcc -o upload_file main.c -lkoldan_sdk -lcurl
./upload_file

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.