> ## Documentation Index
> Fetch the complete documentation index at: https://docs.case.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Manage Case.dev resources from the command line

The Case.dev CLI (`casedev`) gives you full access to the Case.dev API from your terminal. Every API operation is exposed as a CLI command, making it easy to script workflows, test integrations, and manage resources without writing code.

## Installation

<CodeGroup>
  ```bash title="Homebrew (recommended)" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  brew install CaseMark/casedev/casedev
  ```

  ```bash title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  go install github.com/CaseMark/casedev-cli/cmd/casedev@latest
  ```
</CodeGroup>

Pre-built binaries for macOS, Linux, and Windows are available on [GitHub Releases](https://github.com/CaseMark/casedev-cli/releases).

### Verify installation

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
casedev --version
```

## Authentication

The CLI reads your API key from the `CASEDEV_API_KEY` environment variable. Get your key from the [Case.dev dashboard](https://app.case.dev).

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
export CASEDEV_API_KEY=sk_case_YOUR_API_KEY
```

<Tip>
  Add the export to your shell profile (`~/.bashrc`, `~/.zshrc`, etc.) so it persists across
  sessions.
</Tip>

API keys starting with `sk_case_` are production keys. Development keys are available for testing.

## Quick Start

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
# Chat with an LLM
casedev llm:v1:chat create-completion \
  --model anthropic/claude-sonnet-4.6 \
  --message '{"role":"user","content":"Summarize this contract..."}'

# Search a vault
casedev vault search \
  --id vault_abc123 \
  --query "termination clauses"

# List available models
casedev llm:v1 list-models

# Run OCR on a document already accessible by URL
casedev ocr:v1 process --document-url https://example.com/contract.pdf

# Transcribe audio already accessible by URL
casedev voice:transcription create --audio-url https://example.com/deposition.mp3
```

<Note>
  OCR and voice transcription accept URLs, not local file paths. To process a local file, upload it
  to a vault first (see [File uploads](#file-uploads) below), then pass the vault-generated
  presigned URL — or the `--vault-id` / `--object-id` pair, where supported — into the processing
  command.
</Note>

## Command Structure

Commands follow a `resource[:version][:sub] action` pattern that mirrors the API. Resource names use colons, not slashes:

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
casedev llm:v1:chat create-completion    # LLM chat
casedev vault search                     # Vault search
casedev ocr:v1 process                   # OCR processing
casedev voice:transcription create       # Voice transcription
casedev legal:v1 find                    # Legal research
casedev search:v1 answer                 # Web search AI answer
```

List all available resources with `casedev --help`, and inspect a resource's subcommands with `casedev <resource> --help`:

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
casedev --help
casedev vault --help
casedev llm:v1:chat create-completion --help
```

## Output Formats

Control how results are displayed with the `--format` global flag (`auto`, `explore`, `json`, `jsonl`, `pretty`, `raw`, `yaml`):

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
# JSON output (pipe-friendly)
casedev llm:v1 list-models --format json

# YAML output
casedev llm:v1 list-models --format yaml

# Interactive explorer
casedev llm:v1 list-models --format explore
```

JSON output works well with tools like `jq`:

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
casedev llm:v1 list-models --format json | jq '.data[].id'
```

You can also reshape output with the `--transform` flag, which accepts a [GJSON](https://github.com/tidwall/gjson) path:

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
casedev llm:v1 list-models --transform 'data.#.id'
```

## File uploads

The CLI does **not** accept local file paths as a `--file` argument. Uploads happen directly to S3 via a short-lived presigned URL. The flow is always:

1. Request a presigned upload URL from the vault (`casedev vault upload ...`).
2. `PUT` the file bytes to that URL (e.g. with `curl`).
3. Confirm the upload to record the final size and ETag (`casedev vault confirm-upload ...`).
4. Trigger ingestion if your vault has indexing enabled (`casedev vault ingest ...`).

```bash title="Upload a local PDF to a vault" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
VAULT_ID=vault_abc123
FILE=./contract.pdf
SIZE=$(wc -c < "$FILE" | tr -d ' ')

# 1. Request a presigned upload URL
UPLOAD=$(casedev vault upload \
  --id "$VAULT_ID" \
  --filename "contract.pdf" \
  --content-type "application/pdf" \
  --size-bytes "$SIZE" \
  --auto-index \
  --format json)

OBJECT_ID=$(echo "$UPLOAD" | jq -r '.objectId')
UPLOAD_URL=$(echo "$UPLOAD" | jq -r '.uploadUrl')

# 2. Upload the bytes directly to S3
curl -X PUT \
  -H "Content-Type: application/pdf" \
  --data-binary "@$FILE" \
  "$UPLOAD_URL"

# 3. Confirm the upload
casedev vault confirm-upload \
  --id "$VAULT_ID" \
  --object-id "$OBJECT_ID" \
  --success \
  --size-bytes "$SIZE"

# 4. Trigger ingestion (skip if --auto-index was not set or the vault is storage-only)
casedev vault ingest --id "$VAULT_ID" --object-id "$OBJECT_ID"
```

For files larger than 5 GB, use `casedev vault:multipart get-part-urls` to obtain per-part presigned URLs and upload each part separately.

See [Vault uploads](/vault/upload) for the complete reference, including multipart uploads and error handling.

### OCR and voice transcription with local files

Neither `ocr:v1 process` nor `voice:transcription create` accept local file paths. Two paths work:

* **Already-hosted file**: pass `--document-url` (OCR) or `--audio-url` (voice) pointing to a publicly reachable HTTPS URL or a presigned S3 URL.
* **Local file**: upload it to a vault first (flow above), then either pass the vault's presigned download URL or — for voice transcription — the `--vault-id` + `--object-id` pair directly.

```bash title="OCR a local PDF via vault" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
# After the upload flow above:
PRESIGNED=$(casedev vault:objects create-presigned-url \
  --id "$VAULT_ID" \
  --object-id "$OBJECT_ID" \
  --operation GET \
  --expires-in 3600 \
  --transform 'presignedUrl')

casedev ocr:v1 process --document-url "$PRESIGNED"
```

```bash title="Transcribe a local audio file via vault" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
# Voice transcription can read directly from the vault without a presigned URL.
casedev voice:transcription create \
  --vault-id "$VAULT_ID" \
  --object-id "$OBJECT_ID" \
  --speaker-labels \
  --punctuate
```

## Piping and stdin

Most commands accept a JSON (or YAML) body on stdin. Any unset flag is filled from the stdin object, so you can compose commands without building long flag lists:

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
# Pipe a full JSON payload
echo '{"model":"anthropic/claude-sonnet-4.6","messages":[{"role":"user","content":"Hello"}]}' \
  | casedev llm:v1:chat create-completion

# Chain commands: summarize vault search results
casedev vault search --id vault_abc123 --query "liability" --format json \
  | jq '{model:"anthropic/claude-sonnet-4.6", messages:[{role:"user", content:(.results[0].content // "no results")}]}' \
  | casedev llm:v1:chat create-completion
```

## Shell completions

Enable tab completions for your shell:

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
# Bash
casedev completion bash > /etc/bash_completion.d/casedev

# Zsh
casedev completion zsh > "${fpath[1]}/_casedev"

# Fish
casedev completion fish > ~/.config/fish/completions/casedev.fish
```

Restart your shell or source the completion file to activate.

## Debugging

Use `--debug` to see full HTTP request and response details:

```bash title="Shell" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
casedev vault search --id vault_abc123 --query "test" --debug
```

This prints request headers, body, response status, and timing information to stderr.

<Warning>
  Debug output may contain your API key and sensitive request payloads. Redact credentials and
  confidential data before sharing logs externally.
</Warning>

## Upgrading

<CodeGroup>
  ```bash title="Homebrew" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  brew upgrade casedev
  ```

  ```bash title="Go" theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
  go install github.com/CaseMark/casedev-cli/cmd/casedev@latest
  ```
</CodeGroup>

## Repositories

* **CLI source:** [github.com/CaseMark/casedev-cli](https://github.com/CaseMark/casedev-cli)
* **Homebrew tap:** [github.com/CaseMark/homebrew-casedev](https://github.com/CaseMark/homebrew-casedev)

## Next Steps

<CardGroup>
  <Card title="SDKs" icon="package" href="/sdks">
    Official client libraries for TypeScript, Python, and Go
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference">
    Complete API documentation with interactive examples
  </Card>

  <Card title="Getting Started" icon="play" href="/getting-started">
    Integration tutorials with step-by-step examples
  </Card>
</CardGroup>
