4. Call the Inference API
Configure the Airflux SDK to call the Inference API before displaying ads, and use the API response to determine whether to proceed with the ad display. This step may take about 15 minutes to 1 hour.

1. Call the Inference API and configure callbacks
Airflux analyzes player behavior using in-game events and player attribute data to determine the optimal timing for ad displays to maximize revenue. When calling the Inference API before showing an ad to the player, the Airflux AI will return a decision on whether to display the ad or skip it.
The InferenceShowAdInterstitial()
function should be called when the ad is supposed to be shown.
If the API call is successfully processed, the onShowAd
callback function is triggered to show the ad to the player, or the onSkipAd
callback function is triggered to skip the ad for the player.
Airflux.InferenceShowAdInterstitial(
onShowAd: () => { /* Show Ad */ },
onSkipAd: () => { /* Skip Ad */ },
onFailure: (AirfluxError error) => { /* Handle on failure */ }
);
When the API call fails, onFailure
is returned. The API call may fail in the following cases:
The device's country is not in the countryAllowlist: API calls may fail for players in countries not supported by Airflux.
The inference server returns a 4XX or 5XX error response: API calls may fail due to internal server errors or invalid requests.
The API call times out after 3 seconds without a response: Network delays or other issues may cause the API response time to go beyond the limit.
Failure to call the InferenceShowAdInterstitial()
function may lead to degraded play experience and loss of ad revenue. Therefore, it is recommended that a 3-second timeout be set and a fallback be implemented to display ads to the player in case the API call fails, to minimize potential negative effects. Retry attempts upon function call failure are not required.
The fallback should incorporate your internal ad display logic.
Frequently Asked Questions
2. Verify implementation
Ensure that the InferenceShowAdInterstitial()
function is called when the ad is supposed to be shown to the player.
Then, verify that the logic for proceeding with ad display based on the API response is properly implemented. Airflux supports testing API call response scenarios for you to verify proper implementation. The following settings should be used for verification purposes only and must be removed before deploying the app.
Test options
You can simulate specific test scenarios by setting the contexts.inferenceAttributes.forceInferenceResponse
field in the Inference API request.
onShowAd
Test ad display
Always returns true → Ad is shown
onSkipAd
Test ad skip
Always returns false → Ad is skipped
onFailure
Test API failure scenario
Returns HTTP 422 → Client should handle fallback
Attention
The forceInferenceResponse
field MUST be removed in the production environment.
Test setup
Airflux.SetInferenceAttribute("forceInferenceResponse", "onShowAd");
// The following call to Airflux.InferenceShowAdInterstitial() will return "onShowAd"
Airflux.SetInferenceAttribute("forceInferenceResponse", "onSkipAd");
// The following call to Airflux.InferenceShowAdInterstitial() will return "onSkipAd"
Airflux.SetInferenceAttribute("forceInferenceResponse", "onFailure");
// The following call to Airflux.InferenceShowAdInterstitial() will return "onFailure"
Attention
This test setting forcibly manipulates inference responses. If it remains active in the production environment, ads may never be shown or may be constantly shown at every ad placement. Ensure this setting is removed before deploying the app.
Confirm that when the onShowAd
callback is triggered, the ad is displayed, and when the onSkipAd
callback is triggered, the ad is skipped. When the onFailure
callback is triggered, the fallback procedure is operated as intended.
3. Deploy the app
After completing sufficient QA and crash testing, deploy your gaming app. To ensure proper integration with Airflux, make sure the deployment follows the timeline coordinated with the Growth Manager.
Next steps
Congratulations! If you have completed the steps above, you are all set to optimize your in-game advertising with Airflux. Click here to learn how to receive your optimization results.
Last updated