{"id":41437485,"url":"https://github.com/shantoislamdev/claude-adapter","last_synced_at":"2026-01-23T14:43:32.935Z","repository":{"id":329703404,"uuid":"1118216515","full_name":"shantoislamdev/claude-adapter","owner":"shantoislamdev","description":"Transform your OpenAI API into an Anthropic-compatible endpoint for Claude Code","archived":false,"fork":false,"pushed_at":"2026-01-20T05:01:57.000Z","size":322,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-20T11:57:43.023Z","etag":null,"topics":["anthropic-to-openai","claude-api-proxy","claude-code-adapter","claude-code-proxy","claude-code-router","claude-openai-proxy","claude-router","claude-to-openai"],"latest_commit_sha":null,"homepage":"https://claude-adapter.pages.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shantoislamdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-17T12:32:45.000Z","updated_at":"2026-01-20T05:01:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/shantoislamdev/claude-adapter","commit_stats":null,"previous_names":["shantoislamdev/claude-adapter"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/shantoislamdev/claude-adapter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shantoislamdev%2Fclaude-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shantoislamdev%2Fclaude-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shantoislamdev%2Fclaude-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shantoislamdev%2Fclaude-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shantoislamdev","download_url":"https://codeload.github.com/shantoislamdev/claude-adapter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shantoislamdev%2Fclaude-adapter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28694457,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T14:15:13.573Z","status":"ssl_error","status_checked_at":"2026-01-23T14:09:05.534Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["anthropic-to-openai","claude-api-proxy","claude-code-adapter","claude-code-proxy","claude-code-router","claude-openai-proxy","claude-router","claude-to-openai"],"created_at":"2026-01-23T14:43:30.940Z","updated_at":"2026-01-23T14:43:32.906Z","avatar_url":"https://github.com/shantoislamdev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Claude Adapter\n\n![Claude Adapter Logo](assets/banner.png)\n\n**Adapt any model for Claude Code**\n\n[![npm version](https://img.shields.io/npm/v/claude-adapter.svg)](https://www.npmjs.com/package/claude-adapter)\n[![codecov](https://codecov.io/gh/shantoislamdev/claude-adapter/graph/badge.svg)](https://codecov.io/gh/shantoislamdev/claude-adapter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Node.js Version](https://img.shields.io/node/v/claude-adapter.svg)](https://nodejs.org)\n\n[Getting Started](#getting-started) •\n[Installation](#installation) •\n[Configuration](#configuration) •\n[API Reference](#api-reference) •\n[Contributing](#contributing)\n\n\u003c/div\u003e\n\n---\n\n## Overview\n\n**Claude Adapter** serves as a sophisticated middleware solution designed to bridge the interoperability gap between the Anthropic Messages API and the OpenAI Chat Completions ecosystem. By functioning as a transparent proxy, it enables **Claude Code**—Anthropic's command-line interface—to leverage the capabilities of any OpenAI-compatible large language model (LLM), regardless of the provider.\n\nThis adapter effectively \"tricks\" Claude Code into communicating with models it was not natively designed to support, handling all necessary protocol translations, header modifications, and payload restructuring in real-time.\n\n### Key Features\n\n- 🔄 **Protocol Translation Layer** — Implements a robust bi-directional conversion engine that maps Anthropic's message format to OpenAI's chat completion schema on the fly.\n- 🌊 **Server-Sent Events (SSE) Streaming** — Provides full support for real-time response streaming, ensuring that the interactive feel of Claude Code is preserved even when backend by different models.\n- 🛠️ **Tool Invocation Compatibility** — seamlessly translates tool definitions and function call requests, allowing complex agentic workflows to function correctly across model boundaries.\n- ⚡ **Zero-Configuration Initialization** — Features an interactive CLI setup wizard that automates the generation of configuration files and environment variables.\n- 🔌 **Transparent Proxying** — Operates non-intrusively as a local service, requiring no modifications to the core Claude Code binary or internal logic.\n\n---\n\n## Architecture\n\nThe adapter operates as a local HTTP server that mimics the Anthropic API structure while forwarding requests to an upstream OpenAI-compatible target.\n\n```\n┌─────────────┐      ┌─────────────────┐      ┌─────────────────┐\n│              ────▶                   ────▶                   │\n│ Claude Code │      │  Claude Adapter │      │ OpenAI Endpoint │\n│               ◀────                   ◀────                  │\n└─────────────┘      └─────────────────┘      └─────────────────┘\n   Anthropic              Converts                  OpenAI\n    Format                Formats                   Format\n```\n\nWhen Claude Code initiates a request, **Claude Adapter** intercepts it, transforms the payload (including system prompts, message history, and tool definitions) into a format compliant with the OpenAI specification, and dispatches it to the configured backend (e.g., OpenAI, Grok, or a local inference server). The response is then captured, re-serialized into the Anthropic message format, and returned to the client.\n\n---\n\n## Getting Started\n\n### Prerequisites\n\n- **Runtime Environment**: Node.js Version 20.0.0 or higher is required to execute the adapter.\n- **API Access**: A valid API key for an OpenAI-compatible service (e.g., OpenAI, DeepSeek, XAI).\n\n### Installation\n\nTo install the adapter globally on your system, execute the following command:\n\n```bash\nnpm install -g claude-adapter\n```\n\n### Quick Start\n\n1. **Initialize the Service:**\n   Launch the adapter's interactive setup utility:\n   ```bash\n   claude-adapter\n   ```\n\n2. **Configuration Wizard:**\n   The CLI will guide you through the necessary configuration steps:\n   - **Base URL**: Enter the endpoint URL of your compatible provider.\n   - **Authentication**: Securely input your API key.\n   - **Model Mapping**: Define which OpenAI-compatible models should be aliased to Claude's internal identifiers (`opus`, `sonnet`, `haiku`).\n\n3. **Operational State:**\n   Once configured, the adapter will start a local proxy server. Claude Code is automatically reconfigured to route traffic through this local endpoint.\n\n---\n\n## Configuration\n\n### CLI Options\n\nThe CLI accepts several flags to customize runtime behavior:\n\n| Option                  | Description                                   | Default |\n| ----------------------- | --------------------------------------------- | ------- |\n| `-p, --port \u003cport\u003e`     | Specifies the port for the local proxy server | `3080`  |\n| `-r, --reconfigure`     | Forces the specific reconfiguration workflow  | `false` |\n| `--no-claude-settings`  | Skip updating Claude Code settings files      | `false` |\n| `-V, --version`         | Output the current version information        | —       |\n| `-h, --help`            | Display available commands and options        | —       |\n\n### Model Mapping Configuration\n\nThe core of the adapter's flexibility lies in its ability to map Claude's expected model tiers to arbitrary upstream models. This allows you to substitute, for example, a specialized coding model for `sonnet` or a high-speed inference model for `haiku`.\n\n| Claude Tier | Intended Use Case | Example Mapping Strategy       |\n| ----------- | ----------------- | ------------------------------ |\n| `opus`      | Complex reasoning | `gpt-4`, `grok-1`              |\n| `sonnet`    | Balanced tasks    | `gpt-4-turbo`, `deepseek-chat` |\n| `haiku`     | Low-latency ops   | `gpt-3.5-turbo`, `llama-3-70b` |\n\n---\n\n## API Reference\n\n### Programmatic Integration\n\nFor users wishing to embed the adapter within larger Node.js applications, the package exports its core server factory:\n\n```typescript\nimport { createServer, AdapterConfig } from 'claude-adapter';\n\nconst config: AdapterConfig = {\n  baseUrl: 'https://api.openai.com/v1',\n  apiKey: process.env.OPENAI_API_KEY!,\n  models: {\n    opus: 'gpt-4',\n    sonnet: 'gpt-4-turbo',\n    haiku: 'gpt-3.5-turbo'\n  }\n};\n\n// Instantiate the proxy server\nconst server = createServer(config);\n\n// Start listening on a specific port\nawait server.start(3080);\n\nconsole.log('Proxy running on http://localhost:3080');\n```\n\n\u003e **Note**: While the adapter exposes this programmatic interface, its primary design intent is to function as a standalone CLI tool for Claude Code users.\n\n### Transformation Utilities\n\nThe underlying conversion logic is also exposed as standalone functions for custom implementations:\n\n```typescript\nimport { \n  convertRequestToOpenAI,\n  convertResponseToAnthropic \n} from 'claude-adapter';\n\n// Transform an incoming Anthropic request payload\nconst openaiRequest = convertRequestToOpenAI(anthropicRequest, 'target-model-name');\n\n// Transform an OpenAI response payload back to Anthropic format\nconst anthropicResponse = convertResponseToAnthropic(openaiResponse, 'original-model-name');\n```\n\nFor detailed type definitions and function signatures, please consult the [API Documentation](./docs/API.md).\n\n---\n\n## Supported Features\n\n| Feature Capability    | Support Status | Implementation Notes       |\n| --------------------- | :------------: | -------------------------- |\n| Text Generation       |       ✅        | Full fidelity              |\n| System Prompts        |       ✅        | Mapped to 'system' role    |\n| Real-time Streaming   |       ✅        | SSE event translation      |\n| Tool/Function Calling |       ✅        | Bidirectional mapping      |\n| Context Preservation  |       ✅        | Multi-turn history support |\n| Token Limits          |       ✅        | Parameter pass-through     |\n| Sampling (Temp/Top P) |       ✅        | Parameter pass-through     |\n| Stop Sequences        |       ✅        | Mapped to API equivalent   |\n| Multimodal (Vision)   |       🔜        | Implementation roadmap     |\n\n---\n\n## Troubleshooting\n\n### Common issues and Resolutions\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eEADDRINUSE: Port collision\u003c/strong\u003e\u003c/summary\u003e\n\nIf the default port `3080` is occupied by another process, launch the adapter on an alternative port:\n```bash\nclaude-adapter --port 3000\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eAuthentication Failures\u003c/strong\u003e\u003c/summary\u003e\n\nIf you encounter 401 errors, your API key may be invalid or expired. Rerun the configuration wizard:\n```bash\nclaude-adapter --reconfigure\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eConnection Refused\u003c/strong\u003e\u003c/summary\u003e\n\nEnsure the proxy server is running in a terminal window. Check your `~/.claude/settings.json` to verify the `ANTHROPIC_BASE_URL` is pointing to the correct local address (e.g., `http://localhost:3080`).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eManual Configuration Mode\u003c/strong\u003e\u003c/summary\u003e\n\nTo run the adapter without modifying Claude Code's settings, use `--no-claude-settings`:\n```bash\nclaude-adapter --no-claude-settings\n```\n\nThen manually set environment variables in `~/.claude/settings.json`:\n```json\n{\n  \"env\": {\n    \"ANTHROPIC_BASE_URL\": \"http://localhost:3080\",\n    \"ANTHROPIC_AUTH_TOKEN\": \"default\"\n  }\n}\n```\n\u003c/details\u003e\n\n---\n\n## Development\n\nTo contribute to the codebase or build from source:\n\n```bash\n# Clone the repository\ngit clone https://github.com/shantoislamdev/claude-adapter.git\ncd claude-adapter\n\n# Install dependencies\nnpm install\n\n# Start the development server with hot-reload\nnpm run dev\n\n# Execute the test suite\nnpm test\n\n# Compile TypeScript to JavaScript for production\nnpm run build\n```\n\nPlease refer to [CONTRIBUTING.md](./CONTRIBUTING.md) for comprehensive contribution guidelines.\n\n---\n\n## License\n\nThis project is licensed under the **MIT License**. For full terms and conditions, please see the [LICENSE](./LICENSE) file.\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**[Report Bug](https://github.com/shantoislamdev/claude-adapter/issues)** •\n**[Request Feature](https://github.com/shantoislamdev/claude-adapter/issues)** •\n**[Documentation](./docs/)**\n\nMade with ❤️ by [Shanto Islam](https://shantoislamdev.web.app/)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshantoislamdev%2Fclaude-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshantoislamdev%2Fclaude-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshantoislamdev%2Fclaude-adapter/lists"}