Run AI prediction functions (a.k.a "predictors") in your Unity apps and games. With Function, you can build AI-powered apps by creating and composing GPU-accelerated predictors that run in the cloud. In a few steps:
Add the following items to your Unity project's Packages/manifest.json
:
{
"scopedRegistries": [
{
"name": "Function",
"url": "https://registry.npmjs.com",
"scopes": ["ai.fxn"]
}
],
"dependencies": {
"ai.fxn.fxn3d": "0.0.23"
}
}
Important
When building for WebGL, make sure that the Enable Exceptions
setting in Player Settings > Publishing Settings is set to Full With Stacktrace
. Other exception modes will currently raise errors.
Head over to fxn.ai to create an account by logging in. Once you do, generate an access key:
Then add it to your Unity project in Project Settings > Function
:
Caution
If your Unity project is open-source, make sure to add ProjectSettings/Function.asset
to your .gitignore
file to keep your Function access key private.
First, create a Function client:
using Function;
// Create a Function client
var fxn = FunctionUnity.Create();
Then make a prediction:
// Make a prediction
var prediction = await fxn.Predictions.Create(
tag: "@samples/greeting",
inputs: new () {
["name"] = "Roberta"
}
);
// Log the result
Debug.Log(prediction.results[0]);
Tip
Explore public predictors on Function or create your own.
- Unity 2021.3+
- Android API Level 24+
- iOS 14+
- macOS 10.15+ (Apple Silicon and Intel)
- Windows 10+ (64-bit only)
- WebGL:
- Chrome 91+
- Firefox 90+
- Safari 16.4+
- Discover predictors to use in your apps.
- Join our Discord community.
- Check out our docs.
- Learn more about us on our blog.
- Reach out to us at [email protected].
Thank you very much!