sdk/runanywhere-react-native/packages/llamacpp/README.md
Llama.cpp backend registration package for the RunAnywhere React Native SDK.
This package does not own public model catalog, download, lifecycle,
generation, VLM, LoRA, tool-calling, or structured-output APIs. Those surfaces
live in @runanywhere/core over the generated proto/Nitro/commons bridge,
mirroring the Swift architecture source of truth.
@runanywhere/llamacpp only installs or removes the native llama.cpp backend
providers and ships the RABackendLLAMACPP native binary.
@runanywhere/core peer dependencynpm install @runanywhere/core @runanywhere/llamacpp
For iOS, run CocoaPods from the app:
cd ios && pod install && cd ..
Android native libraries are packaged by the React Native package.
import { RunAnywhere } from '@runanywhere/core';
import {
InferenceFramework,
ModelCategory,
ModelLoadRequest,
} from '@runanywhere/proto-ts/model_types';
import { LlamaCPP } from '@runanywhere/llamacpp';
await RunAnywhere.initialize();
const registered = await LlamaCPP.register();
if (!registered) {
throw new Error('llama.cpp backend is not available');
}
await RunAnywhere.registerModel({
id: 'smollm2-360m-q8_0',
name: 'SmolLM2 360M Q8_0',
framework: InferenceFramework.INFERENCE_FRAMEWORK_LLAMA_CPP,
url: 'https://example.invalid/model.gguf',
});
const download = RunAnywhere.downloadModel('smollm2-360m-q8_0')[Symbol.asyncIterator]();
while (!(await download.next()).done) {}
await RunAnywhere.loadModel(ModelLoadRequest.fromPartial({
modelId: 'smollm2-360m-q8_0',
category: ModelCategory.MODEL_CATEGORY_LANGUAGE,
}));
const result = await RunAnywhere.generate('Write one sentence about local AI.');
console.log(result.text);
import { LlamaCPP } from '@runanywhere/llamacpp';
LlamaCPP.register()Registers llama.cpp LLM and VLM providers with the native backend registry.
LlamaCPP.register(): Promise<boolean>
LlamaCPP.unregister()Unregisters llama.cpp LLM and VLM providers. Core-owned model lifecycle handles remain owned by core.
LlamaCPP.unregister(): Promise<boolean>
LlamaCPP.isRegistered()Checks native backend registration state.
LlamaCPP.isRegistered(): Promise<boolean>
LlamaCPP.moduleId
LlamaCPP.moduleName
LlamaCPP.inferenceFramework
LlamaCPP.capabilities
LlamaCPP.defaultPriority
The generated Nitro spec exposes only backend registration hooks:
registerBackendunregisterBackendisBackendRegisteredregisterVLMBackendunregisterVLMBackendisVLMBackendRegisteredDirect llama.cpp model loading, generation, structured-output, and VLM process
bridges were deleted. Use @runanywhere/core for public model lifecycle and
inference APIs.
packages/llamacpp/
|-- src/
| |-- index.ts
| |-- LlamaCPP.ts
| |-- LlamaCppProvider.ts
| |-- native/
| | `-- NativeRunAnywhereLlama.ts
| `-- specs/
| `-- RunAnywhereLlama.nitro.ts
|-- cpp/
| |-- HybridRunAnywhereLlama.cpp
| `-- HybridRunAnywhereLlama.hpp
|-- ios/
| `-- Binaries/
| `-- RABackendLLAMACPP.xcframework
|-- RunAnywhereLlama.podspec
|-- android/
| |-- build.gradle
| `-- CMakeLists.txt
`-- nitrogen/
`-- generated/