Skip to main content
On iOS 26+, macOS 26+, and visionOS 26+, the Figranium Swift SDK provides RunFigraniumTaskTool, a constrained Foundation Models tool that lets Apple Intelligence invoke pre-approved browser automation tasks. The tool is compiled only when FoundationModels and FoundationModelsMacros are available, so it does not affect builds on earlier platforms.
This feature requires import FoundationModels and the @Generable macro from FoundationModelsMacros. It is unavailable on tvOS, watchOS, and earlier Apple platform versions.

Tool overview

RunFigraniumTaskTool exposes a single callable action named run_figranium_task. The model can only invoke tasks you explicitly allow through allowedTaskIDs. The tool returns a JSON-encoded ExecutionResult<JSONValue> string, so the model receives structured outcome data without direct access to browser internals or credentials.
RunFigraniumTaskTool.swift
Tool parameters:
String
required
The identifier of a pre-approved Figranium task to run. The model receives this as a guided parameter.
Returns: A JSON-encoded ExecutionResult<JSONValue> string. If encoding fails, it returns "{}". Throws: FigraniumError with code TASK_NOT_ALLOWED if the requested taskID is not in allowedTaskIDs.

Attach the tool to a language model session

Create a tool instance with your client and an allowlist, then pass it into a LanguageModelSession.
FoundationModelsExample.swift
The model decides when to invoke the tool based on the user prompt. Because only taskID is exposed, the model cannot construct arbitrary actions or access credentials.

Availability guard

Because the tool is conditionally compiled, wrap usage in an availability check or keep it in a file compiled only for the supported platforms.

Error reference