Files
Beta
Server tools are currently in beta. The API and behavior may change.
The openrouter:files server tool lets any model read, write, edit, and
list the files stored in your OpenRouter workspace through the
Files API. The model decides when to call it; OpenRouter
executes the operation server-side against your workspace and returns the
result.
Enabling the tool
The files tool operates on OpenRouter-hosted files, so it is only active
when the request opts into OpenRouter file handling via the
x-openrouter-file-ids header:
Without this header (or with x-openrouter-file-ids: provider, the current
default), the tool is inert: the model is told that files are unavailable. This
is the same header that controls whether file_id message references are
resolved by OpenRouter or passed through to the upstream provider.
Quick Start
Operations
The model selects an operation via the operation argument:
Edit creates a new file
Editing is copy-on-write: an edit reads the source file, applies the
string replacement, and writes the result as a new file with a new
file_id. The original file is left unchanged, so existing references keep
resolving. The response includes the new file_id and the source_file_id it
was derived from.
Constraints
- Text only. The tool reads and writes UTF-8 text files. Binary files are rejected.
- Size limit. Individual reads and writes are capped at 20 MB.
- Workspace-scoped. All operations run against the workspace of the authenticated request. Anonymous (unauthenticated) callers have no workspace, so the tool is unavailable.
documents/namespace. Files live under your workspace’s default document namespace — the same files surfaced in the Files dashboard.
Pricing
The files tool has no additional cost beyond standard token usage. Stored files count toward your workspace storage quota.
Next Steps
- Server Tools Overview — Learn about server tools
- Files API — Upload and manage workspace files
- Apply Patch — Propose file edits via V4A diffs
- Tool Calling — Learn about user-defined tool calling