WebInfer

Mobile Apps

Integrate WebInfer into iOS and Android applications

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.

User-Owned AI

Users control their providers, API keys, and spending. Your app doesn't need any AI credentials.

Full Capabilities

Access text, image, speech, and embedding generation. Tool calling runs locally in your app.

App-Bound Tokens

Tokens are bound to your app's bundle ID, preventing unauthorized use from other apps.

How It Works

  1. 1

    User taps "Connect Your AI"

    Your app calls connectCloud() which opens a secure browser

  2. 2

    User signs in and authorizes

    They see your app name, requested permissions, and their bundle ID

  3. 3

    App receives tokens

    Access and refresh tokens are securely stored in the device keychain

  4. 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.

Installation
terminal
npm install @webinfer/react-native# Required peer dependenciesnpm install react-native-keychain react-native-inappbrowser-reborn
Basic Usage
Use the useCloudAuth hook to manage authentication
App.tsx
import { 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>  )}
Custom Configuration
Configure scopes, client ID, and OAuth behavior
CustomAuth.tsx
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.

Planned API
Swift SDK interface (preview)
ContentView.swift
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.

Planned API
Kotlin SDK interface (preview)
MainActivity.kt
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:

Without Registration
  • Users see your bundle ID during authorization
  • Quick to get started - no setup required
  • Good for development and testing
With Registration
  • Users see your app name and logo
  • Usage analytics in developer dashboard
  • Configure allowed bundle IDs/package names
Register Your App
Configure mobile identifiers in OAuth settings
  1. 1.Go to OAuth Applications in settings
  2. 2.Create a new app or edit an existing one
  3. 3.Add your iOS Bundle ID (e.g., com.yourcompany.app)
  4. 4.Add your Android Package Name (e.g., com.yourcompany.app)
  5. 5.Use your Client ID in the SDK configuration

Security Considerations

Token Binding

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
Secure Storage

Tokens are stored securely using platform-native secure storage:

  • iOS: Keychain Services
  • Android: EncryptedSharedPreferences (AndroidX Security)
  • React Native: react-native-keychain
Request Headers

Mobile requests include context headers for validation:

HTTP Headers
POST /g/{gatewayId}/chat/completionsAuthorization: Bearer wlm-app-xxx.eyJ...X-WebInfer-Context: iosX-WebInfer-App-Id: com.yourcompany.appX-WebInfer-Team-Id: ABC123XYZ

API Reference

useCloudAuth(options?)

React hook for managing cloud authentication state.

Returns:

  • connected: boolean - Whether user is connected
  • loading: boolean - Auth flow in progress
  • error: Error | null - Last error
  • connect(): Promise - Start OAuth flow
  • disconnect(options?): Promise - Disconnect and optionally revoke
  • status: ConnectionStatus - Detailed connection info