npm package: @plexor-dev/plexr
Description: Plexor CLI - Sync Claude MAX OAuth tokens to Plexor API
Author: Plexor
Latest version: 2.0.15

# plexr

**Plexor CLI** - LLM gateway, prompt optimization, and developer tools.

## Installation

```bash
npm install -g @plexor-dev/plexr
```

## Quick Start

```bash
# Set your API key
export PLEXOR_API_KEY="plx_user0_your_key_here"

# Send a prompt
plexr prompt "Explain recursion in one sentence"

# List available models
plexr models

# Check usage & savings
plexr usage
```

## Commands

### LLM Gateway

#### `plexr prompt <text>`

Send a prompt to Plexor's LLM gateway.

```bash
# Basic prompt
plexr prompt "What is the capital of France?"

# With specific model
plexr prompt "Write a haiku" --model gpt-4o

# With system prompt
plexr prompt "Translate to Spanish" --system "You are a translator"

# JSON output
plexr prompt "List 3 colors" --json

# With optimization (compression)
plexr prompt "Long prompt here..." --optimize
```

**Options:**
- `-m, --model <model>` - Model to use (default: claude-sonnet-4-20250514)
- `-o, --optimize` - Apply prompt compression
- `--max-tokens <n>` - Max response tokens (default: 4096)
- `-t, --temperature <n>` - Temperature 0.0-1.0 (default: 0.7)
- `--system <prompt>` - System prompt
- `--json` - Output raw JSON

#### `plexr models`

List all available models grouped by provider.

```bash
plexr models
plexr models --json
```

#### `plexr usage`

Show usage statistics and cost savings.

```bash
plexr usage
plexr usage --json
```

### Token Sync (Claude MAX)

Sync your Claude MAX OAuth token to Plexor, enabling the platform to use your MAX subscription.

#### `plexr sync`

One-time sync of your Claude MAX token.

```bash
plexr sync
plexr sync --force  # Force sync even if unchanged
```

#### `plexr status`

Show token and sync status.

```bash
plexr status
```

#### `plexr watch`

Continuously watch for token changes and auto-sync.

```bash
plexr watch
plexr watch --interval 60  # Check every 60 seconds
```

#### `plexr clear-cache`

Clear the local sync cache.

```bash
plexr clear-cache
```

## Configuration

### Environment Variables

| Variable | Required | Description | Default |
|----------|----------|-------------|---------|
| `PLEXOR_API_KEY` | Yes | Your Plexor API key | - |
| `PLEXOR_API_URL` | No | API endpoint | `https://staging.api.plexor.dev` |

### Setting API Key

**Linux/macOS:**
```bash
echo 'export PLEXOR_API_KEY="plx_user0_your_key"' >> ~/.bashrc
source ~/.bashrc
```

**Windows PowerShell:**
```powershell
[Environment]::SetEnvironmentVariable("PLEXOR_API_KEY", "plx_user0_your_key", "User")
```

## Daemon Setup (Token Sync)

For automatic token sync, run plexr as a background service.

### Linux (systemd)

```bash
# Install service
mkdir -p ~/.config/systemd/user
curl -o ~/.config/systemd/user/plexr.service \
  https://raw.githubusercontent.com/micoverde/plex-vc-fund-platform/main/scripts/plexr.service

# Enable and start
systemctl --user daemon-reload
systemctl --user enable --now plexr.service

# Check logs
journalctl --user -u plexr.service -f
```

### macOS (launchd)

```bash
# Create plist at ~/Library/LaunchAgents/com.plexor.plexr.plist
# Then load:
launchctl load ~/Library/LaunchAgents/com.plexor.plexr.plist
```

### Cron (simple)

```bash
# Sync every 30 minutes
*/30 * * * * PLEXOR_API_KEY=plx_xxx plexr sync >> /tmp/plexr.log 2>&1
```

## Examples

### Daily workflow

```bash
# Morning: check your usage
plexr usage

# Work: send prompts
plexr prompt "Review this code: $(cat myfile.py)"

# Quick questions
plexr prompt "What's the time complexity of quicksort?"
```

### Scripting

```bash
# Pipe input
echo "Summarize this" | xargs plexr prompt

# JSON for parsing
plexr prompt "List 5 programming languages" --json | jq '.content'

# Batch processing
for file in *.txt; do
  plexr prompt "Summarize: $(cat $file)" >> summaries.txt
done
```

## Supported Models

Run `plexr models` to see all available models. Includes:

- **Anthropic**: Claude Opus, Sonnet, Haiku (3.5, 4.0, 4.5)
- **OpenAI**: GPT-4o, GPT-4 Turbo, o1, o3
- **DeepSeek**: deepseek-chat, deepseek-reasoner
- **Mistral**: mistral-large, codestral
- **Google**: Gemini 2.0, 2.5, 3.0

## License

MIT - Plexor Inc.