Using for Free

With "free" in the name FreeToken you are right to expect that you can use it for free. This article describes what is free and what is not.

Free Features

Using localChat or generateLocalCompletion with the client is completely free. You can use it as much as you want without any limitations. This lets you skip all the complexity of implementing on-device LLM client and focus on building your app.

In order to use the client you'll need to:

  1. Add the FreeToken SDK into your App
  2. Register the device with a Device Session Registration
  3. Download the AI model

These features will incur no costs on the platform.

Example of Free Usage

import FreeToken

// Configure the FreeToken client
let client = FreeToken.shared.config(
    appToken: "your_app_token"
)

// Register the device session:
await client.registerDeviceSession(
  scope: "free-example",
  success: {
    print("Device session registered")
    await downloadModel()
  },
  failure: { error in
    print("Failed to register device session: \(error)")
  }
)

// Download the model
func downloadModel() async {
    await client.downloadAIModel(
      success: {
        runAI()
      },
      error: { error in
        print("Failed to download model: \(error)")
      }
    )
}

func runAI() async throws {
  let message = FreeToken.Message(role: .user, content: "Hello, how are you?")

  do {
    let resultMessage = try await client.localChat(messages: [message])
  } catch {
    print("Error during local chat: \(error)")
  }

  print("AI Response: \(resultMessage.content)")
}