{"_id":"@amux.ai/llm-bridge","_rev":"4-a44ccfbc92eded983060410438e9032d","name":"@amux.ai/llm-bridge","dist-tags":{"latest":"0.3.2"},"versions":{"0.2.0":{"name":"@amux.ai/llm-bridge","version":"0.2.0","keywords":["amux","llm","api","adapter","bridge","core"],"author":{"name":"isboyjc"},"license":"MIT","_id":"@amux.ai/llm-bridge@0.2.0","maintainers":[{"name":"isboyjc","email":"214930661@qq.com"}],"homepage":"https://github.com/isboyjc/amux#readme","bugs":{"url":"https://github.com/isboyjc/amux/issues"},"dist":{"shasum":"c5c8577681f203030aa3bd580e51d7f7835bfa65","tarball":"https://registry.npmjs.org/@amux.ai/llm-bridge/-/llm-bridge-0.2.0.tgz","fileCount":7,"integrity":"sha512-/Nhkn+jap9ZRKp7KYrHFg+tiVRMoictqXmvhSrvNaJQ9EIMh3xQe+zm0Mb60SqKuUamA4Ehznl5bzv9Ng5gjSw==","signatures":[{"sig":"MEUCIQD9igO/YVmL/5IGdZ6psQMHXjrVJ2+GA5ZC8qdyRgR31wIgZDbi1/rqFHOFdlL+vWifrMckdeaTvDl4q2+2Ro4QzcY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":255320},"main":"./dist/index.cjs","type":"module","_from":"file:amux.ai-llm-bridge-0.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts","test":"vitest run","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"isboyjc","email":"214930661@qq.com"},"_resolved":"/private/var/folders/40/ydvkbdz503l88ck6kxydy50w0000gn/T/b97bba9389d808afda6130e9ab267d4e/amux.ai-llm-bridge-0.2.0.tgz","_integrity":"sha512-/Nhkn+jap9ZRKp7KYrHFg+tiVRMoictqXmvhSrvNaJQ9EIMh3xQe+zm0Mb60SqKuUamA4Ehznl5bzv9Ng5gjSw==","repository":{"url":"git+https://github.com/isboyjc/amux.git","type":"git","directory":"packages/llm-bridge"},"_npmVersion":"10.9.2","description":"Core IR and adapter interfaces for Amux","directories":{},"_nodeVersion":"22.15.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.1","vitest":"^1.2.1","typescript":"^5.3.3","@types/node":"^20.11.5"},"_npmOperationalInternal":{"tmp":"tmp/llm-bridge_0.2.0_1769284658626_0.06332993192281688","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@amux.ai/llm-bridge","version":"0.3.0","keywords":["amux","llm","api","adapter","bridge","core"],"author":{"name":"isboyjc"},"license":"MIT","_id":"@amux.ai/llm-bridge@0.3.0","maintainers":[{"name":"isboyjc","email":"214930661@qq.com"}],"homepage":"https://github.com/isboyjc/amux#readme","bugs":{"url":"https://github.com/isboyjc/amux/issues"},"dist":{"shasum":"dedbefcf45eb801de1ba3ac72f9237aa593c10ed","tarball":"https://registry.npmjs.org/@amux.ai/llm-bridge/-/llm-bridge-0.3.0.tgz","fileCount":8,"integrity":"sha512-MyoFnDRuEZAA6DomywrgCu+AewFfXnAslhLfm32ehrT73Bu71mzUfhDOV7zMJ1sXopQ+ikxYNTOIUWB6GiUNVg==","signatures":[{"sig":"MEUCIFDBBxNQnLBhws+f4hEysihP0kzqhxTGCUpZowt4s938AiEAmIyDsVd/J/J2JYs/NLNlJZQabgS5qtSCAnzEyt93dws=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":260596},"main":"./dist/index.cjs","type":"module","_from":"file:amux.ai-llm-bridge-0.3.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts","test":"vitest run","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"isboyjc","email":"214930661@qq.com"},"_resolved":"/private/var/folders/40/ydvkbdz503l88ck6kxydy50w0000gn/T/97622ab462aba1515ed556b52e967901/amux.ai-llm-bridge-0.3.0.tgz","_integrity":"sha512-MyoFnDRuEZAA6DomywrgCu+AewFfXnAslhLfm32ehrT73Bu71mzUfhDOV7zMJ1sXopQ+ikxYNTOIUWB6GiUNVg==","repository":{"url":"git+https://github.com/isboyjc/amux.git","type":"git","directory":"packages/llm-bridge"},"_npmVersion":"10.9.2","description":"Core IR and adapter interfaces for Amux","directories":{},"_nodeVersion":"22.15.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.1","vitest":"^1.2.1","typescript":"^5.3.3","@types/node":"^20.11.5"},"_npmOperationalInternal":{"tmp":"tmp/llm-bridge_0.3.0_1769294673161_0.42898243636109745","host":"s3://npm-registry-packages-npm-production"}},"0.3.1":{"name":"@amux.ai/llm-bridge","version":"0.3.1","keywords":["amux","llm","api","adapter","bridge","core"],"author":{"name":"isboyjc"},"license":"MIT","_id":"@amux.ai/llm-bridge@0.3.1","maintainers":[{"name":"isboyjc","email":"214930661@qq.com"}],"homepage":"https://github.com/isboyjc/amux#readme","bugs":{"url":"https://github.com/isboyjc/amux/issues"},"dist":{"shasum":"5a4cd50a259e186297e40e7e2faf81b274b4c048","tarball":"https://registry.npmjs.org/@amux.ai/llm-bridge/-/llm-bridge-0.3.1.tgz","fileCount":8,"integrity":"sha512-CpGGwPyggDNPngpNynPHXuj9Hr6uw7gJ8STJ/3JSWI6BnPLnyuZY6sLIgTbL/xofBeiEir/oJkueJc9yGa/4kg==","signatures":[{"sig":"MEYCIQC6Dae5AzjCj89cKdygkr2rgP86tUtd+HEH3AwZVmSUtgIhALtbLTN8eOuUwUDm9ubQHxjFZjbliqhciJNesBnckSHn","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":260596},"main":"./dist/index.cjs","type":"module","_from":"file:amux.ai-llm-bridge-0.3.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts","test":"vitest run","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"isboyjc","email":"214930661@qq.com"},"_resolved":"/private/var/folders/40/ydvkbdz503l88ck6kxydy50w0000gn/T/4bbad71580424d377b9090b34287bd65/amux.ai-llm-bridge-0.3.1.tgz","_integrity":"sha512-CpGGwPyggDNPngpNynPHXuj9Hr6uw7gJ8STJ/3JSWI6BnPLnyuZY6sLIgTbL/xofBeiEir/oJkueJc9yGa/4kg==","repository":{"url":"git+https://github.com/isboyjc/amux.git","type":"git","directory":"packages/llm-bridge"},"_npmVersion":"10.9.2","description":"Core IR and adapter interfaces for Amux","directories":{},"_nodeVersion":"22.15.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.1","vitest":"^1.2.1","typescript":"^5.3.3","@types/node":"^20.11.5"},"_npmOperationalInternal":{"tmp":"tmp/llm-bridge_0.3.1_1769632643223_0.5553192273458669","host":"s3://npm-registry-packages-npm-production"}},"0.3.2":{"name":"@amux.ai/llm-bridge","version":"0.3.2","description":"Core IR and adapter interfaces for Amux","keywords":["amux","llm","api","adapter","bridge","core"],"repository":{"type":"git","url":"git+https://github.com/isboyjc/amux.git","directory":"packages/llm-bridge"},"homepage":"https://github.com/isboyjc/amux#readme","bugs":{"url":"https://github.com/isboyjc/amux/issues"},"license":"MIT","author":{"name":"isboyjc"},"type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","devDependencies":{"@types/node":"^20.11.5","tsup":"^8.0.1","typescript":"^5.3.3","vitest":"^1.2.1"},"publishConfig":{"access":"public"},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","typecheck":"tsc --noEmit","lint":"eslint src --ext .ts","clean":"rm -rf dist"},"_id":"@amux.ai/llm-bridge@0.3.2","_integrity":"sha512-xIFXV1BRS1D9ZAbrTatcndtF8cV6TyBodGTCBAOxHWCYIs3LqKAfhzJDyyv4vTs51fCtpC4YLR5DXFUT/nb3Fw==","_resolved":"/private/var/folders/40/ydvkbdz503l88ck6kxydy50w0000gn/T/53245fdd782f73a8edd34850af62312a/amux.ai-llm-bridge-0.3.2.tgz","_from":"file:amux.ai-llm-bridge-0.3.2.tgz","_nodeVersion":"22.15.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-xIFXV1BRS1D9ZAbrTatcndtF8cV6TyBodGTCBAOxHWCYIs3LqKAfhzJDyyv4vTs51fCtpC4YLR5DXFUT/nb3Fw==","shasum":"606518dfb4c5d8c62127cf1e82c3bc5dae0c9dda","tarball":"https://registry.npmjs.org/@amux.ai/llm-bridge/-/llm-bridge-0.3.2.tgz","fileCount":8,"unpackedSize":266160,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDYX8b8S0SqowxhYQKsRFN6NNu8Z0l5WL7sIpCxl9AIZAIhAPESUQpDjM4tX0ajSsEee908q8Bbqa4BPjv5UnsJwGoJ"}]},"_npmUser":{"name":"isboyjc","email":"214930661@qq.com"},"directories":{},"maintainers":[{"name":"isboyjc","email":"214930661@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/llm-bridge_0.3.2_1770213329003_0.4450663209521397"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-24T19:57:38.572Z","modified":"2026-02-04T13:55:29.324Z","0.2.0":"2026-01-24T19:57:38.792Z","0.3.0":"2026-01-24T22:44:33.331Z","0.3.1":"2026-01-28T20:37:23.370Z","0.3.2":"2026-02-04T13:55:29.154Z"},"bugs":{"url":"https://github.com/isboyjc/amux/issues"},"author":{"name":"isboyjc"},"license":"MIT","homepage":"https://github.com/isboyjc/amux#readme","keywords":["amux","llm","api","adapter","bridge","core"],"repository":{"type":"git","url":"git+https://github.com/isboyjc/amux.git","directory":"packages/llm-bridge"},"description":"Core IR and adapter interfaces for Amux","maintainers":[{"name":"isboyjc","email":"214930661@qq.com"}],"readme":"# @amux.ai/llm-bridge\n\n> Core IR (Intermediate Representation) and adapter interfaces for Amux\n\n[![npm version](https://img.shields.io/npm/v/@amux.ai/llm-bridge.svg)](https://www.npmjs.com/package/@amux.ai/llm-bridge)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Overview\n\n`@amux.ai/llm-bridge` is the core package of Amux that provides:\n\n- **Intermediate Representation (IR)**: Unified data structures for LLM requests/responses\n- **Adapter Interface**: Standard interface for building provider adapters\n- **Bridge Pattern**: Orchestration layer for bidirectional conversion\n- **HTTP Client**: Built-in HTTP client with SSE streaming support\n- **Zero Dependencies**: No runtime dependencies\n\n## Installation\n\n```bash\npnpm add @amux.ai/llm-bridge\n# or\nnpm install @amux.ai/llm-bridge\n# or\nyarn add @amux.ai/llm-bridge\n```\n\n## Quick Start\n\n### Create a Bridge\n\n```typescript\nimport { createBridge } from '@amux.ai/llm-bridge'\nimport { openaiAdapter } from '@amux.ai/adapter-openai'\nimport { anthropicAdapter } from '@amux.ai/adapter-anthropic'\n\nconst bridge = createBridge({\n  inbound: openaiAdapter,\n  outbound: anthropicAdapter,\n  config: {\n    apiKey: process.env.ANTHROPIC_API_KEY,\n    baseURL: 'https://api.anthropic.com'\n  }\n})\n\n// Send request in OpenAI format, get response in OpenAI format\n// But actually calls Anthropic API under the hood\nconst response = await bridge.chat({\n  model: 'gpt-4',\n  messages: [{ role: 'user', content: 'Hello!' }]\n})\n```\n\n### Streaming\n\n```typescript\nfor await (const chunk of bridge.chatStream({\n  model: 'gpt-4',\n  messages: [{ role: 'user', content: 'Tell me a story' }],\n  stream: true\n})) {\n  console.log(chunk)\n}\n```\n\n## Core Concepts\n\n### Intermediate Representation (IR)\n\nThe IR is the central data structure that all adapters convert to/from:\n\n- **LLMRequestIR**: Unified request format\n- **LLMResponseIR**: Unified response format\n- **LLMStreamEvent**: Unified streaming events\n- **LLMErrorIR**: Unified error format\n\n### Adapter Interface\n\nEvery adapter implements the `LLMAdapter` interface:\n\n```typescript\ninterface LLMAdapter {\n  inbound: {\n    parseRequest(request: unknown): Promise<LLMRequestIR>\n    parseResponse(response: unknown): Promise<LLMResponseIR>\n    parseStream(chunk: string): Promise<LLMStreamEvent | null>\n    parseError(error: unknown): LLMErrorIR\n  }\n  outbound: {\n    buildRequest(ir: LLMRequestIR): unknown\n    buildResponse(ir: LLMResponseIR): unknown\n  }\n  capabilities: AdapterCapabilities\n  getInfo(): AdapterInfo\n}\n```\n\n### Bridge Pattern\n\nThe Bridge orchestrates the conversion flow:\n\n1. Inbound adapter parses incoming request → IR\n2. Validate IR (optional)\n3. Outbound adapter builds provider request from IR\n4. Send HTTP request to target provider\n5. Outbound adapter parses response → IR\n6. Inbound adapter builds final response from IR\n\n## API Reference\n\n### `createBridge(options)`\n\nCreate a new bridge instance.\n\n**Options:**\n- `inbound` - Inbound adapter instance\n- `outbound` - Outbound adapter instance\n- `config` - Configuration object\n  - `apiKey` - API key for the outbound provider\n  - `baseURL` - Base URL for the outbound provider (optional)\n  - `timeout` - Request timeout in milliseconds (optional)\n  - `headers` - Additional HTTP headers (optional)\n\n**Returns:** `Bridge` instance\n\n### `bridge.chat(request)`\n\nSend a chat completion request.\n\n**Parameters:**\n- `request` - Request object in inbound adapter format\n\n**Returns:** `Promise<Response>` - Response in inbound adapter format\n\n### `bridge.chatStream(request)`\n\nSend a streaming chat completion request.\n\n**Parameters:**\n- `request` - Request object in inbound adapter format with `stream: true`\n\n**Returns:** `AsyncIterable<string>` - Server-Sent Events stream\n\n## Available Adapters\n\n- [@amux.ai/adapter-openai](https://www.npmjs.com/package/@amux.ai/adapter-openai) - OpenAI\n- [@amux.ai/adapter-anthropic](https://www.npmjs.com/package/@amux.ai/adapter-anthropic) - Anthropic (Claude)\n- [@amux.ai/adapter-deepseek](https://www.npmjs.com/package/@amux.ai/adapter-deepseek) - DeepSeek\n- [@amux.ai/adapter-moonshot](https://www.npmjs.com/package/@amux.ai/adapter-moonshot) - Moonshot (Kimi)\n- [@amux.ai/adapter-zhipu](https://www.npmjs.com/package/@amux.ai/adapter-zhipu) - Zhipu AI (GLM)\n- [@amux.ai/adapter-qwen](https://www.npmjs.com/package/@amux.ai/adapter-qwen) - Qwen\n- [@amux.ai/adapter-google](https://www.npmjs.com/package/@amux.ai/adapter-google) - Google Gemini\n\n## TypeScript Support\n\nThis package is written in TypeScript and provides full type definitions.\n\n```typescript\nimport type { \n  LLMRequestIR, \n  LLMResponseIR, \n  LLMAdapter,\n  Bridge \n} from '@amux.ai/llm-bridge'\n```\n\n## Contributing\n\nContributions are welcome! Please see our [Contributing Guide](https://github.com/isboyjc/amux/blob/main/CONTRIBUTING.md).\n\n## License\n\nMIT © [isboyjc](https://github.com/isboyjc)\n\n## Links\n\n- [Documentation](https://github.com/isboyjc/amux#readme)\n- [GitHub Repository](https://github.com/isboyjc/amux)\n- [Issue Tracker](https://github.com/isboyjc/amux/issues)\n- [Changelog](./CHANGELOG.md)\n","readmeFilename":"README.md"}