{"id":29477430,"url":"https://github.com/codingworkflow/claude-code-api","last_synced_at":"2025-08-07T00:52:26.275Z","repository":{"id":306242273,"uuid":"1005699064","full_name":"codingworkflow/claude-code-api","owner":"codingworkflow","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-10T18:50:54.000Z","size":370,"stargazers_count":118,"open_issues_count":1,"forks_count":12,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-24T15:09:21.311Z","etag":null,"topics":["ai","ai-assistant","anthropic","anthropic-claude","claude","claude-ai","claude-api","claude-code"],"latest_commit_sha":null,"homepage":"https://www.codingworkflow.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codingworkflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-20T16:52:41.000Z","updated_at":"2025-07-23T21:04:20.000Z","dependencies_parsed_at":"2025-07-24T15:21:00.145Z","dependency_job_id":null,"html_url":"https://github.com/codingworkflow/claude-code-api","commit_stats":null,"previous_names":["codingworkflow/claude-code-api"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/codingworkflow/claude-code-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingworkflow%2Fclaude-code-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingworkflow%2Fclaude-code-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingworkflow%2Fclaude-code-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingworkflow%2Fclaude-code-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codingworkflow","download_url":"https://codeload.github.com/codingworkflow/claude-code-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingworkflow%2Fclaude-code-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269181031,"owners_count":24373850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-assistant","anthropic","anthropic-claude","claude","claude-ai","claude-api","claude-code"],"created_at":"2025-07-14T18:01:57.578Z","updated_at":"2025-08-07T00:52:26.246Z","avatar_url":"https://github.com/codingworkflow.png","language":"Python","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"# Claude Code API Gateway\n\nA simple, focused OpenAI-compatible API gateway for Claude Code with streaming support.\nLeverage the Claude Code SDK use mode. Don't hack the token credentials.\n\n## Getting Started\n\nUse the Makefile to install the project or pip/uv.\n\n![API Started](assets/api.png)\n\n![Cline use](assets/cline.png)\n\n![Cursor](assets/cursor.png)\n\n![OpenWebUI](assets/openwebui.png)\n\n![Roo Code config](assets/roocode.png)\n\n![Roo Code chat](assets/roo_code.png) \n\n### Python Implementation\n```bash\n# Clone and setup\ngit clone https://github.com/codingworkflow/claude-code-api\ncd claude-code-api\n\n# Install dependencies \u0026 module\nmake install \n\n# Start the API server\nmake start\n```\n\n## Limitations\n\n- There might be a limit on maximum input below normal \"Sonnet 4\" input as Claude Code usually doesn't ingest more than 25k tokens (despite the context being 100k).\n- Claude Code auto-compacts context beyond 100k.\n- Currently runs with bypass mode to avoid tool errors.\n- Claude Code tools may need to be disabled to avoid overlap and background usage.\n- Runs only on Linux/Mac as Claude Code doesn't run on Windows (you can use WSL).\n- Note that Claude Code will default to accessing the current workspace environment/folder and is set to use bypass mode.\n\n\n## Features\n\n- **Claude-Only Models**: Supports exactly the 4 Claude models that Claude Code CLI offers\n- **OpenAI Compatible**: Drop-in replacement for OpenAI API endpoints\n- **Streaming Support**: Real-time streaming responses \n- **Simple \u0026 Clean**: No over-engineering, focused implementation\n- **Claude Code Integration**: Leverages Claude Code CLI with streaming output\n\n## Supported Models\n\n- `claude-opus-4-20250514` - Claude Opus 4 (Most powerful)\n- `claude-sonnet-4-20250514` - Claude Sonnet 4 (Latest Sonnet)\n- `claude-3-7-sonnet-20250219` - Claude Sonnet 3.7 (Advanced)\n- `claude-3-5-haiku-20241022` - Claude Haiku 3.5 (Fast \u0026 cost-effective)\n\n## Quick Start\n\n### Prerequisites\n- Python 3.10+\n- Claude Code CLI installed and accessible\n- Valid Anthropic API key configured in Claude Code (ensure it works in current directory src/)\n\n### Installation \u0026 Setup\n\n```bash\n# Clone and setup\ngit clone https://github.com/codingworkflow/claude-code-api\ncd claude-code-api\n\n# Install dependencies\nmake install\n\n# Run tests to verify setup\nmake test\n\n# Start the API server\nmake start-dev\n```\n\nThe API will be available at:\n- **API**: http://localhost:8000\n- **Docs**: http://localhost:8000/docs  \n- **Health**: http://localhost:8000/health\n\n## Makefile Commands\n\n### Core Commands\n```bash\nmake install     # Install production dependencies\nmake install-dev # Install development dependencies  \nmake test        # Run all tests\nmake start       # Start API server (production)\nmake start-dev   # Start API server (development with reload)\n```\n\n### Testing\n```bash\nmake test           # Run all tests\nmake test-fast      # Run tests (skip slow ones)\nmake test-hello     # Test hello world with Haiku\nmake test-health    # Test health check only\nmake test-models    # Test models API only\nmake test-chat      # Test chat completions only\nmake quick-test     # Quick validation of core functionality\n```\n\n### Development\n```bash\nmake dev-setup      # Complete development setup\nmake lint           # Run linting checks\nmake format         # Format code with black/isort\nmake type-check     # Run type checking\nmake clean          # Clean up cache files\n```\n\n### Information\n```bash\nmake help           # Show all available commands\nmake models         # Show supported Claude models\nmake info           # Show project information\nmake check-claude   # Check if Claude Code CLI is available\n```\n\n## API Usage\n\n### Chat Completions\n\n```bash\ncurl -X POST http://localhost:8000/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"claude-3-5-haiku-20241022\",\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Hello!\"}\n    ]\n  }'\n```\n\n### List Models\n\n```bash\ncurl http://localhost:8000/v1/models\n```\n\n### Streaming Chat\n\n```bash\ncurl -X POST http://localhost:8000/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"claude-3-5-haiku-20241022\", \n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"Tell me a joke\"}\n    ],\n    \"stream\": true\n  }'\n```\n\n## Project Structure\n\n```\nclaude-code-api/\n├── claude_code_api/\n│   ├── main.py              # FastAPI application\n│   ├── api/                 # API endpoints\n│   │   ├── chat.py          # Chat completions\n│   │   ├── models.py        # Models API\n│   │   ├── projects.py      # Project management\n│   │   └── sessions.py      # Session management\n│   ├── core/                # Core functionality\n│   │   ├── auth.py          # Authentication\n│   │   ├── claude_manager.py # Claude Code integration\n│   │   ├── session_manager.py # Session management\n│   │   ├── config.py        # Configuration\n│   │   └── database.py      # Database layer\n│   ├── models/              # Data models\n│   │   ├── claude.py        # Claude-specific models\n│   │   └── openai.py        # OpenAI-compatible models\n│   ├── utils/               # Utilities\n│   │   ├── streaming.py     # Streaming support\n│   │   └── parser.py        # Output parsing\n│   └── tests/               # Test suite\n├── Makefile                 # Development commands\n├── pyproject.toml          # Project configuration\n├── setup.py                # Package setup\n└── README.md               # This file\n```\n\n## Testing\n\nThe test suite validates:\n- Health check endpoints\n- Models API (Claude models only)\n- Chat completions with Haiku model\n- Hello world functionality\n- OpenAI compatibility (structure)\n- Error handling\n\nRun specific test suites:\n```bash\nmake test-hello    # Test hello world with Haiku\nmake test-models   # Test models API\nmake test-chat     # Test chat completions\n```\n\n## Development\n\n### Setup Development Environment\n```bash\nmake dev-setup\n```\n\n### Code Quality\n```bash\nmake format        # Format code\nmake lint          # Check linting\nmake type-check    # Type checking\n```\n\n### Quick Validation\n```bash\nmake quick-test    # Test core functionality\n```\n\n## Deployment\n\n### Check Deployment Readiness\n```bash\nmake deploy-check\n```\n\n### Production Server\n```bash\nmake start-prod    # Start with multiple workers\n```\nUse http://127.0.0.1:8000/v1 as OpenAPI endpoint\n\n## Configuration\n\nKey settings in `claude_code_api/core/config.py`:\n- `claude_binary_path`: Path to Claude Code CLI\n- `project_root`: Root directory for projects\n- `database_url`: Database connection string\n- `require_auth`: Enable/disable authentication\n\n## Design Principles\n\n1. **Simple \u0026 Focused**: No over-engineering\n2. **Claude-Only**: Pure Claude gateway, no OpenAI models\n3. **Streaming First**: Built for real-time streaming\n4. **OpenAI Compatible**: Drop-in API compatibility\n5. **Test-Driven**: Comprehensive test coverage\n\n## Health Check\n\n```bash\ncurl http://localhost:8000/health\n```\n\nResponse:\n```json\n{\n  \"status\": \"healthy\",\n  \"version\": \"1.0.0\", \n  \"claude_version\": \"1.x.x\",\n  \"active_sessions\": 0\n}\n```\n\n## License\n\nThis project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingworkflow%2Fclaude-code-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodingworkflow%2Fclaude-code-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingworkflow%2Fclaude-code-api/lists"}