dreame-claude
v1.2.14
Published
dreame claude-code
Downloads
1,241
Readme
dreame-claude
A wrapper for claude-code with custom API endpoints and SSO authentication.
Installation
npm install -g dreame-claudeUsage
After installation, you can use the dreame-claude command just like the regular claude command:
dreame-claudeFeatures
- Automatic Environment Setup: Sets up telemetry environment variables automatically
- API Endpoint Redirection: Redirects all Anthropic API requests to custom endpoints
- SSO Authentication: Provides browser-based authentication with token management
- User Identity Management: Extracts and maps user IDs between systems
- API Key Management: Automatically creates and manages user-specific API keys
- Configuration Management: Automatically sets up Claude settings with GLM model configuration
Authentication Flow
The tool implements a comprehensive authentication system:
- Token Caching: Stores authentication tokens in
~/.claude/dreame-tokens.json - Token Validation: Validates tokens with the remote authentication service
- Browser-based Login: Opens a local web server for authentication when needed
- Automatic Renewal: Handles token expiration and renewal automatically
Authentication Endpoints
- Token Validation:
https://upper.dreame.tech:5005/v1/auth/reftoken - User Login:
http://llm.dreame.tech/copilot/v1/api/rest/login - User Mapping:
https://llm.dreame.tech/copilot/v1/api/rest/claude-client-user-map/create_or_update
Environment Variables
This tool automatically sets the following environment variables:
Telemetry Configuration
CLAUDE_CODE_ENABLE_TELEMETRY=1OTEL_METRICS_EXPORTER=otlpOTEL_LOGS_EXPORTER=otlpOTEL_EXPORTER_OTLP_PROTOCOL=grpcOTEL_EXPORTER_OTLP_ENDPOINT=http://172.26.33.148:4317OTEL_METRIC_EXPORT_INTERVAL=10000OTEL_LOGS_EXPORT_INTERVAL=5000OTEL_LOG_USER_PROMPTS=1
API Configuration
ANTHROPIC_BASE_URL=https://dreame-claude.dreame.tech/initANTHROPIC_API_KEY: Dynamically set per user via API key management
Localization
LANG=zh_CN.UTF-8LC_ALL=zh_CN.UTF-8LC_CTYPE=zh_CN.UTF-8
Configuration Management
The tool automatically creates and manages Claude configuration:
Claude Settings (~/.claude/settings.json)
{
"env": {
"ANTHROPIC_MODEL": "glm-4.6",
"ANTHROPIC_SMALL_FAST_MODEL": "glm-4.6"
},
"alwaysThinkingEnabled": true
}API Key Management
The tool includes a comprehensive API key management system:
- Dynamic Key Creation: Creates user-specific API keys through the admin API
- Remote Synchronization: Synchronizes keys with the remote user management service
- Automatic Rotation: Handles key updates and invalidation
API Management Endpoints
- Admin API:
https://dreame-claude.dreame.tech/admin/api-keys - User API Sync:
https://llm.dreame.tech/copilot/v1/api/rest/claude-user-apikey/create_or_update
User Identity Extraction
The tool automatically extracts user identities from Claude telemetry data:
- Parses JSON telemetry output to identify
user.idfields - Maps extracted user IDs to usernames in the user management system
- Ensures proper attribution for API usage
Command Setup
The tool automatically manages the Claude command installation:
- Renames existing
claudeexecutable toreal_claude - Creates symbolic link from
dreame-claudetoclaude - Ensures seamless integration with existing workflows
Requirements
- Node.js >= 18.0.0
- @anthropic-ai/claude-code installed globally
- Network access to Dreame authentication services
Dependencies
@anthropic-ai/claude-code: Base Claude Code functionality
License
MIT
