Open-source legal AI for U.S. lawyers and small firms.
Gary is an open-source legal AI workspace for U.S. lawyers and small firms. It helps create matters, review uploaded documents, run common legal tasks, and export drafts for attorney review.
Gary is self-hostable and uses a bring-your-own-API-key model: you connect your own Anthropic, Google, or OpenAI account, and your documents stay under your control.
Gary is software, not an attorney. It does not provide legal advice and does not replace your professional judgment. Always review every draft, and verify the facts, law, citations, and deadlines before relying on anything Gary produces. See docs/LEGAL_DISCLAIMER.md.
- Solo attorneys and small U.S. law firms.
- Lawyers who want a private, self-hosted AI workspace instead of a SaaS product.
- Non-technical users — setup is documented in plain English in the U.S. Lawyer's Setup Guide.
- Connect AI accounts — bring your own Anthropic (Claude), Google (Gemini), or OpenAI (ChatGPT) API key, and confirm it works with a secure Test Connection.
- Create matters — organize work the way a U.S. law office does, by matter (also called a project).
- Upload documents — add PDFs and Word files for the AI to read.
- Build Review Tables — turn a stack of documents into a sortable table of dates, document types, parties, summaries, and follow-up issues.
- Run Saved Legal Tasks — eight U.S.-focused presets: Contract Review, Litigation Memo, Case Chronology, Discovery Summary, Deposition Prep, Demand Letter Draft, Client Intake Summary, and Privilege Review.
- Export drafts — Copy Draft to the clipboard, or Download Markdown / Download Word Draft, each with an attorney-review reminder.
- Self-host — run Gary on your own infrastructure with your own keys.
- Connect an AI account — add an API key from Anthropic, Google, or OpenAI.
- Create a matter — set up a workspace for a client or case.
- Upload documents — add the PDFs and Word files you want to work with.
- Create a Review Table — let Gary organize the documents into a structured summary.
- Run a Saved Legal Task — generate a first-draft memo, summary, or letter.
- Copy or download the draft — move it into Word, email, or your own template.
- Review before use — check the facts, law, citations, and deadlines yourself.
Gary does not include an AI model and does not resell access to one. You create an account directly with an AI provider (Anthropic, Google, or OpenAI), generate an API key, and paste it into Gary. The key is a private credential that lets Gary send your prompts to that provider on your behalf.
Because you use your own key:
- You control which provider processes your documents.
- Usage is billed by the provider directly to your account, not through Gary.
- The Gary developers never see your key or your documents.
Most providers offer an API privacy setting that keeps API traffic out of public model training. Check your provider's settings and your own confidentiality obligations before uploading client material.
Gary is a fork of MikeOSS by Will Chen. The goal of this fork is to simplify setup, Americanize terminology and legal workflows, and make the platform more approachable for U.S. lawyers and small firms. Specifically, Gary:
- Americanizes British/UK spelling and legal terminology (see docs/US_TERMINOLOGY_MAP.md).
- Renames the product and user-facing branding to Gary.
- Adds a plain-English setup guide and legal disclaimer for U.S. lawyers.
- Adds a guided "Connect AI Accounts" flow with provider cards and a secure Test Connection.
- Adds a first-run "Start Your First Matter" walkthrough.
- Renames workflows as "Saved Legal Tasks" and ships eight U.S.-focused presets.
- Adds a "Matter Document Review" Review Table template with U.S. legal review columns.
- Adds Copy Draft, Download Markdown, and Download Word Draft export actions.
The underlying engine — document analysis, citations, tracked-change editing, and the Review Table system — comes from MikeOSS.
| Area | What it does |
|---|---|
| Connect AI Accounts | Add and test Anthropic, Google, or OpenAI keys. |
| Matters | Organize documents and work by client or case. |
| Document upload | Process PDFs and Word documents for AI review. |
| Review Tables | Summarize documents into a structured, editable table. |
| Saved Legal Tasks | Eight ready-to-run U.S. legal task presets. |
| Draft export | Copy Draft, Download Markdown, Download Word Draft. |
| Self-hosting | Run on your own infrastructure with your own keys. |
- Gary does not do legal research — it has no library of cases or statutes.
- Gary can produce incorrect or incomplete output ("hallucinations"). Every draft needs attorney review.
- Gary does not guarantee accuracy, does not replace legal research, is not "bar-compliant" out of the box, and does not absolutely protect privilege. You are responsible for compliance and confidentiality.
- Setup currently requires a Clerk application, a Supabase project, and an S3-compatible storage bucket.
- DOC/DOCX-to-PDF conversion requires LibreOffice installed on the server.
Planned, not yet built:
- Launch a Saved Legal Task directly from a Review Table row.
- Per-row actions in the Review Table (e.g., "Run as Privilege Review").
- DOCX export polish for the draft-export actions.
- More U.S. legal task presets based on user feedback.
- U.S. Lawyer's Setup Guide — plain-English setup and usage.
- Vercel Deployment Guide — deploy the Gary web app on Vercel.
- Legal Disclaimer — what Gary is and is not.
- U.S. Terminology Map — terminology changes from MikeOSS.
- Safe Local Testing — how to test without real client data.
- docs/README.md — index of all documentation.
The rest of this README is for developers who want to run or self-host Gary.
frontend/— Next.js applicationbackend/— Express API, Supabase access, document processing, and database schemabackend/schema.sql— Supabase schema for fresh databasesbackend/migrations/— incremental database updates for existing deployments
- Node.js 20 or newer
- npm
- git
- A Clerk application (authentication) — create one at https://dashboard.clerk.com
- A Supabase project (database and S3-compatible file storage)
- At least one supported model provider API key: Anthropic, Google Gemini, or OpenAI
- LibreOffice installed locally if you need DOC/DOCX to PDF conversion
For a new Supabase database, open the Supabase SQL editor and run the contents of backend/schema.sql.
For an existing database, do not run the full schema file over production data. Apply the incremental files in backend/migrations/ instead.
Create local env files:
touch backend/.env
touch frontend/.env.localCreate backend/.env:
PORT=3001
FRONTEND_URL=http://localhost:3000
DOWNLOAD_SIGNING_SECRET=replace-with-a-random-32-byte-hex-string
CLERK_SECRET_KEY=sk_test_your-clerk-secret-key
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SECRET_KEY=your-supabase-service-role-key
S3_ENDPOINT_URL=https://your-project.supabase.co/storage/v1/s3
S3_REGION=us-east-1
S3_ACCESS_KEY_ID=your-s3-access-key-id
S3_SECRET_ACCESS_KEY=your-s3-secret-access-key
S3_BUCKET_NAME=gary-documents
GEMINI_API_KEY=your-gemini-key
ANTHROPIC_API_KEY=your-anthropic-key
OPENAI_API_KEY=your-openai-key
RESEND_API_KEY=your-resend-key
USER_API_KEYS_ENCRYPTION_SECRET=your-long-random-secretCreate frontend/.env.local:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_your-clerk-publishable-key
CLERK_SECRET_KEY=sk_test_your-clerk-secret-key
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/login
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/signup
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/assistant
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/assistant
NEXT_PUBLIC_API_BASE_URL=http://localhost:3001
NEXT_PUBLIC_SITE_URL=http://localhost:3000Clerk keys come from the Clerk dashboard under API Keys: the publishable key (pk_…) is browser-safe, the secret key (sk_…) is private — never prefix it with NEXT_PUBLIC_. The backend uses the same CLERK_SECRET_KEY to verify the session tokens the frontend sends. Supabase values come from the Supabase project dashboard; the backend uses the project URL for SUPABASE_URL and the service role key for SUPABASE_SECRET_KEY. The frontend no longer talks to Supabase directly — authentication is Clerk's job.
File storage uses an S3-compatible bucket. Supabase Storage works well: in Supabase open Storage → Settings, enable S3 access, create a bucket, and generate S3 access keys — those become the backend's S3_* values. The S3 endpoint is https://<project-ref>.supabase.co/storage/v1/s3 and S3_REGION is your Supabase project's region. See the Supabase Setup Guide for the full walkthrough.
NEXT_PUBLIC_SITE_URL is optional — it sets the public URL used for social link previews and defaults to http://localhost:3000.
Provider keys are only needed for the models and email features you plan to use. Model provider keys can be configured in backend/.env for the whole instance, or per user in Account > Models & API Keys. If a provider key is present in backend/.env, that provider is available by default and the matching browser API key field is read-only.
npm install --prefix backend
npm install --prefix frontendStart the backend:
npm run dev --prefix backendStart the main app:
npm run dev --prefix frontendOpen http://localhost:3000.
Vercel is the recommended simple deployment path for the Gary web app right now. A few things to know:
- Vercel hosts the Next.js frontend (the
frontend/folder). - Clerk handles authentication; Supabase is still required for the database.
- The backend stays separate — it needs a long-running server and LibreOffice, so deploy it on a host like Railway, Render, or Fly.io rather than on Vercel.
Set the Vercel Root Directory to frontend, leave the build and output
settings at their defaults, and add the public environment variables.
Full step-by-step instructions are in docs/VERCEL_DEPLOYMENT.md.
- Open the app and create your account on the Clerk sign-up screen.
- If you did not set provider keys in
backend/.env, open Account > Models & API Keys and add an Anthropic, Gemini, or OpenAI API key. - Create or open a matter and start working with documents.
Sign-in page shows a Clerk error or never loads. Confirm NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY are set in frontend/.env.local (local) or in your host's environment (deployed). Account sign-up, sign-in, email verification, and password resets are all handled by Clerk — configure them in the Clerk dashboard.
The model picker shows a missing-key warning. Add a key for that provider in Account > Models & API Keys, or configure the provider key in backend/.env and restart the backend.
DOC or DOCX conversion fails. Install LibreOffice locally and restart the backend so document conversion commands are available on the process path.
npm run build --prefix backend
npm run build --prefix frontend
npm run lint --prefix frontendGary is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0-only). See LICENSE.
Gary is a fork of MikeOSS by Will Chen, also distributed under AGPL-3.0. The AGPL license and its attribution requirements are preserved in this fork. Gary is an independent project and is not affiliated with or endorsed by the MikeOSS authors.