> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runanywhere.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Working code on every platform

Install, register a backend, initialize, generate. The same four steps everywhere.

<Tabs>
  <Tab title="Swift" icon="swift">
    ### 1. Install

    Add the package in Xcode via **File → Add Package Dependencies…** with the URL
    `https://github.com/RunanywhereAI/runanywhere-swift`, or declare it:

    ```swift Package.swift theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    dependencies: [
        .package(url: "https://github.com/RunanywhereAI/runanywhere-swift", from: "0.20.24")
    ],
    targets: [
        .target(
            name: "YourApp",
            dependencies: [
                .product(name: "RunAnywhere", package: "runanywhere-swift"),
                .product(name: "RunAnywhereLlamaCPP", package: "runanywhere-swift"),
            ]
        )
    ]
    ```

    Requires iOS 17.5+ or macOS 14.5+.

    ### 2. Register a backend, then initialize

    Register backends **before** `initialize()`. Do it after and the first model load fails
    with "No provider could handle the request".

    ```swift theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    import RunAnywhere
    import RunAnywhereLlamaCPP

    LlamaCPP.register()
    try RunAnywhere.initialize(apiKey: "", baseUrl: "", environment: .development)
    ```

    ### 3. Generate

    ```swift theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    let result = try await RunAnywhere.llm.generate(
        prompt: "Explain on-device AI in one sentence",
        options: LlmOptions(model: "qwen3-0.6b", maxOutputTokens: 100)
    )

    print(result.text)
    ```

    ### 4. Stream

    ```swift theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    for try await event in try await RunAnywhere.llm.generateStream(prompt: "Write a haiku") {
        if case .token(let token) = event { print(token.text, terminator: "") }
    }
    ```

    [Full Swift guide →](/swift/introduction)
  </Tab>

  <Tab title="Kotlin" icon="android">
    ### 1. Install

    ```kotlin build.gradle.kts (Module: app) theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    dependencies {
        implementation("io.github.sanchitmonga22:runanywhere-sdk:0.20.27")
        implementation("io.github.sanchitmonga22:runanywhere-llamacpp:0.20.27")
        implementation("io.github.sanchitmonga22:runanywhere-onnx:0.20.27")
        // QHexRT stops at 0.20.19; it is not published past that
        implementation("io.github.sanchitmonga22:runanywhere-qhexrt-android:0.20.19")
    }
    ```

    Requires API 24+, JDK 17.

    ### 2. Import both packages

    ```kotlin theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    import com.runanywhere.sdk.public.RunAnywhere
    import com.runanywhere.sdk.public.api.*
    ```

    The namespaces are extension properties. Without the second import, `RunAnywhere.llm` does
    not resolve.

    ### 3. Initialize

    ```kotlin theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    class App : Application() {
        override fun onCreate() {
            super.onCreate()
            RunAnywhere.initialize(apiKey = "", baseUrl = "")
        }
    }
    ```

    ### 4. Generate

    ```kotlin theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    val result = RunAnywhere.llm.generate(
        "Explain on-device AI in one sentence",
        LlmOptions(model = "qwen3-0.6b", maxOutputTokens = 100)
    )

    println(result.text)
    ```

    Streaming:

    ```kotlin theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    RunAnywhere.llm.generateStream("Write a haiku").collect { event ->
        if (event is GenerationEvent.Token) print(event.text)
    }
    ```

    [Full Kotlin guide →](/kotlin/introduction)
  </Tab>

  <Tab title="React Native" icon="react">
    ### 1. Install

    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    npm install @runanywhere/core @runanywhere/llamacpp @runanywhere/onnx
    cd ios && pod install
    ```

    Requires React Native 0.83.1, iOS 17.5, Android API 24.

    ### 2. Register a backend, then initialize

    ```ts theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    import { RunAnywhere } from '@runanywhere/core';
    import { LlamaCPP } from '@runanywhere/llamacpp';

    await LlamaCPP.register();
    await RunAnywhere.initialize({});
    ```

    ### 3. Generate

    ```ts theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    const result = await RunAnywhere.llm.generate('Explain on-device AI in one sentence', {
      model: 'qwen3-0.6b',
      maxOutputTokens: 100,
    });

    console.log(result.text);
    ```

    ### 4. Stream

    ```ts theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    for await (const event of RunAnywhere.llm.generateStream('Write a haiku')) {
      if (event.type === 'textDelta') setText((t) => t + event.text);
    }
    ```

    Note that input constructors are plural here: `AudioInputs`, `ImageInputs`.

    [Full React Native guide →](/react-native/introduction)
  </Tab>

  <Tab title="Flutter" icon="flutter">
    ### 1. Install

    ```yaml pubspec.yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    dependencies:
      runanywhere: ^0.20.27
      runanywhere_llamacpp: ^0.20.27
      runanywhere_onnx: ^0.20.27
      # QHexRT publishes at 0.20.19
      runanywhere_qhexrt: ^0.20.19
    ```

    Requires Dart `>=3.12.0`, iOS 17.5, Android API 24.

    ### 2. Register a backend, then initialize

    ```dart theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    import 'package:runanywhere/runanywhere.dart';
    import 'package:runanywhere_llamacpp/runanywhere_llamacpp.dart';

    await LlamaCpp.register();
    await RunAnywhere.initialize(apiKey: '', baseUrl: '');
    ```

    ### 3. Generate

    ```dart theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    final result = await RunAnywhere.llm.generate(
      'Explain on-device AI in one sentence',
      options: LlmOptions(model: 'qwen3-0.6b', maxOutputTokens: 100),
    );

    print(result.text);
    ```

    ### 4. Stream

    ```dart theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    await for (final event in RunAnywhere.llm.generateStream('Write a haiku')) {
      if (event is GenerationEventToken) setState(() => _text += event.text);
    }
    ```

    For a conversation, call `generateChat`, not `generate`. Dart has no overloading.

    [Full Flutter guide →](/flutter/introduction)
  </Tab>

  <Tab title="Web" icon="globe">
    ### 1. Install

    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    npm install @runanywhere/web @runanywhere/web-llamacpp @runanywhere/web-onnx @runanywhere/proto-ts
    ```

    ### 2. Serve the isolation headers

    ```
    Cross-Origin-Opener-Policy: same-origin
    Cross-Origin-Embedder-Policy: require-corp
    ```

    Without these there is no `SharedArrayBuffer` and nothing loads.

    ### 3. Register a backend, then initialize

    ```ts theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    import { RunAnywhere } from '@runanywhere/web';
    import { LlamaCPP } from '@runanywhere/web-llamacpp';

    await LlamaCPP.autoRegister();
    await RunAnywhere.initialize({ environment: 'development' });
    ```

    ### 4. Generate

    ```ts theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    const result = await RunAnywhere.llm.generate('Explain on-device AI in one sentence', {
      model: 'qwen3-0.6b',
      maxOutputTokens: 100,
    });

    console.log(result.text);
    ```

    Streaming:

    ```ts theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    for await (const event of RunAnywhere.llm.generateStream('Write a haiku')) {
      if (event.type === 'textDelta') output.textContent += event.text;
    }
    ```

    [Full Web guide →](/web/introduction)
  </Tab>

  <Tab title="Electron" icon="box">
    ### 1. Install

    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    npm install @runanywhere/electron @runanywhere/electron-llamacpp @runanywhere/electron-onnx
    ```

    ### 2. Construct the facade and initialize

    ```ts main.ts theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    import { createRunAnywhere, NativeBackend } from '@runanywhere/electron'

    const RunAnywhere = createRunAnywhere(new NativeBackend())
    await RunAnywhere.initialize()
    ```

    `initialize()` is single-phase here: one call, no second services phase to await.

    ### 3. Generate

    ```ts theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    const result = await RunAnywhere.llm.generate('Explain on-device AI in one sentence', {
      model: 'qwen3-0.6b',
      maxOutputTokens: 100,
    })

    console.log(result.text, result.tokensPerSecond)
    ```

    Streaming:

    ```ts theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    for await (const event of RunAnywhere.llm.generateStream('Write a haiku')) {
      if (event.type === 'textDelta') process.stdout.write(event.text)
    }
    ```

    ### 4. Reach it from the renderer

    The preload exposes the same facade as `window.runanywhere`, so page code calls the
    identical methods without importing a native addon.

    ```ts renderer.ts theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
    const result = await window.runanywhere.llm.generate('Hello')
    output.textContent = result.text
    ```

    [Full Electron guide →](/electron/introduction)
  </Tab>
</Tabs>

## What happens on the first call

Generation auto-loads whatever it needs. When `options.model` names a model that is not on
disk, the SDK downloads it first, so the first call is slow and later calls are not. To control
when that cost is paid, download and load explicitly:

```swift theme={"theme":{"light":"vitesse-light","dark":"vitesse-black"}}
for try await event in try await RunAnywhere.models.download(id: "qwen3-0.6b") {
    if case .progress(let p) = event { progress = p.fraction ?? 0 }
}
```

## Next

<CardGroup cols={2}>
  <Card title="SDK overview" icon="layer-group" href="/sdks">
    What differs between platforms
  </Card>

  <Card title="Tool calling" icon="wrench" href="/swift/tool-calling">
    Let the model call your functions
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.