Skip to content

Advanced Topics Bring Your Own Ai

Mr.P edited this page Aug 25, 2026 · 2 revisions

Bring Your Own AI Service

Using your own AI service does not create a separate device workflow. Device connection, AI request events, the SCO or Opus audio path selected by the device, session coordination, and cleanup continue to follow the corresponding AIBuds feature documentation.

The integration difference is authentication and AI processing: the host app authenticates its own service, reports that result to the device, and uses its own AI implementation instead of an SDK-provided AI service.

Self-owned AI authorization handoff

Authenticate the app's AI service, report the result to the device, and then continue the standard device-driven AI flow.

  1. Connect the Device — Establish the normal AIBuds device connection and wait until the required feature APIs are ready.
  2. Authenticate Your AI Service — The host app completes authentication using its own service integration.
  3. Report the Result — Send true when the service is ready, or false when authentication fails or the service is unavailable.
  4. Continue the Standard Flow — The device can continue eligible AI requests and the documented SCO or Opus audio flow after a successful report.
  5. Process with Your AI — Handle the AI request with the app\

What Changes

The host app owns authentication for its AI service and the AI-specific request processing. After each authentication attempt, it reports the current result through reportSelfAiServiceAuthResult.

What Stays the Same

The AIBuds device workflow does not need to be replaced. Continue to use the documented device events, requested audio channel, feature lifecycle, stop handling, and cleanup for AI Chat, AI Audio Recording, Streaming ASR, Simultaneous Interpretation, or the feature being implemented.

For example, when the device requests Opus input, it can send the voice stream only after the self-owned AI service is authorized and the successful result has been reported. When the device requests SCO, the app continues to prepare the documented SCO recording path. Using your own AI service does not change which side selects the audio channel.

Report the Authentication Result

Swift

func selfAIAuthenticationDidFinish(isAuthenticated: Bool) {
    guard let serviceAuthAPI = device as? DeviceServiceAuthAPI else { return }

    // Report only the result. Authentication is completed by the host app.
    serviceAuthAPI.reportSelfAiServiceAuthResult(isAuthenticated) {
        reportSucceeded,
        error in

        guard reportSucceeded else {
            print(error?.localizedDescription ?? "Failed to report authorization")
            return
        }

        // A true result allows the device to continue eligible AI flows.
        // A false result keeps the device informed that the service is unavailable.
    }
}

Objective-C

- (void)selfAIAuthenticationDidFinish:(BOOL)isAuthenticated {
    if (![self.device conformsToProtocol:@protocol(AIBudsDeviceServiceAuthAPI)]) {
        return;
    }

    id<AIBudsDeviceServiceAuthAPI> serviceAuthAPI =
        (id<AIBudsDeviceServiceAuthAPI>)self.device;

    // Report only the result. Authentication is completed by the host app.
    [serviceAuthAPI reportSelfAiServiceAuthResult:isAuthenticated
                                      completion:^(BOOL reportSucceeded,
                                                   NSError *error) {
        if (!reportSucceeded) {
            NSLog(@"%@", error.localizedDescription);
            return;
        }

        // A true result allows the device to continue eligible AI flows.
        // A false result keeps the device informed that the service is unavailable.
    }];
}

See reportSelfAiServiceAuthResult and Report Self-AI Authorization for the complete API contract.

Completion semantics

The completion handler reports whether the Boolean result was delivered to the device. It does not indicate whether the host app successfully authenticated the AI service. Do not send tokens, API keys, or other credentials through this API.

Integration Checklist

  • Authenticate the self-owned AI service in the host app.
  • Report true only when that service is ready for AI requests.
  • Report false after authentication failure or when the service is unavailable.
  • Continue the documented device event, SCO or Opus, session, and cleanup flow for the selected AI feature.
  • Keep credentials inside the app's own secure service integration; report only the Boolean result to the device.

AIBuds SDK iOS Wiki

Clone this wiki locally