AI Engine C API

Preview 0.4.0

The AI Engine C API reference.

This is a preview of the Modular AI Engine. It is not publicly available yet and APIs are subject to change.

If you’re interested, please sign up for early access.

This is an early preview of the C API for the Modular AI Engine.

For a walkthrough, showing how to load and execute a model, see the C get started guide.

C API headers

Each of the following pages represents one of the C API header files:

Async API usage

Our C API allows for compiling and executing models asyncronously. In general, effective use of asynchronous APIs may be difficult, but rewarding for performance. To help with this, we’re going to explain some important concepts and mental models to keep in mind with the API.

Our APIs are async-safe unless stated otherwise, typically with a `Sync` in the function identifier name. For example, we have M_executeModel and M_executeModelSync().


Our API describes the underlying async-holding types with a “value or error” concept. Conceptually, this means that the type is in one of three states:

  • Constructed - the value is not yet there, but there is no error

  • Available - the value is there and ready for use

  • Error - the value is not there and there is an error

Synchronization points

When using async APIs, it is a good idea to be mindful of the synchronization point APIs currently provided below. This is useful for discerning between the Constructed and Available states mentioned above. After calling the synchronization point, the input will never be in a Constructed state: it will always resolve to either being Available or Error.


Errors surface immediately when using our syncronous APIs. Otherwise, in the case of async APIs, errors will not surface until the next synchronization point. You can query the error message by calling M_getError().