A modern web application for batch processing text completions through Anthropic's Claude AI model. This application allows you to efficiently create, manage, and monitor batches of AI completion requests.
- Batch Processing: Upload, configure, and process large batches of prompts with Claude
- Dashboard Interface: Monitor real-time progress of your batch completions
- Authentication: Secure user authentication with email/password and OAuth providers
- API Key Management: Create and manage API keys for programmatic access
- User Roles: Administrative controls and user role management
- Robust Security: Comprehensive security headers and authentication flows
- Responsive Design: Modern UI built with React, Tailwind CSS, and Shadcn UI components
- Framework: Next.js 15 with App Router and React Server Components
- Authentication: NextAuth.js with database adapter
- Database: PostgreSQL with Prisma ORM
- Schema Enhancement: ZenStack for access policies
- Form Management: React Hook Form with Zod validation
- Styling: Tailwind CSS with Shadcn UI components
- State Management: Zustand and React Query
- UI Components: Radix UI primitives
- AI Integration: Anthropic API for Claude AI access
- Node.js 18+ and npm/yarn/pnpm
- PostgreSQL database
- Anthropic API key
-
Clone the repository:
git clone https://github.com/yourusername/claude-batch.git cd claude-batch -
Install dependencies:
npm install # or yarn install # or pnpm install
-
Set up environment variables:
- Copy
.env.exampleto.env.local - Fill in the required environment variables:
# Database DATABASE_URL="postgresql://postgres:password@localhost:5432/claude_batch" # Anthropic API ANTHROPIC_API_KEY="your-anthropic-api-key" # NextAuth NEXTAUTH_SECRET="your-nextauth-secret" NEXTAUTH_URL="http://localhost:3000" # Optional OAuth Providers # GITHUB_ID="your-github-client-id" # GITHUB_SECRET="your-github-client-secret" # GOOGLE_ID="your-google-client-id" # GOOGLE_SECRET="your-google-client-secret"
- Copy
-
Initialize and migrate the database:
npx prisma migrate dev
-
Start the development server:
npm run dev # or yarn dev # or pnpm dev
-
Open http://localhost:3000 in your browser to see the application.
The application uses the following core data models:
- User: User accounts with authentication information
- Batch: Represents a collection of completions to be processed
- Completion: Individual AI completion requests within a batch
- ApiKey: API keys for programmatic access to the application
- Email/Password authentication
- OAuth providers support (GitHub, Google)
- Session-based authentication with JWT
- Protected routes via middleware
- API key authentication for programmatic access
The application provides both a web interface and API endpoints for managing batches:
- Create an API key in the settings
- Use the key to authenticate API requests:
curl -X POST https://your-deployment-url/api/batches \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "My Batch", "prompts": ["Tell me about AI", "Explain quantum computing"] }'
This application supports the following Claude models:
-
Claude 4 (Latest Generation):
claude-opus-4-20250514- Our most capable and intelligent model with 32K max output tokensclaude-sonnet-4-20250514- High-performance model with 64K max output tokens- Features: 200K context window, extended thinking support, vision capabilities, March 2025 training cutoff
-
Claude 3.7:
claude-3-7-sonnet-20250219- High-performance model with early extended thinking (up to 128K output with beta header)- Features: 200K context window, extended thinking support, vision capabilities, October 2024 training cutoff
-
Claude 3.5:
claude-3-5-sonnet-20241022- Latest Claude 3.5 Sonnet (October 2024)claude-3-5-haiku-20241022- Fastest model for quick responsesclaude-3-5-sonnet-20240620- Previous Claude 3.5 Sonnet (June 2024)- Features: 200K context window, 8K max output tokens, vision capabilities
-
Claude 3 (Legacy):
claude-3-opus-20240229- Most capable Claude 3 modelclaude-3-sonnet-20240229- Balanced Claude 3 modelclaude-3-haiku-20240307- Fastest Claude 3 model- Features: 200K context window, 4K max output tokens, vision capabilities
To verify model availability or test your Anthropic API connection, you can use the provided scripts:
# Check available models (JavaScript)
cd scripts && node check-models.js
# Check available models (TypeScript)
cd scripts && npx ts-node check-models.ts
# Test batch API functionality (JavaScript)
cd scripts && node check-batch-api.js
# Test batch API functionality (TypeScript)
cd scripts && npx ts-node check-batch-api.tsThe scripts will automatically use the Anthropic API key from the main project's .env.local file, so you don't need to create a separate .env file in the scripts directory.
- Batch Structure: Each batch request must include a list of individual message requests, each with a unique
custom_idand message parameters. - Propagation Delay: After creating a batch, there might be a short delay (5-15 seconds) before it's fully available in Anthropic's system.
- Model Name Validation: Ensure you're using a valid model name as shown above. Invalid model names will result in a
not_found_error. - Error Handling: The application implements retry logic for handling temporary availability issues with newly created batches.
- Create a Batch: Upload a CSV or JSON file with prompts or enter prompts manually
- Configure: Set Claude model, temperature, and other parameters
- Process: Start the batch and monitor progress in real-time
- Results: Download or export results when processing completes
claude-batch/
├── app/ # Next.js App Router
│ ├── (auth)/ # Authentication pages
│ ├── (dashboard)/ # Protected dashboard pages
│ ├── api/ # API routes
│ └── page.tsx # Landing page
├── components/ # Reusable React components
├── config/ # Configuration files
├── hooks/ # Custom React hooks
├── lib/ # Utility functions and services
├── prisma/ # Database schema and migrations
│ ├── schema.prisma # Prisma schema
│ └── zenstack.schema # ZenStack enhanced schema
├── public/ # Static assets
└── types/ # TypeScript type definitions
npm run dev: Start development servernpm run build: Build for productionnpm run start: Start production servernpm run lint: Run ESLint
This project is licensed under the MIT License.