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

# Quick Start

> Build your first AI feature in minutes

## 1. Register a backend, then initialize

```ts theme={"theme":"css-variables"}
import { RunAnywhere } from '@runanywhere/core'
import { LlamaCPP } from '@runanywhere/llamacpp'

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

`InitializeOptions` is `{ apiKey?, baseUrl?, environment? }`. Omit `apiKey` for keyless local
mode.

## 2. Generate text

```ts theme={"theme":"css-variables"}
const result = await RunAnywhere.llm.generate('Explain quantum computing in one paragraph', {
  model: 'qwen3-0.6b',
  maxOutputTokens: 200,
})

console.log(result.text)
```

## 3. Stream it instead

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

## 4. Hold a conversation

`generate` takes a string or a message array.

```ts theme={"theme":"css-variables"}
const reply = await RunAnywhere.llm.generate([
  { role: 'system', content: 'You are a concise assistant.' },
  { role: 'user', content: 'What is on-device inference?' },
  { role: 'assistant', content: 'Running the model on your own hardware.' },
  { role: 'user', content: 'Why does that matter?' },
])
```

## 5. Add speech

```ts theme={"theme":"css-variables"}
import { ONNX } from '@runanywhere/onnx'
import { AudioInputs } from '@runanywhere/core'

await ONNX.register()

const transcription = await RunAnywhere.stt.transcribe(AudioInputs.file(path))
RunAnywhere.tts.speak('Ready when you are')
```

Note the plural `AudioInputs`, and that `tts.speak` is synchronous here.

## A complete screen

```tsx theme={"theme":"css-variables"}
import { RunAnywhere, SDKException } from '@runanywhere/core'
import { LlamaCPP } from '@runanywhere/llamacpp'
import { useCallback, useEffect, useRef, useState } from 'react'
import { Button, ScrollView, Text, TextInput, View } from 'react-native'

export function ChatScreen(): React.JSX.Element {
  const [ready, setReady] = useState(false)
  const [prompt, setPrompt] = useState('')
  const [reply, setReply] = useState('')
  const [busy, setBusy] = useState(false)
  const cancelled = useRef(false)

  useEffect(() => {
    ;(async () => {
      await LlamaCPP.register()
      await RunAnywhere.initialize({})
      setReady(true)
    })()

    return () => {
      cancelled.current = true
    }
  }, [])

  const send = useCallback(async () => {
    setBusy(true)
    setReply('')
    try {
      for await (const event of RunAnywhere.llm.generateStream(prompt)) {
        if (cancelled.current) break
        if (event.type === 'textDelta') setReply((t) => t + event.text)
      }
    } catch (error) {
      setReply(error instanceof SDKException ? error.message : String(error))
    } finally {
      setBusy(false)
    }
  }, [prompt])

  return (
    <View style={{ flex: 1, padding: 16 }}>
      <ScrollView style={{ flex: 1 }}>
        <Text>{reply}</Text>
      </ScrollView>
      <TextInput value={prompt} onChangeText={setPrompt} placeholder="Ask something" />
      <Button title="Send" onPress={send} disabled={!ready || busy || !prompt} />
    </View>
  )
}
```

The `cancelled` ref is what stops the loop writing state after the screen unmounts.

## Next

> [card] [Managing models](https://docs.runanywhere.ai/react-native/configuration.md)
>
> Download, load, and storage

> [card] [Tool calling](https://docs.runanywhere.ai/react-native/tool-calling.md)
>
> Let the model call your functions

> [card] [Voice agent](https://docs.runanywhere.ai/react-native/voice-agent.md)
>
> A full spoken conversation

> [card] [Error handling](https://docs.runanywhere.ai/react-native/error-handling.md)
>
> What throws and when


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