Skip to content
imaged
Docs / Setup / C

C setup.

Same libsdk, plain C ABI through sdk_c.h. No Foundation, no C++ runtime needed at the call site.

Prerequisites
Compiler GCC 11+ or Clang 14+
Platforms Linux x86_64, macOS arm64, Windows x64
License token JWT issued from /dashboard
  1. 01

    Download the SDK

    The C bindings ship in the same tarball as C++. Headers under include/imaged/, library under lib/.

    bash
    tar -xzf imaged-linux-x86_64-0.10.tar.gz
    cd imaged-sdk-0.10
  2. 02

    Hello world

    Create the AI handle, set a license token from /dashboard, verify it, print the version. The C ABI returns int handles and small POD structs; you free nothing the SDK didn't allocate for you.

    c
    #include "imaged/sdk_c.h"
    #include <stdio.h>
    
    int main(void) {
        AIHandle ai = ai_create();
        ConfigurationOptionsHandle cfg = ai_get_options(ai);
    
        configuration_options_set_string(cfg, "license.token", "your-license-token");
        configuration_options_set_string(cfg, "license.audience", "cameras.acme.com");
    
        int status = configuration_options_check_license(cfg);
        if (status != 200) {
            fprintf(stderr, "license check failed, status %d\n", status);
            ai_destroy(ai);
            return 1;
        }
    
        printf("imaged %s licensed=%d\n",
               ai_get_version(ai), ai_is_licensed(ai));
    
        ai_destroy(ai);
        return 0;
    }
  3. 03

    Build

    One include path, one library path, link libsdk and libonnxruntime. The runtime loader needs to find both at run time, so set rpath or LD_LIBRARY_PATH.

    bash
    cc -std=c11 -I imaged-sdk-0.10/include \
       -L imaged-sdk-0.10/lib \
       -Wl,-rpath,imaged-sdk-0.10/lib \
       main.c -lsdk -lonnxruntime -o hello
    
    ./hello
    # imaged 0.10.0 licensed=1
  4. 04

    Run a family

    Family dispatch is string-keyed. ai_family_detect runs YOLO and returns a flat array of objects you read with index access. Free nothing on the result, the SDK owns it.

    c
    ImageHandle img = image_create();
    image_load(img, "bus.jpg");
    
    configuration_options_set_string(cfg, "yolo.model", "yolo26x.onnx");
    
    ResponseObject r = ai_family_detect(ai, "yolo", img);
    for (int i = 0; i < r.objectCount; i++) {
        printf("%s %.2f\n", r.objects[i].label, r.objects[i].score);
    }
    
    image_destroy(img);
  5. 05

    Where to go next

    The full C example for object detection is on the task page. C++ users get the same calls with type-safe variants in std::variant; pick whichever fits your build.