auth2api  by AmazingAng

Claude API proxy for OpenAI clients

Created 4 weeks ago

New!

308 stars

Top 87.2% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a lightweight, single-account proxy that bridges Claude's OAuth authentication with an OpenAI-compatible API endpoint. It is designed for developers and power users seeking to integrate Claude models into existing applications or workflows that rely on the OpenAI API specification, offering a simple, understandable, and easily modifiable solution. The primary benefit is enabling seamless use of Claude's capabilities through familiar API patterns without complex setup.

How It Works

auth2api functions as a reverse proxy, intercepting requests intended for OpenAI-compatible APIs and translating them into calls to the Anthropic Claude API. It handles the OAuth flow for a single Claude account, managing token refresh and cooldown periods. The proxy exposes standard OpenAI endpoints like /v1/chat/completions and /v1/models, while also supporting Claude's native /v1/messages endpoint for direct interaction, including features like streaming, tool use, and image input. Its design prioritizes a minimal codebase and a straightforward, single-account architecture for ease of deployment and customization.

Quick Start & Requirements

  • Installation: Clone the repository, navigate to the directory, and run npm install && npm run build.
  • Prerequisites: Node.js 20+ and a Claude account (Claude Max subscription recommended).
  • Running: Execute node dist/index.js. The server defaults to http://127.0.0.1:8317.
  • Login: Use node dist/index.js --login for automatic browser-based authorization or node dist/index.js --login --manual for remote servers, requiring manual URL pasting.
  • Configuration: Copy config.example.yaml to config.yaml and adjust settings for host, port, API keys, body limits, and timeouts.
  • Docker: Build with docker build -t auth2api . and run using provided docker run or docker-compose examples, mounting configuration and token directories.

Highlighted Details

  • Supports OpenAI-compatible endpoints: /v1/chat/completions, /v1/responses, /v1/models.
  • Includes Claude native passthrough: /v1/messages, /v1/messages/count_tokens.
  • Handles streaming, tools, images, and reasoning capabilities.
  • Features single-account health management: cooldown, retries, token refresh, and an /admin/accounts status endpoint.
  • Includes basic safety defaults: per-IP rate limiting and localhost-only CORS.
  • Configurable request body limits (default 200mb) and timeouts for long-running tasks.

Maintenance & Community

No specific details regarding maintainers, community channels (e.g., Discord, Slack), or project roadmaps are provided in the README.

Licensing & Compatibility

The project is released under the MIT License, which is permissive and generally compatible with commercial use and linking within closed-source applications.

Limitations & Caveats

The proxy is strictly designed for a single Claude OAuth account per instance. Attempting to add a second account requires manual removal of the existing token file. It is not intended as a multi-provider gateway or a complex routing platform.

Health Check
Last Commit

2 days ago

Responsiveness

Inactive

Pull Requests (30d)
12
Issues (30d)
2
Star History
308 stars in the last 29 days

Explore Similar Projects

Feedback? Help us improve.