# opencode-quota

OpenCode plugin that fetches subscription quotas for ChatGPT Codex, Google Antigravity, and z.ai.

## Features

- `/quotas` command for all providers
- `/quotas <provider>` for a single provider
- Returns markdown summaries plus raw JSON
- Reads tokens from OpenCode and auth plugins

## Installation in OpenCode

Create or edit `~/.config/opencode/opencode.json`:

```json
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-quota"]
}
```

For local development, use a relative path:

```json
{
  "plugin": ["./path/to/opencode-quota"]
}
```

## Provider Setup

### ChatGPT Codex

- Install the `opencode-openai-codex-auth` plugin, or ensure `openai` auth exists in
  `~/.local/share/opencode/auth.json`.
- The plugin also checks `~/.opencode/auth/openai.json` as a fallback.

### Google Antigravity

- Install an Antigravity auth plugin (for example, `opencode-antigravity-auth`).
- Ensure accounts are stored in `~/.config/opencode/antigravity-accounts.json`.
- The first configured account is used for quota checks.

### z.ai

- Add a `zai` or `z.ai` entry in `~/.local/share/opencode/auth.json` with the API key, or
  set `ZAI_API_KEY`.

## Usage

```bash
/quotas
/quotas codex
/quotas antigravity
/quotas zai
```

## Output

- `markdown`: human-readable summary
- `json`: provider-specific quota data

## Development

```bash
bun install
mise run build
mise run test
mise run lint
```

## Author

Nelson Pires <nelsonpires.sn@gmail.com>

## Repository

https://github.com/nelsonPires5/opencode-quota

## License

MIT License. See the [LICENSE](LICENSE) file for details.
