npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@openpets/anthropic

v1.0.4

Published

OpenPets plugin for the Anthropic API. Create messages, manage batches, count tokens, and manage your organization with Admin API. Includes organization management, workspace control, usage/cost reports, and more.

Downloads

66

Readme

Anthropic Pet

OpenPets plugin for the Anthropic API. Interact with Claude AI models AND manage your organization programmatically.

Features

Claude AI Features (requires ANTHROPIC_API_KEY)

  • Messages API - Send messages to Claude and receive responses
  • Token Counting - Count tokens in messages before sending
  • Message Batches - Create and manage batches for async processing
  • Beta Features - Access beta endpoints for prompt caching and more

Admin Features (requires ANTHROPIC_ADMIN_API_KEY)

  • Organization Management - View org details, manage members, send invites
  • Workspace Management - Create, update, archive workspaces
  • Workspace Members - Manage team access per workspace
  • API Key Management - List, monitor, and update API keys
  • Usage & Cost Reports - Detailed analytics on token usage and costs
  • Claude Code Analytics - Track Claude Code usage

Quick Start

1. Get API Keys

For Claude AI (Required):

For Admin Features (Optional):

  • Only organization admins can create Admin API keys
  • Create at Admin API Keys
  • Admin keys start with sk-ant-admin...

2. Configure Environment

Copy the example environment file and add your keys:

cp .env.example .env
# Edit .env and add your keys

Or set directly:

export ANTHROPIC_API_KEY=sk-ant-api03-xxxxx
export ANTHROPIC_ADMIN_API_KEY=sk-ant-admin-xxxxx  # Optional

3. Test Connections

Test Claude API:

opencode run "test anthropic connection"

Test Admin API (if configured):

opencode run "test admin connection"

4. Use Claude AI

opencode run "ask Claude what is the capital of France"

5. Use Admin Features (Optional)

opencode run "list all organization members"
opencode run "get usage report for last 7 days"
opencode run "list all workspaces"

Available Tools

Claude AI Tools (15 tools)

| Tool | Description | |------|-------------| | anthropic-test-connection | Test API connection and verify credentials | | anthropic-messages-post | Send a message to Claude and get a response | | anthropic-beta-messages-count-tokens-post | Count tokens in a message without sending | | anthropic-beta-message-batches-list | List all message batches | | anthropic-beta-message-batches-post | Create a new message batch | | anthropic-beta-message-batches-retrieve | Get status of a specific batch | | anthropic-beta-message-batches-cancel | Cancel a running batch | | anthropic-beta-message-batches-results | Get results from a completed batch |

Admin API Tools (28 tools - requires ANTHROPIC_ADMIN_API_KEY)

Organization Management:

  • anthropic-admin-test-connection - Test admin API connection
  • anthropic-admin-get-organization - Get organization details
  • anthropic-admin-list-users - List organization members
  • anthropic-admin-get-user - Get specific user details
  • anthropic-admin-update-user-role - Update member role
  • anthropic-admin-remove-user - Remove organization member

Invitations:

  • anthropic-admin-list-invites - List pending invites
  • anthropic-admin-create-invite - Send new invitation
  • anthropic-admin-get-invite - Get invite details
  • anthropic-admin-delete-invite - Cancel invitation

Workspaces:

  • anthropic-admin-list-workspaces - List all workspaces
  • anthropic-admin-create-workspace - Create new workspace
  • anthropic-admin-get-workspace - Get workspace details
  • anthropic-admin-update-workspace - Update workspace name
  • anthropic-admin-archive-workspace - Archive workspace

Workspace Members:

  • anthropic-admin-list-workspace-members - List workspace members
  • anthropic-admin-add-workspace-member - Add member to workspace
  • anthropic-admin-get-workspace-member - Get workspace member details
  • anthropic-admin-update-workspace-member-role - Update workspace member role
  • anthropic-admin-remove-workspace-member - Remove workspace member

API Keys:

  • anthropic-admin-list-api-keys - List all API keys
  • anthropic-admin-get-api-key - Get API key details and usage
  • anthropic-admin-update-api-key - Update key name or status

Usage & Cost Analytics:

  • anthropic-admin-usage-report - Get detailed token usage report
  • anthropic-admin-cost-report - Get cost breakdown in USD
  • anthropic-admin-claude-code-usage - Get Claude Code analytics

