Mobile Apps
Integrate WebInfer into iOS and Android applications
Preview
Connect Your AI
WebInfer's mobile SDKs use the same OAuth flow as web applications, allowing users to "Connect their AI" - similar to "Sign in with Google" but for AI capabilities. Users bring their own WebInfer Cloud account, and your app uses their configured providers and credits.
Users control their providers, API keys, and spending. Your app doesn't need any AI credentials.
Access text, image, speech, and embedding generation. Tool calling runs locally in your app.
Tokens are bound to your app's bundle ID, preventing unauthorized use from other apps.
How It Works
- 1
User taps "Connect Your AI"
Your app calls
connectCloud()which opens a secure browser - 2
User signs in and authorizes
They see your app name, requested permissions, and their bundle ID
- 3
App receives tokens
Access and refresh tokens are securely stored in the device keychain
- 4
Make AI requests
All requests automatically use the user's credentials and count against their quota
React Native
The @webinfer/react-native package provides hooks and utilities for React Native apps, with automatic platform detection and secure token storage.
npm install @webinfer/react-native# Required peer dependenciesnpm install react-native-keychain react-native-inappbrowser-rebornimport { useCloudAuth, generateText } from '@webinfer/react-native'import { Button, Text, View } from 'react-native'function AIFeature() { const { connected, loading, connect, disconnect } = useCloudAuth() const [response, setResponse] = useState('') const handleGenerate = async () => { const result = await generateText({ prompt: 'Explain quantum computing briefly', maxTokens: 200, }) setResponse(result.text) } if (!connected) { return ( <Button title={loading ? 'Connecting...' : 'Connect Your AI'} onPress={connect} disabled={loading} /> ) } return ( <View> <Text>Connected ✓</Text> <Button title="Generate" onPress={handleGenerate} /> <Text>{response}</Text> <Button title="Disconnect" onPress={() => disconnect()} /> </View> )}import { connectCloud, disconnectCloud, isCloudConnected } from '@webinfer/react-native'// With custom optionsconst result = await connectCloud({ // Optional: Your registered OAuth app client ID clientId: 'webinfer_your_app_id', // Requested permission scopes scopes: ['inference', 'inference:image'], // App context is auto-detected from bundle ID // but can be overridden if needed context: { type: 'ios', appIdentifier: 'com.yourcompany.app', teamId: 'ABC123XYZ', // iOS only },})console.log('Connected:', result.connected)console.log('Scopes:', result.scopes)console.log('Expires:', new Date(result.expiresAt))iOS Native (Swift)
For native iOS apps, a Swift SDK will be available via Swift Package Manager.
Coming Soon
import WebInferimport SwiftUIstruct ContentView: View { @StateObject private var webinfer = WebInferClient() @State private var response = "" var body: some View { VStack { if webinfer.isConnected { Text("Connected ✓") Button("Generate") { Task { let result = try await webinfer.generateText( prompt: "Explain quantum computing", maxTokens: 200 ) response = result.text } } Text(response) } else { Button("Connect Your AI") { Task { try await webinfer.connect( scopes: [.inference] ) } } } } }}Android Native (Kotlin)
For native Android apps, a Kotlin SDK will be available via Maven Central.
Coming Soon
import dev.webinfer.WebInferClientimport dev.webinfer.Scopeclass MainActivity : ComponentActivity() { private val webinfer = WebInferClient(this) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { var connected by remember { mutableStateOf(webinfer.isConnected) } var response by remember { mutableStateOf("") } Column { if (connected) { Text("Connected ✓") Button(onClick = { lifecycleScope.launch { val result = webinfer.generateText( prompt = "Explain quantum computing", maxTokens = 200 ) response = result.text } }) { Text("Generate") } Text(response) } else { Button(onClick = { lifecycleScope.launch { webinfer.connect(scopes = listOf(Scope.INFERENCE)) connected = true } }) { Text("Connect Your AI") } } } } }}App Registration
Like web OAuth, mobile apps can work with or without registration:
- Users see your bundle ID during authorization
- Quick to get started - no setup required
- Good for development and testing
- Users see your app name and logo
- Usage analytics in developer dashboard
- Configure allowed bundle IDs/package names
- 1.Go to OAuth Applications in settings
- 2.Create a new app or edit an existing one
- 3.Add your iOS Bundle ID (e.g.,
com.yourcompany.app) - 4.Add your Android Package Name (e.g.,
com.yourcompany.app) - 5.Use your Client ID in the SDK configuration
Security Considerations
Mobile tokens are bound to your app identifier, preventing use from other apps:
- iOS: Bound to Bundle ID + Team ID
- Android: Bound to Package Name + Signing Certificate
Tokens are stored securely using platform-native secure storage:
- iOS: Keychain Services
- Android: EncryptedSharedPreferences (AndroidX Security)
- React Native: react-native-keychain
Mobile requests include context headers for validation:
POST /g/{gatewayId}/chat/completionsAuthorization: Bearer wlm-app-xxx.eyJ...X-WebInfer-Context: iosX-WebInfer-App-Id: com.yourcompany.appX-WebInfer-Team-Id: ABC123XYZAPI Reference
React hook for managing cloud authentication state.
Returns:
connected: boolean- Whether user is connectedloading: boolean- Auth flow in progresserror: Error | null- Last errorconnect(): Promise- Start OAuth flowdisconnect(options?): Promise- Disconnect and optionally revokestatus: ConnectionStatus- Detailed connection info