fm — command-line
interface for Apple Foundation Models
fm |
[-h] command
[options] |
fm is a command-line interface for Apple Foundation Models. It
generates responses from Apple's on-device and Private Cloud Compute
language models, counts tokens, generates JSON generation schemas, checks
model availability and quota usage, and hosts a Chat Completions API
server.
By default every command uses the on-device system model. Pass
--model pcc to run against the Apple Foundation Model on Private Cloud
Compute instead.
Run 'fm <command> --help' for detailed help on an individual
command.
- respond
- Generate a response to a prompt.
- chat
- Start an interactive chat session.
- token-count
- Count the tokens in a prompt, instructions, or saved transcript.
- schema
- Generate a JSON generation schema.
- serve
- Start a Chat Completions API server for Foundation Models.
- available
- Check model availability.
- quota-usage
- Check model quota usage.
- system
- On-device Apple Foundation Model (default).
- pcc
- Apple Foundation Model on Private Cloud Compute.
- -i, --instructions
<text>
- Instructions for the model to follow.
- --schema <file>
- Path to a JSON schema file, or an inline JSON schema string.
- --text <text>
- Text segment to include in the prompt.
- --image <path>
- Path to an image to include in the prompt.
- --load-transcript <file>
- Path to a saved transcript for conversational context.
- --save-transcript <name>
- Save the session transcript to ~/.fm/sessions/<name> after
responding.
- --[no-]stream
- Stream the output as it is generated (default: on).
- -g,
--greedy
- Use greedy sampling.
- -v,
--verbose
- Print verbose output.
- --use-case <case>
- System model use case: general or content-tagging.
- --guardrails <level>
- System model guardrail level: default or
permissive-content-transformations.
- -r, --resume
<session>
- Resume a saved chat session.
- --continue
- Continue the most recent chat session.
- -i,
--instructions <text>
- Instructions for the model.
- --set-default-model <model>
- Persist <model> as the default for future fm chat sessions.
- -q,
--quiet
- Print only the integer count (automatic when stdout is piped or
redirected).
- --host <address>
- Host address to bind to (TCP mode).
- --port <port>
- Port to listen on, 1-65535 (TCP mode).
- --socket <path>
- Unix domain socket path (socket mode).
fm schema object generates a JSON generation schema for an object
type. Each --string, --integer, --double, or --boolean starts a new
property; follow it with --description, --optional, and/or --array to
annotate it. Use dot notation (a.b) in property names to nest objects.
fm schema object --help documents the full property-declaration
syntax.
Generate a response with the on-device model:
fm respond 'What is Swift?'
Stream a response from Private Cloud Compute:
fm respond --model pcc --stream 'Summarize this article'
Start an interactive chat with custom instructions:
fm chat --instructions 'You are a coding assistant'
Count the tokens in a prompt:
fm token-count 'Hello world'
Generate a JSON schema for an object type:
fm schema object --name Person --string name --int age
Foundation Models documentation:
https://developer.apple.com/documentation/foundationmodels