{"_id":"@aizigao/pi-claude-code-headers-compat","_rev":"7-d9fa94d6b3dac66a12987e35dfe95bd7","name":"@aizigao/pi-claude-code-headers-compat","dist-tags":{"latest":"0.4.1"},"versions":{"0.1.0":{"name":"@aizigao/pi-claude-code-headers-compat","version":"0.1.0","keywords":["pi-package","pi-extension","claude","claude code","anthropic","headers","compat"],"license":"MIT","_id":"@aizigao/pi-claude-code-headers-compat@0.1.0","maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"homepage":"https://github.com/aizigao/pi-claude-code-headers-compat#readme","bugs":{"url":"https://github.com/aizigao/pi-claude-code-headers-compat/issues"},"pi":{"extensions":["./index.ts"]},"dist":{"shasum":"7d627878d315092087f71462c21e72b4a1ae62fe","tarball":"https://registry.npmjs.org/@aizigao/pi-claude-code-headers-compat/-/pi-claude-code-headers-compat-0.1.0.tgz","fileCount":4,"integrity":"sha512-YADKg4jRjQUu8OQLMj6e6M+Ya4L9GV2HBZ+70nwrcoAzN2T/1AhnlwN3ihFlo7ttIxQwXtO28pzEnbGVwJtwtg==","signatures":[{"sig":"MEUCIQDgegDlMyNg/itJZqN7Q0lOF6DlsmNDR9Gyl/6tght7vgIgCZH6hvF5IETj3P41doPGaaRNTcn7XN2OXQbcuYGApVI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19512},"type":"module","engines":{"node":">=20"},"gitHead":"4e8eac0b69791b2e8ebc63f95e4928db68a96b1d","scripts":{"lint":"node ./node_modules/eslint/bin/eslint.js .","check":"node ./node_modules/typescript/bin/tsc --noEmit","lint:fix":"node ./node_modules/eslint/bin/eslint.js . --fix"},"_npmUser":{"name":"aizigao","email":"weixiangzhe@live.com"},"repository":{"url":"git+https://github.com/aizigao/pi-claude-code-headers-compat.git","type":"git"},"_npmVersion":"10.9.4","description":"Pi extension package for Claude-compatible header and request-path adaptation across multiple providers.","directories":{},"_nodeVersion":"22.21.1","dependencies":{"undici":"^7.16.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.39.1","@eslint/js":"^9.39.1","typescript":"^5.9.3","@types/node":"^24.10.1","typescript-eslint":"^8.46.4","@earendil-works/pi-coding-agent":"*"},"peerDependencies":{"@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-claude-code-headers-compat_0.1.0_1779604532017_0.891636141189819","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@aizigao/pi-claude-code-headers-compat","version":"0.1.1","keywords":["pi-package","pi-extension","claude","claude code","anthropic","headers","compat","Cloudflare"],"license":"MIT","_id":"@aizigao/pi-claude-code-headers-compat@0.1.1","maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"homepage":"https://github.com/aizigao/pi-claude-code-headers-compat#readme","bugs":{"url":"https://github.com/aizigao/pi-claude-code-headers-compat/issues"},"pi":{"extensions":["./index.ts"]},"dist":{"shasum":"c21449bfc203c8a79188b67cd621b7b1e7909da2","tarball":"https://registry.npmjs.org/@aizigao/pi-claude-code-headers-compat/-/pi-claude-code-headers-compat-0.1.1.tgz","fileCount":4,"integrity":"sha512-lxmf2zu0LHH4vdAQgLvx4NbrvO/mDQWZBg7W4UzVeDuRy7FTtqgZsw/p5b1+LZ3Y/3QI1dASzE2rkW2nNsQGYA==","signatures":[{"sig":"MEUCIDU8YVFQJc4N0/ucxE0uiM9Fk73oa5BsksnWlW58oXwCAiEAvkrO7gsqNT3zU3MW+psvkN9z32LUH4pHf5zg0cBOFUQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20589},"type":"module","engines":{"node":">=20"},"gitHead":"c7ffdcd188b78830eb6d6b04d1c38b2cc3ac5572","scripts":{"lint":"node ./node_modules/eslint/bin/eslint.js .","check":"node ./node_modules/typescript/bin/tsc --noEmit","lint:fix":"node ./node_modules/eslint/bin/eslint.js . --fix"},"_npmUser":{"name":"aizigao","email":"weixiangzhe@live.com"},"repository":{"url":"git+https://github.com/aizigao/pi-claude-code-headers-compat.git","type":"git"},"_npmVersion":"10.9.4","description":"Pi extension package for Claude-compatible header and request-path adaptation across multiple providers.","directories":{},"_nodeVersion":"22.21.1","dependencies":{"undici":"^7.16.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.39.1","@eslint/js":"^9.39.1","typescript":"^5.9.3","@types/node":"^24.10.1","typescript-eslint":"^8.46.4","@earendil-works/pi-coding-agent":"*"},"peerDependencies":{"@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-claude-code-headers-compat_0.1.1_1779605628665_0.24815750383365587","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@aizigao/pi-claude-code-headers-compat","version":"0.1.2","keywords":["pi-package","pi-extension","claude","claude code","anthropic","headers","compat","Cloudflare"],"license":"MIT","_id":"@aizigao/pi-claude-code-headers-compat@0.1.2","maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"homepage":"https://github.com/aizigao/pi-claude-code-headers-compat#readme","bugs":{"url":"https://github.com/aizigao/pi-claude-code-headers-compat/issues"},"pi":{"extensions":["./index.ts"]},"dist":{"shasum":"cc71ef89c7885ce1095b1a9174e2520d2bebb488","tarball":"https://registry.npmjs.org/@aizigao/pi-claude-code-headers-compat/-/pi-claude-code-headers-compat-0.1.2.tgz","fileCount":4,"integrity":"sha512-gEBsfzMAqjy1DV73yi9j005dsTSv6GCuRifbTKMRj6mNAxYBfDYy8JlruXO9iEborIHZpZNwGjH1rAtYNk1wgg==","signatures":[{"sig":"MEQCIDfBQD5xAk+vMxgKr5z2I5Vryj2hkpOc4LEOR5EWadPIAiA33E5bxakdCwmr2+3ehnKnyc6wuMGLfrt0DE6OUcBhuA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20999},"type":"module","engines":{"node":">=20"},"gitHead":"3836970423dd9bf122f8629ee9b5f1d0c5df2136","scripts":{"lint":"node ./node_modules/eslint/bin/eslint.js .","check":"node ./node_modules/typescript/bin/tsc --noEmit","lint:fix":"node ./node_modules/eslint/bin/eslint.js . --fix"},"_npmUser":{"name":"aizigao","email":"weixiangzhe@live.com"},"repository":{"url":"git+https://github.com/aizigao/pi-claude-code-headers-compat.git","type":"git"},"_npmVersion":"10.9.4","description":"Pi extension package for Claude-compatible header and request-path adaptation across multiple providers.","directories":{},"_nodeVersion":"22.21.1","dependencies":{"undici":"^7.16.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.39.1","@eslint/js":"^9.39.1","typescript":"^5.9.3","@types/node":"^24.10.1","typescript-eslint":"^8.46.4","@earendil-works/pi-coding-agent":"*"},"peerDependencies":{"@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-claude-code-headers-compat_0.1.2_1779938502505_0.5823531186106023","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@aizigao/pi-claude-code-headers-compat","version":"0.2.0","keywords":["pi-package","pi-extension","claude","claude code","anthropic","headers","compat","Cloudflare"],"license":"MIT","_id":"@aizigao/pi-claude-code-headers-compat@0.2.0","maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"homepage":"https://github.com/aizigao/pi-claude-code-headers-compat#readme","bugs":{"url":"https://github.com/aizigao/pi-claude-code-headers-compat/issues"},"pi":{"extensions":["./index.ts"]},"dist":{"shasum":"58bde033ccdbcb09d02d7935b20ba5292e7fb562","tarball":"https://registry.npmjs.org/@aizigao/pi-claude-code-headers-compat/-/pi-claude-code-headers-compat-0.2.0.tgz","fileCount":4,"integrity":"sha512-ilSTNxE4CCAyZk9TQEkdp6AHOMrUwPKOrSgQQsW9pYaZPTx0lSvtcVdYXCfbRUwlJQU/B46/o/hM3jOKmO5oSA==","signatures":[{"sig":"MEUCIQDtXLjTy+YVLBAG7jczmwm2tbC5TWdkzOMpGjGbkyQcBwIgOn28F+kdyP1wFtPJkvFnXMPEOfpLN0iiYrWuq9jzIvI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23386},"type":"module","engines":{"node":">=20"},"gitHead":"86b4089e0feb65e52b13df5bbdf2ca0d1c126d55","scripts":{"lint":"node ./node_modules/eslint/bin/eslint.js .","check":"node ./node_modules/typescript/bin/tsc --noEmit","lint:fix":"node ./node_modules/eslint/bin/eslint.js . --fix"},"_npmUser":{"name":"aizigao","email":"weixiangzhe@live.com"},"repository":{"url":"git+https://github.com/aizigao/pi-claude-code-headers-compat.git","type":"git"},"_npmVersion":"10.9.4","description":"Pi extension package for Claude-compatible header and request-path adaptation across multiple providers.","directories":{},"_nodeVersion":"22.21.1","dependencies":{"undici":"^7.16.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.39.1","@eslint/js":"^9.39.1","typescript":"^5.9.3","@types/node":"^24.10.1","typescript-eslint":"^8.46.4","@earendil-works/pi-coding-agent":"*"},"peerDependencies":{"@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-claude-code-headers-compat_0.2.0_1780043676463_0.3445526292598291","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@aizigao/pi-claude-code-headers-compat","version":"0.3.0","keywords":["pi-package","pi-extension","claude","claude code","anthropic","headers","compat","Cloudflare"],"license":"MIT","_id":"@aizigao/pi-claude-code-headers-compat@0.3.0","maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"homepage":"https://github.com/aizigao/pi-claude-code-headers-compat#readme","bugs":{"url":"https://github.com/aizigao/pi-claude-code-headers-compat/issues"},"pi":{"extensions":["./index.ts"]},"dist":{"shasum":"f3167b347b7b425d80c6dc479e83f26c3a4b0790","tarball":"https://registry.npmjs.org/@aizigao/pi-claude-code-headers-compat/-/pi-claude-code-headers-compat-0.3.0.tgz","fileCount":4,"integrity":"sha512-idk7Q1g11aS9KSXx5YEGslArxbPORaovwsMNKntf29W2xSy02A2lEVtqfCCnB8UNxtWQf/apXpkLz9BoNI8j0w==","signatures":[{"sig":"MEQCIHzVu3XU4QykTZKAlWMdumd80HQeIrafHtdOcBcdDzKSAiAk+VzS35eho2M5JyB/nAKvE5A1XykZVH4Y4nNUpz4y3A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23438},"type":"module","engines":{"node":">=20"},"gitHead":"bd4d37216939a9980225d17c3f4af8659ad989b4","scripts":{"lint":"node ./node_modules/eslint/bin/eslint.js .","check":"node ./node_modules/typescript/bin/tsc --noEmit","lint:fix":"node ./node_modules/eslint/bin/eslint.js . --fix"},"_npmUser":{"name":"aizigao","email":"weixiangzhe@live.com"},"repository":{"url":"git+https://github.com/aizigao/pi-claude-code-headers-compat.git","type":"git"},"_npmVersion":"10.9.4","description":"Pi extension package for Claude-compatible header and request-path adaptation across multiple providers.","directories":{},"_nodeVersion":"22.21.1","dependencies":{"undici":"^7.16.0","@aizigao/pi-fetch-pipeline":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.39.1","@eslint/js":"^9.39.1","typescript":"^5.9.3","@types/node":"^24.10.1","typescript-eslint":"^8.46.4","@earendil-works/pi-coding-agent":"*"},"peerDependencies":{"@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-claude-code-headers-compat_0.3.0_1780221760494_0.7241851722669059","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@aizigao/pi-claude-code-headers-compat","version":"0.4.0","keywords":["pi-package","pi-extension","claude","claude code","anthropic","headers","compat","Cloudflare"],"license":"MIT","_id":"@aizigao/pi-claude-code-headers-compat@0.4.0","maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"homepage":"https://github.com/aizigao/pi-claude-code-headers-compat#readme","bugs":{"url":"https://github.com/aizigao/pi-claude-code-headers-compat/issues"},"pi":{"extensions":["./index.ts"]},"dist":{"shasum":"46bb4c7e64f2bed0e394381a31f47475fa8df147","tarball":"https://registry.npmjs.org/@aizigao/pi-claude-code-headers-compat/-/pi-claude-code-headers-compat-0.4.0.tgz","fileCount":4,"integrity":"sha512-3jfj1sELjDCPWxbsFxR8w3uuVU+viDh44Kg0/DG2pgFAJtceVcmgyZubUoqFBqN7WhkUYi7MzrNMGimoe5RS7g==","signatures":[{"sig":"MEQCIHapbziQ6jd7DYnsoPQKptmzv61JYibyytqyD5nkPg+AAiA9K1ov/ARoHF9uEc7EZ3oRt5nyxUK2M6J9RZH0bHfhbg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23864},"type":"module","engines":{"node":">=20"},"gitHead":"f41123005a44749457fee7f6da67c2b863f7bbb2","scripts":{"lint":"node ./node_modules/eslint/bin/eslint.js .","check":"node ./node_modules/typescript/bin/tsc --noEmit","lint:fix":"node ./node_modules/eslint/bin/eslint.js . --fix"},"_npmUser":{"name":"aizigao","email":"weixiangzhe@live.com"},"repository":{"url":"git+https://github.com/aizigao/pi-claude-code-headers-compat.git","type":"git"},"_npmVersion":"10.9.4","description":"Pi extension package for Claude-compatible header and request-path adaptation across multiple providers.","directories":{},"_nodeVersion":"22.21.1","dependencies":{"undici":"^7.16.0","@aizigao/pi-fetch-pipeline":"^1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.39.1","@eslint/js":"^9.39.1","typescript":"^5.9.3","@types/node":"^24.10.1","typescript-eslint":"^8.46.4","@earendil-works/pi-coding-agent":"*"},"peerDependencies":{"@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-claude-code-headers-compat_0.4.0_1780298308818_0.3646855551918802","host":"s3://npm-registry-packages-npm-production"}},"0.4.1":{"name":"@aizigao/pi-claude-code-headers-compat","version":"0.4.1","description":"Pi extension package for Claude-compatible header and request-path adaptation across multiple providers.","type":"module","license":"MIT","homepage":"https://github.com/aizigao/pi-claude-code-headers-compat#readme","repository":{"type":"git","url":"git+https://github.com/aizigao/pi-claude-code-headers-compat.git"},"bugs":{"url":"https://github.com/aizigao/pi-claude-code-headers-compat/issues"},"keywords":["pi-package","pi-extension","claude","claude code","anthropic","headers","compat","Cloudflare"],"engines":{"node":">=20"},"publishConfig":{"access":"public"},"scripts":{"check":"node ./node_modules/typescript/bin/tsc --noEmit","lint":"node ./node_modules/eslint/bin/eslint.js .","lint:fix":"node ./node_modules/eslint/bin/eslint.js . --fix"},"pi":{"extensions":["./index.ts"]},"dependencies":{"@aizigao/pi-fetch-pipeline":"^1.0.0","undici":"^7.16.0"},"peerDependencies":{"@earendil-works/pi-coding-agent":"*"},"devDependencies":{"@earendil-works/pi-coding-agent":"*","@eslint/js":"^9.39.1","@types/node":"^24.10.1","eslint":"^9.39.1","typescript":"^5.9.3","typescript-eslint":"^8.46.4"},"_id":"@aizigao/pi-claude-code-headers-compat@0.4.1","gitHead":"5c67dca1918b8294ed98f9ac4f032ab58624d00b","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-k4BtP6szFM9TZcDj/le6h36xrQIC/+nQ6hzsoXtoBvS3sSeoyWcwhxcMs1lxuXjzm92RUCM86yWT4mVxCzZE4g==","shasum":"ab5cae25076ec2565c70821d20ae82eb32e55273","tarball":"https://registry.npmjs.org/@aizigao/pi-claude-code-headers-compat/-/pi-claude-code-headers-compat-0.4.1.tgz","fileCount":4,"unpackedSize":23864,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAYuhyrzHOdZUCAXM/EJST3oZJ2E3UBhCRtum7v/01tCAiEA2xxLmijbfV4JPAiexwM9OWqeZE3gRef/if0oit8taLs="}]},"_npmUser":{"name":"aizigao","email":"weixiangzhe@live.com"},"directories":{},"maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pi-claude-code-headers-compat_0.4.1_1781591066426_0.1024097997847635"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-24T06:35:31.912Z","modified":"2026-06-16T06:24:26.695Z","0.1.0":"2026-05-24T06:35:32.143Z","0.1.1":"2026-05-24T06:53:48.797Z","0.1.2":"2026-05-28T03:21:42.641Z","0.2.0":"2026-05-29T08:34:36.598Z","0.3.0":"2026-05-31T10:02:40.647Z","0.4.0":"2026-06-01T07:18:28.950Z","0.4.1":"2026-06-16T06:24:26.574Z"},"bugs":{"url":"https://github.com/aizigao/pi-claude-code-headers-compat/issues"},"license":"MIT","homepage":"https://github.com/aizigao/pi-claude-code-headers-compat#readme","keywords":["pi-package","pi-extension","claude","claude code","anthropic","headers","compat","Cloudflare"],"repository":{"type":"git","url":"git+https://github.com/aizigao/pi-claude-code-headers-compat.git"},"description":"Pi extension package for Claude-compatible header and request-path adaptation across multiple providers.","maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"readme":"# pi-claude-code-headers-compat\n\n[简体中文](https://github.com/aizigao/pi-claude-code-headers-compat/blob/main/README-CN.md) | [English](https://github.com/aizigao/pi-claude-code-headers-compat/blob/main/README.md)\n\n[![npm version](https://img.shields.io/npm/v/%40aizigao%2Fpi-claude-code-headers-compat.svg)](https://www.npmjs.com/package/@aizigao/pi-claude-code-headers-compat)\n\nThe requests sent by Pi with `\"api\": \"anthropic-messages\"` use the SDK format, which is not exactly the same as the requests sent by Claude Code. The specific problem I am facing is that my proxy provider is currently blocked by Cloudflare as crawler traffic. The purpose of this package is to make the request `headers` look broadly closer to what Claude Code sends.\n\nThe goal of this plugin is not to change the structure of `models.json`, but to add an extra compatibility layer while keeping Pi's original provider configuration style.\n\n## Who this is for\n\nThis package is suitable for users who:\n- already configured custom providers in Pi\n- use Claude-compatible proxy/provider endpoints\n- run into incompatible headers, incompatible paths, or unexpected API responses\n- want to handle these compatibility rules through a standalone package\n- get `403` responses from the proxy provider\n\n## What it does\n\nWhen enabled, the package will:\n- read configured providers from the official `~/.pi/agent/models.json`\n- read compatibility settings from `~/.pi/agent/claude-code-headers-compat.json`\n- only apply compatibility handling to matched provider requests\n- automatically rewrite request paths and adjust headers before sending the request\n\n## Installation\n\nInstall it in Pi with:\n\n```bash\npi install npm:@aizigao/pi-claude-code-headers-compat\n```\n\nIf you are developing this project locally, use:\n\n```bash\nnpm install\n```\n\n## Configuration\n\n### 1. Configure the provider\n\nUsing my current proxy provider [aicoding.sh](https://aicoding.sh/i/kD8yO7) as an example: when used in Pi, Cloudflare treats the request as crawler traffic because of the headers and returns `403`. My configuration is:\n\nFile: `~/.pi/agent/models.json`.\nKeep using Pi's default format for this file. No structure changes are needed.\n\n```json\n{\n  \"providers\": {\n    \"aicoding-sh-anthropic\": {\n      \"baseUrl\": \"https://api.aicoding.sh\",\n      \"api\": \"anthropic-messages\",\n      \"apiKey\": \"$AI_CODING_SH_API_KEY\",\n      \"models\": [\n        {\n          \"id\": \"claude-sonnet-4-6\",\n          \"name\": \"azg-claude-sonnet-4-6\",\n          \"reasoning\": true,\n          \"input\": [\"text\", \"image\"],\n          \"cost\": {\n            \"input\": 3,\n            \"output\": 15,\n            \"cacheRead\": 0.3,\n            \"cacheWrite\": 3.75\n          },\n          \"contextWindow\": 1000000,\n          \"maxTokens\": 128000\n        },\n        {\n          \"id\": \"claude-opus-4-7\",\n          \"name\": \"azg-claude-opus-4-7\",\n          \"reasoning\": true,\n          \"input\": [\"text\", \"image\"],\n          \"cost\": {\n            \"input\": 15,\n            \"output\": 75,\n            \"cacheRead\": 1.5,\n            \"cacheWrite\": 18.75\n          },\n          \"contextWindow\": 1000000,\n          \"maxTokens\": 128000\n        },\n        {\n          \"id\": \"gpt-5.5\",\n          \"name\": \"azg-gpt-5.5\",\n          \"reasoning\": true,\n          \"input\": [\"text\", \"image\"],\n          \"cost\": {\n            \"input\": 5,\n            \"output\": 30,\n            \"cacheRead\": 0.5,\n            \"cacheWrite\": 6.25\n          },\n          \"contextWindow\": 1000000,\n          \"maxTokens\": 128000\n        },\n        {\n          \"id\": \"gpt-5.4\",\n          \"name\": \"azg-gpt-5.4\",\n          \"reasoning\": true,\n          \"input\": [\"text\", \"image\"],\n          \"cost\": {\n            \"input\": 2.5,\n            \"output\": 15,\n            \"cacheRead\": 0.25,\n            \"cacheWrite\": 3.125\n          },\n          \"contextWindow\": 1000000,\n          \"maxTokens\": 128000\n        },\n        {\n          \"id\": \"gpt-5.3-codex\",\n          \"name\": \"azg-gpt-5.3-codex\",\n          \"reasoning\": true,\n          \"input\": [\"text\", \"image\"],\n          \"cost\": {\n            \"input\": 1.75,\n            \"output\": 14,\n            \"cacheRead\": 0.175,\n            \"cacheWrite\": 2.1875\n          },\n          \"contextWindow\": 1000000,\n          \"maxTokens\": 128000\n        }\n      ]\n    }\n  }\n}\n```\n\nNotes:\n- the key under `providers` is the provider name\n- `apiKey` follows the latest official value-resolution rules: it supports `!command`, `$ENV`, `${ENV}`, composite interpolation like `${KEY_PREFIX}_${KEY_SUFFIX}`, escapes like `$$` / `$!`, and literal values\n- legacy uppercase env-style values such as `AI_CODING_SH_API_KEY` are still treated as env var names for backward compatibility\n- the plugin matches compatibility logic using the provider name and `baseUrl`\n\n### 2. Configure compatibility rules\n\nFile: `~/.pi/agent/claude-code-headers-compat.json`\n\nYour current configuration example:\n\n```json\n{\n  \"enable\": true,\n  \"matchedProviders\": [\"aicoding-sh-anthropic\"],\n  \"modifyHeaders\": {\n    \"USER_AGENT\": \"2.1.178 (Claude Code)\",\n    \"ANTHROPIC_VERSION\": \"2023-06-01\"\n  }\n}\n```\n\nField reference:\n\n#### `enable`\n\nWhether to enable it.\n\n#### `matchedProviders`\nThe list of provider names that should use compatibility handling. Configure it as needed.\n\nRequirements:\n- the names must match the provider keys in `models.json`\n- only providers listed here will get compatibility handling\n\nCompatibility note:\n- `matchedProviders` is the current field name\n- legacy `matchedProvidersUrl` is still supported for backward compatibility\n\n#### `modifyHeaders`\nUsed to override default header values.\n\nCurrently supported:\n- `USER_AGENT`\n- `ANTHROPIC_VERSION`\n- `ACCEPT`\n- `CONTENT_TYPE`\n- `AUTHORIZATION`\n\nNotes:\n- if a field is omitted, it falls back to the default value\n- `AUTHORIZATION` defaults to `Bearer ${API_KEY}`\n- `${API_KEY}` will be replaced with the final resolved key value for that provider\n- `apiKey` resolution follows Pi's latest rules:\n  - `!command` executes the command and uses stdout\n  - `$ENV` / `${ENV}` interpolates environment variables, including composite values like `${KEY_PREFIX}_${KEY_SUFFIX}`\n  - `$$` emits a literal `$`, and `$!` emits a literal `!`\n  - other values are treated as literals\n- for backward compatibility, legacy uppercase env-style values are still resolved as environment variable names when present\n\n## How it works\n\nThis package uses `@aizigao/pi-fetch-pipeline` to register a fetch middleware that intercepts outgoing requests. When a request matches a configured provider, the middleware rewrites the URL and adjusts headers before forwarding the request down the pipeline. This approach avoids directly patching `globalThis.fetch`, making it safer to coexist with other extensions that also modify fetch behavior.\n\n## Usage\n\nAfter configuration:\n1. make sure the provider is already defined in `models.json`\n2. make sure that provider is enabled in `claude-code-headers-compat.json`\n3. start Pi\n4. when that provider sends requests, the plugin will automatically apply the compatibility handling\n\n## Notes\n\n- provider names in `matchedProviders` must stay consistent with `models.json`\n- legacy `matchedProvidersUrl` is still accepted, but new configs should use `matchedProviders`\n- `apiKey` in `models.json` supports the latest Pi value-resolution syntax, including `!command`, `$ENV`, `${ENV}`, composite interpolation, escapes, and literals\n- this package is currently aimed at Claude-compatible provider scenarios\n- if a provider does not match, requests will not be rewritten\n\n## Request header change list (added/removed/modified)\n\nNote: the following changes only apply when a provider matches the compatibility rules.\n\n### Removed headers\n\nRemoved by default:\n- `x-api-key`\n- `anthropic-dangerous-direct-browser-access`\n- `accept-language`\n- `x-app`\n- `x-pi-provider-marker`\n- `x-stainless-*` (prefix match)\n- `sec-fetch-*` (prefix match)\n\n### Added headers\n\nAdded by default when missing:\n- `authorization: Bearer ${API_KEY}`\n- `user-agent: 2.1.178 (Claude Code)`\n- `anthropic-version: 2023-06-01`\n- `accept: application/json`\n- `content-type: application/json`\n\nIn addition, the plugin injects a marker header during provider registration for request matching:\n- `x-pi-provider-marker: <providerName>`\n\n### Headers you can modify in config\n\nThese headers are force-overridden by default (if already present, values are rewritten):\n- `authorization`\n- `user-agent`\n- `anthropic-version`\n- `accept`\n- `content-type`\n\nYou can override the defaults through `modifyHeaders` (legacy style) or `providers.<name>.setHeaders` (new style).\n","readmeFilename":"README.md"}