72 lines
1.6 KiB
Markdown
72 lines
1.6 KiB
Markdown
# CLAUDE.md
|
|
|
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
|
|
## Project Overview
|
|
|
|
zzrouter is an AI model API proxy service with OpenAI-compatible and Anthropic support, API key rotation, and request logging.
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
zzrouter/
|
|
├── backend/ # Python FastAPI proxy server
|
|
└── frontend/ # (placeholder)
|
|
```
|
|
|
|
## Backend Commands
|
|
|
|
```bash
|
|
cd backend
|
|
|
|
# Install dependencies
|
|
uv sync
|
|
|
|
# Run development server
|
|
uv run uvicorn app.main:app --reload --port 8000
|
|
|
|
# Run directly
|
|
uv run python main.py
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
| Endpoint | Description |
|
|
|----------|-------------|
|
|
| `POST /v1/chat/completions` | OpenAI-compatible chat (auto-routes by model) |
|
|
| `POST /v1/openai/chat/completions` | OpenAI native passthrough |
|
|
| `POST /v1/anthropic/messages` | Anthropic native passthrough |
|
|
| `GET /health` | Health check |
|
|
|
|
## Authentication
|
|
|
|
All API endpoints require Bearer token authentication:
|
|
```
|
|
Authorization: Bearer <client_key>
|
|
```
|
|
|
|
## Database
|
|
|
|
SQLite database stored at `backend/data/zzrouter.db`.
|
|
|
|
Key tables:
|
|
- `client_keys` - Client API keys
|
|
- `providers` - Model provider configs
|
|
- `provider_keys` - Provider API keys (supports multiple per provider)
|
|
- `request_logs` - Request statistics
|
|
|
|
## Adding Configuration
|
|
|
|
```sql
|
|
-- Add a client key
|
|
INSERT INTO client_keys (key, name) VALUES ('my-secret-key', 'my-app');
|
|
|
|
-- Add provider API keys
|
|
INSERT INTO provider_keys (provider_id, key) VALUES (1, 'sk-openai-key');
|
|
INSERT INTO provider_keys (provider_id, key) VALUES (2, 'sk-ant-anthropic-key');
|
|
```
|
|
|
|
## Frontend
|
|
|
|
Frontend directory is currently empty and pending implementation.
|