{"_id":"@chameleon-nexus-tech/llms","name":"@chameleon-nexus-tech/llms","dist-tags":{"latest":"1.0.32"},"versions":{"1.0.32":{"name":"@chameleon-nexus-tech/llms","version":"1.0.32","description":"A universal LLM API transformation server (Chameleon Nexus Fork)","main":"dist/cjs/server.cjs","module":"dist/esm/server.mjs","type":"module","exports":{".":{"import":"./dist/esm/server.mjs","require":"./dist/cjs/server.cjs"}},"scripts":{"tsx":"tsx","build":"tsx scripts/build.ts","build:watch":"tsx scripts/build.ts --watch","dev":"nodemon","start":"node dist/cjs/server.cjs","start:esm":"node dist/esm/server.mjs","lint":"eslint src --ext .ts,.tsx"},"keywords":[],"author":{"name":"chameleon-nexus"},"license":"MIT","dependencies":{"@anthropic-ai/sdk":"^0.54.0","@fastify/cors":"^11.0.1","@google/genai":"^1.7.0","dotenv":"^16.5.0","fastify":"^5.4.0","google-auth-library":"^10.1.0","json5":"^2.2.3","jsonrepair":"^3.13.0","openai":"^5.6.0","undici":"^7.10.0","uuid":"^11.1.0"},"devDependencies":{"@types/chai":"^5.2.2","@types/mocha":"^10.0.10","@types/node":"^24.0.3","@types/sinon":"^17.0.4","@typescript-eslint/eslint-plugin":"^8.35.0","@typescript-eslint/parser":"^8.35.0","chai":"^5.2.0","esbuild":"^0.25.5","eslint":"^9.30.0","nodemon":"^3.1.10","sinon":"^21.0.0","tsx":"^4.20.3","typescript":"^5.8.3","typescript-eslint":"^8.35.0"},"_id":"@chameleon-nexus-tech/llms@1.0.32","gitHead":"be0ca55762559912f871af88c94767562b1f39be","_nodeVersion":"22.15.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-H8g2GY1kX3kxSByqPFZ0B07QGE83V8UZfN3rjvaG5Ie7GAnfvRaX6tLTGMrwxgl1TLREaSHmaJe/n5PSTravew==","shasum":"85b25f9a2657899f0462e8f22da4a9f78cd8caef","tarball":"https://registry.npmjs.org/@chameleon-nexus-tech/llms/-/llms-1.0.32.tgz","fileCount":9,"unpackedSize":4111105,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCSLiB62Vmym0B3QlIa8zxYQLojTmf0etmKPo0xOgTm7AIgBtZl09/V+PW5xLh4zvkcz5b218HendXMg6r604Y+VDo="}]},"_npmUser":{"name":"chameleon-nexus","email":"mythicscribe2014@gmail.com"},"directories":{},"maintainers":[{"name":"chameleon-nexus","email":"mythicscribe2014@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/llms_1.0.32_1758378384197_0.21258589057133892"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-20T14:26:24.053Z","1.0.32":"2025-09-20T14:26:24.438Z","modified":"2025-09-20T14:26:24.780Z"},"maintainers":[{"name":"chameleon-nexus","email":"mythicscribe2014@gmail.com"}],"description":"A universal LLM API transformation server (Chameleon Nexus Fork)","keywords":[],"author":{"name":"chameleon-nexus"},"license":"MIT","readme":"# LLMs\r\n\r\n> A universal LLM API transformation server, initially developed for the [claude-code-router](https://github.com/musistudio/claude-code-router).\r\n\r\n## How it works\r\n\r\nThe LLM API transformation server acts as a middleware to standardize requests and responses between different LLM providers (Anthropic, Gemini, Deepseek, etc.). It uses a modular transformer system to handle provider-specific API formats.\r\n\r\n### Key Components\r\n\r\n1. **Transformers**: Each provider (e.g., Anthropic, Gemini) has a dedicated transformer class that implements:\r\n\r\n   - `transformRequestIn`: Converts the provider's request format to a unified format.\r\n   - `transformResponseIn`: Converts the provider's response format to a unified format.\r\n   - `transformRequestOut`: Converts the unified request format to the provider's format.\r\n   - `transformResponseOut`: Converts the unified response format back to the provider's format.\r\n   - `endPoint`: Specifies the API endpoint for the provider (e.g., \"/v1/messages\" for Anthropic).\r\n\r\n2. **Unified Formats**:\r\n\r\n   - Requests and responses are standardized using `UnifiedChatRequest` and `UnifiedChatResponse` types.\r\n\r\n3. **Streaming Support**:\r\n   - Handles real-time streaming responses for providers like Anthropic, converting chunked data into a standardized format.\r\n\r\n### Data Flow\r\n\r\n1. **Request**:\r\n\r\n   - Incoming provider-specific requests are transformed into the unified format.\r\n   - The unified request is processed by the server.\r\n\r\n2. **Response**:\r\n   - The server's unified response is transformed back into the provider's format.\r\n   - Streaming responses are handled with chunked data conversion.\r\n\r\n### Example Transformers\r\n\r\n- **Anthropic**: Converts between OpenAI-style and Anthropic-style message formats.\r\n- **Gemini**: Adjusts tool definitions and parameter formats for Gemini compatibility.\r\n- **Deepseek**: Enforces token limits and handles reasoning content in streams.\r\n\r\n## Run this repo\r\n\r\n- **Install dependencies:**\r\n  ```sh\r\n  npm install\r\n  # or pnpm install\r\n  ```\r\n- **Development:**\r\n  ```sh\r\n  npm run dev\r\n  # Uses nodemon + tsx for hot-reloading src/server.ts\r\n  ```\r\n- **Build:**\r\n  ```sh\r\n  npm run build\r\n  # Outputs to dist/cjs and dist/esm\r\n  ```\r\n- **Test:**\r\n  ```sh\r\n  npm test\r\n  # See CLAUDE.md for details\r\n  ```\r\n- **Path alias:**\r\n  - `@` is mapped to the `src` directory, use `import xxx from '@/xxx'`.\r\n- **Environment variables:**\r\n  - Supports `.env` and `config.json`, see `src/services/config.ts`.\r\n\r\n---\r\n\r\n## Working with this repo\r\n\r\n[👉 Contributing Guide](./CONTRIBUTING.md)\r\n","readmeFilename":"README.md","_rev":"1-1d84815571ec688833c242a2e14db818"}