fm — command-line
interface for Foundation Models
fm |
[-h] command
[options] |
fm is a command-line interface for 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.
- count-tokens
- Count the tokens in a prompt, instructions, or transcript.
- schema
- Generate a JSON generation schema.
- serve
- Start a Chat Completions API server for Foundation Models.
- models
- Check model availability.
- quota-usage
- Check model quota usage.
- config
- View and edit the CLI configuration.
- license
- Show and agree to the Legal Notice & Terms.
- system
- On-device Apple Foundation Model (default).
- pcc
- Apple Foundation Model on Private Cloud Compute.
- -m, --model
<model>
- Model to use: system, pcc, or a model served by --model-provider (default:
system).
- --model-provider <model provider>
- Chat Completions model provider to use: a name configured with fm config,
or a base URL (e.g. http://host:port/v1). Accepted by respond, chat,
serve, and models.
- --model-provider-header <header>
- Extra request header sent to --model-provider, as 'Name: Value'.
Repeatable; overrides a header stored with a configured model
provider.
- -h,
--help
- Show help information.
- -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.
- --resume <file>
- Continue an earlier conversation by loading a saved transcript, so the
model picks up with its previous turns as context.
- --save-transcript <file>
- Save the session transcript to a file after responding. An absolute path
is used as-is; a bare filename is saved in the current directory.
- --[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.
- --set-ax-screen-reader
- Persist screen reader mode for future fm chat sessions. Can be combined
with --set-default-model; both are written in one update.
- --set-no-ax-screen-reader
- Stop rendering for a screen reader in future fm chat sessions. Mutually
exclusive with --set-ax-screen-reader.
- --set-ax-bell <bool>
- Persist whether screen reader mode rings the terminal bell when a turn
taking more than three seconds finishes. On unless set to false. The
terminal decides whether a bell is audible, visual, or silent.
- --[no-]ax-screen-reader
- Render output for a screen reader: plain lines, with no animation or
cursor redrawing. Overrides the axScreenReader setting in
~/.fm/config.json.
- --transcript <file>
- Path to a saved transcript to count. Its turns are counted as a framed
conversation. A bare prompt is counted as raw content instead.
- -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).
- --model-provider <model provider>
- Chat Completions model provider (name or base URL) that request models
other than system/pcc are routed to. GET /v1/models then lists the
built-in models alongside the model provider's.
- --model-provider-header <header>
- Extra model provider request header, as 'Name: Value'. Repeatable.
fm config reads and writes ~/.fm/config.json. Manage named model
providers with add and remove, set defaults with set, look up one value with
get, and inspect the whole configuration with list or path.
Use 'fm config add model-provider <name> <url>' to
store a model provider (optionally with --model-provider-header), 'fm config
set default-model-provider <name-or-url>' and 'fm config set
default-model <name>' to set the defaults, 'fm config get <key>'
to look up one value, and 'fm config list' or 'fm config path' to inspect
the configuration.
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.
The first time you run fm you must agree to the Foundation Models
CLI Legal Notice & Terms. fm displays them and asks whether you agree;
answer 'yes' or 'y' to agree. Any other response disagrees and fm exits with
status 69 without running the command.
fm license is the one command that is never gated, since it is how
you review the terms and agree to them.
Agreeing applies to every user on the machine, so it must be run
as a privileged user: run 'sudo fm license'.
Run 'sudo fm license' to review and agree, 'fm license --show' to
print the terms without being prompted, and 'fm license --status' to report
whether the machine has agreed.
- ~/.fm/sessions/
- Saved chat sessions and transcripts.
- ~/.fm/config.json
- Per-user settings: the default model, the default model provider, whether
chat renders for a screen reader, whether completion bell is active, and
configured Chat Completions model providers.
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 funny comedian'
Count the tokens in a prompt:
fm count-tokens 'Hello world'
Generate a JSON schema for an object type:
fm schema object --name Person --string name --int age
Respond using a Chat Completions model provider:
fm respond --model-provider http://localhost:1976/api/v1 --model <model> 'Hi'
Store a default model provider and model, then use them with no
flags:
fm config set default-model-provider local && fm config set default-model <model>
Foundation Models framework documentation:
https://developer.apple.com/documentation/foundationmodels