Environment Variables

| Variable | Required | Description | |----------|----------|-------------| | ANTHROPIC_API_KEY | Yes | Your Anthropic API key for Claude AI | | ANTHROPIC_ADMIN_API_KEY | No | Admin API key for organization management (starts with sk-ant-admin...) | | ANTHROPIC_VERSION | No | API version header (defaults to 2023-06-01) | | ANTHROPIC_HOST | No | Override API base URL (defaults to https://api.anthropic.com) |

Usage Examples

Claude AI Examples

Simple Message:

opencode run "send a message to Claude asking for a haiku about programming"

Count Tokens:

opencode run "count how many tokens are in 'Hello, how are you today?'"

List Batches:

opencode run "list all my message batches"

Admin API Examples

Organization Management:

opencode run "list all organization members"
opencode run "invite [email protected] as a developer"
opencode run "update user role to admin"

Workspace Management:

opencode run "create a workspace called Production"
opencode run "list all workspaces"
opencode run "add user to workspace as developer"

Usage & Cost Analytics:

opencode run "get usage report for last 7 days"
opencode run "show cost breakdown for January 2025"
opencode run "get Claude Code usage statistics"

API Key Management:

opencode run "list all API keys"
opencode run "show active API keys only"
opencode run "get usage statistics for a specific API key"

Message Format

When using the Messages API directly, format messages as a JSON array:

[
  {"role": "user", "content": "Hello, Claude!"},
  {"role": "assistant", "content": "Hello! How can I help you today?"},
  {"role": "user", "content": "Tell me about AI."}
]

Available Models

| Model | ID | Best For | |-------|-----|----------| | Claude 3.5 Sonnet | claude-3-5-sonnet-20241022 | Most capable, best for complex tasks | | Claude 3 Opus | claude-3-opus-20240229 | Highly capable, thorough responses | | Claude 3 Haiku | claude-3-haiku-20240307 | Fast, cost-effective for simple tasks |

Regenerating Tools

This pet uses auto-generated OpenAPI tools. To regenerate:

cd pets/anthropic
pets generate-openapi --verbose

Admin API Features in Detail

Usage Reports

Track token consumption across your organization with detailed breakdowns:

  • Group by: model, workspace, API key, service tier
  • Filter by: models, service tiers, context windows, workspaces, API keys
  • Metrics: Uncached input, cached input, cache creation, output tokens
  • Time ranges: Custom start/end times with 1m, 1h, or 1d aggregation

Cost Reports

Get service-level cost breakdowns in USD:

  • All costs reported in cents (decimal strings)
  • Token usage costs by model
  • Web search costs
  • Code execution costs
  • Group by workspace or description
  • Custom time ranges

Workspace Organization

Organize your API resources into logical groups:

  • Create separate workspaces for dev/staging/production
  • Set custom spend limits per workspace
  • Control team access with workspace-specific roles
  • Track usage and costs per workspace

Security & Governance

Manage your organization's security posture:

  • Audit all API keys and their usage
  • Monitor who has access to your organization
  • Track invitation status
  • Update or revoke access as needed

FAQ

Q: How do I get an Anthropic API key? A: Sign up at https://console.anthropic.com and create an API key in the API Keys section.

Q: How do I get an Admin API key? A: Only organization admins can create Admin API keys at https://console.anthropic.com/settings/admin-keys. These keys start with sk-ant-admin... and enable organization management.

Q: What's the difference between regular and admin API keys? A: Regular API keys are for using Claude AI. Admin API keys are for managing your organization, workspaces, members, and accessing usage/cost reports.

Q: Can I use this plugin without an admin key? A: Yes! The admin key is optional. Without it, you get all Claude AI features (messages, batches, token counting). With it, you also get organization management and analytics.

Q: What is max_tokens? A: The maximum number of tokens Claude can generate in its response. Different models have different limits.

Q: What are message batches? A: Message Batches allow you to process multiple messages asynchronously. Create a batch, poll for completion, then retrieve results.

Q: What can I do with usage and cost reports? A: Track spending, optimize model usage, implement chargeback by team/workspace, monitor cache effectiveness, and identify cost optimization opportunities.

Links