SDK setup
Add a Desert Ant model to your app, with an API key from the console. The steps cover Swift, Kotlin, the web, and Node, with Emo as the example. For another model, use the package, class, and call from the model's page, such as Redact.
API key
The models run without a key, so you can build and test first. An app in production needs an API key.
- Sign in at platform.desertant.com with GitHub, Hugging Face, or your email.
- Choose an ID for your team. If your company already uses Desert Ant Labs models, ask an owner to invite you instead.
- Click New API key, and choose where the key will be used: iOS or desktop, Android app, Web app, or Server.
- Click Create API key, and copy the key. The console shows the full key only once.
- For a Server key, set the app ID. Each app on a server needs its own ID, listed on your account. For the other keys, you can limit the key to one app with its bundle ID, package name, or allowed sites. That step is optional.
Create a key for each app and platform.
An app that ships the models credits Desert Ant Labs. The attribution guide shows how.
Install
The Swift package requires iOS 18+ or macOS 15+, and Xcode 26. In Xcode, choose File > Add Package Dependencies, enter https://github.com/Desert-Ant-Labs/desert-ant-core.git, and add the Emo and DesertAnt products to your app target. In a Package.swift, add:
.package(url: "https://github.com/Desert-Ant-Labs/desert-ant-core.git", from: "6.0.0")
The Android SDK requires API 24+ and Kotlin 2.3+. The packages are on Maven Central. Add the model's package to app/build.gradle.kts:
dependencies {
implementation("ai.desertant:emo:6.0.0")
}
The browser build runs on WebAssembly with LiteRT.js:
npm i @desert-ant-labs/emo@6.0.0 @litertjs/core
The /native build ships prebuilt for linux-x64, linux-arm64, and darwin-arm64. Voz has no /native build: in Node, pass onnxruntime-node to Voz's load(). Tongue has no /native build either: import it as @desert-ant-labs/tongue.
npm i @desert-ant-labs/emo@6.0.0
Key setup
Each platform reads the key from a file that stays out of git, so a fresh clone builds without a key. In Kotlin, an app that uses only Tongue imports DesertAnt from ai.desertant.tongue. An app with another model sets the key once, on ai.desertant.core.DesertAnt, and Tongue reads it.
Create
Secrets.xcconfignext to the.xcodeproj, with your key, and addSecrets.xcconfigto.gitignore:textDAL_API_KEY=dal_...Create
Config.xcconfignext to the.xcodeproj, and commit it.#include?skipsSecrets.xcconfigwhen the file is missing.textDAL_API_KEY = #include? "Secrets.xcconfig"Set
Config.xcconfigas the configuration file of your app target. In the project's Info tab, chooseConfig.xcconfigfor Debug and Release. If the target already has a configuration file, add the two lines from step 2 to that file instead.Add
DAL_API_KEYtoInfo.plist. Xcode fills in the value from the build setting, so the app can read the key at run time.XML<key>DAL_API_KEY</key> <string>$(DAL_API_KEY)</string>New Xcode projects have no
Info.plistfile, and Xcode drops customINFOPLIST_KEY_settings. In that case, createInfo.plistwith only this key next to the.xcodeproj, not in the app's source folder. Then addINFOPLIST_FILE = Info.plisttoConfig.xcconfig, and keepGENERATE_INFOPLIST_FILE = YES. Xcode adds the keys it generates to the file.Call
DesertAnt.configureat launch, before the first model loads:Swiftimport DesertAnt import SwiftUI @main struct MyApp: App { init() { if let apiKey = Bundle.main.object(forInfoDictionaryKey: "DAL_API_KEY") as? String, !apiKey.isEmpty { DesertAnt.configure(apiKey: apiKey) } } var body: some Scene { WindowGroup { ContentView() } } }
To run a model on a server in Swift, see Run on a server.
Add your key to
local.properties. New Android projects already listlocal.propertiesin.gitignore. On CI, set the Gradle propertyDAL_API_KEYinstead, for example with theORG_GRADLE_PROJECT_DAL_API_KEYenvironment variable.textDAL_API_KEY=dal_...Add
DAL_API_KEYtoBuildConfig, inapp/build.gradle.kts. The import goes at the top of the file.Kotlinimport java.util.Properties val localProperties = Properties().apply { rootProject.file("local.properties").takeIf { it.exists() }?.inputStream()?.use { load(it) } } val dalApiKey = localProperties.getProperty("DAL_API_KEY") ?: providers.gradleProperty("DAL_API_KEY").orNull ?: "" android { buildFeatures { buildConfig = true } defaultConfig { buildConfigField("String", "DAL_API_KEY", "\"$dalApiKey\"") } }Call
DesertAnt.configureinApplication.onCreate, and register the class withandroid:nameinAndroidManifest.xml:Kotlinimport ai.desertant.core.DesertAnt import android.app.Application class App : Application() { override fun onCreate() { super.onCreate() if (BuildConfig.DAL_API_KEY.isNotEmpty()) DesertAnt.configure(apiKey = BuildConfig.DAL_API_KEY) } }
Add your key to
.env.local. A browser bundle only gets variables with the bundler's public prefix. Vite usesVITE_. In Next.js, name the variableNEXT_PUBLIC_DAL_API_KEY.TerminalVITE_DAL_API_KEY=dal_...Call
DesertAnt.configurebefore the first model loads. In Next.js, readprocess.env.NEXT_PUBLIC_DAL_API_KEY.TypeScriptimport { DesertAnt } from "@desert-ant-labs/emo"; DesertAnt.configure({ apiKey: import.meta.env.VITE_DAL_API_KEY ?? "" });
On a server, one process runs models for many end-user devices, so you also set a device id secret and pass a device id with each call.
Add your key and your app ID to
.envlocally, and add.envto.gitignore. For deploys, put them in your secrets manager or CI. Use a Server key, and the app ID you entered for it. Node loads the file withnode --env-file=.env.TerminalDAL_API_KEY=dal_... DAL_APP_ID=...Add a device id secret to
.env. Make the secret once withopenssl rand -hex 32, give every server the same one, and don't change it.TerminalDAL_DEVICE_ID_SECRET=...Call
DesertAnt.configurewith the key and the secret, before the first model loads. Import the/nativebuild in server code. Tongue has no/nativebuild: import it as@desert-ant-labs/tongue.JavaScriptimport { DesertAnt } from "@desert-ant-labs/emo/native"; DesertAnt.configure({ apiKey: process.env.DAL_API_KEY ?? "", deviceIdSecret: process.env.DAL_DEVICE_ID_SECRET, });
Run on a server explains the device id and the secret.
Usage
Create one Emo and reuse it. The SDK downloads the model on first use.
import Emo
let emo = Emo()
let suggestions = try await emo.suggestions(for: "Pay my bills")
suggestions is a suspending function, and use closes the model when the block ends.
import ai.desertant.emo.Emo
Emo(context).use { emo ->
val suggestions = emo.suggestions("Pay my bills")
}
The SDK downloads the model on first use and caches it in the browser.
import { Emo } from "@desert-ant-labs/emo";
const emo = await Emo.load();
const suggestions = await emo.suggestions("Pay my bills");
Pass the id of the end user's device with each call. A device id is any text that stays the same for one device or browser, such as a random id your app makes once and sends with each request.
import { Emo } from "@desert-ant-labs/emo/native";
const emo = await Emo.load();
const suggestions = await emo.suggestions("Pay my bills", { deviceId: request.deviceId });