{"_id":"@alumnium/langchain-codex","_rev":"2-403d7ed411fc7a34f44100dd425f4b77","name":"@alumnium/langchain-codex","dist-tags":{"next":"0.1.0-alpha.0","latest":"0.1.0"},"versions":{"0.1.0-alpha.0":{"name":"@alumnium/langchain-codex","version":"0.1.0-alpha.0","keywords":["langchain","openai","codex","chatgpt","oauth"],"author":{"name":"Alex Rodionov"},"license":"MIT","_id":"@alumnium/langchain-codex@0.1.0-alpha.0","maintainers":[{"name":"kossnocorp","email":"koss@nocorp.me"},{"name":"p0deje","email":"p0deje@gmail.com"}],"homepage":"https://github.com/p0deje/langchain-codex#readme","bugs":{"url":"https://github.com/p0deje/langchain-codex/issues"},"dist":{"shasum":"f20273f833e941501d597aedf89169da13fc8533","tarball":"https://registry.npmjs.org/@alumnium/langchain-codex/-/langchain-codex-0.1.0-alpha.0.tgz","fileCount":9,"integrity":"sha512-dHci4PByQ424SxJJio/5W7w+LOorVdCJrTWBGgKZZqgaTTc6t8OIIYJ0vEax1DnzlLnD9R/dMqTQFMF0L91HUg==","signatures":[{"sig":"MEUCIHYo7hiXkssGXyrK1bbgoCipXdYtplH50YsddVEd3b0DAiEAyZ0V3CBj00/UGB2fFWWzpW5ZdqUyiXcW/XdSzswVj7Y=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51476},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"dabbd2676c2ce1d802a1c38c3e98682b95c72690","scripts":{"test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"p0deje","email":"p0deje@gmail.com"},"repository":{"url":"git+https://github.com/p0deje/langchain-codex.git","type":"git"},"_npmVersion":"11.7.0","description":"LangChain chat model for OpenAI via OAuth (ChatGPT Plus/Pro)","directories":{},"_nodeVersion":"25.4.0","dependencies":{"openai-oauth":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^3.0.0","typescript":"^5.5.0","@types/node":"^25.6.0","@langchain/core":"^1.1.39","@langchain/openai":"^1.2.0"},"peerDependencies":{"@langchain/core":">=1.0.0","@langchain/openai":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/langchain-codex_0.1.0-alpha.0_1777126650653_0.08162292274545013","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@alumnium/langchain-codex","version":"0.1.0","description":"LangChain chat model for OpenAI via OAuth (ChatGPT Plus/Pro)","repository":{"type":"git","url":"git+https://github.com/p0deje/langchain-codex.git"},"keywords":["langchain","openai","codex","chatgpt","oauth"],"author":{"name":"Alex Rodionov"},"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","scripts":{"prepublishOnly":"npm run build","build":"tsup","typecheck":"tsc --noEmit","test":"vitest run"},"dependencies":{"openai-oauth":"^1.0.2"},"peerDependencies":{"@langchain/core":">=1.0.0","@langchain/openai":">=1.0.0"},"devDependencies":{"@langchain/core":"^1.1.39","@langchain/openai":"^1.2.0","@types/node":"^25.6.0","tsup":"^8.0.0","typescript":"^5.5.0","vitest":"^3.0.0"},"license":"MIT","gitHead":"dabbd2676c2ce1d802a1c38c3e98682b95c72690","_id":"@alumnium/langchain-codex@0.1.0","bugs":{"url":"https://github.com/p0deje/langchain-codex/issues"},"homepage":"https://github.com/p0deje/langchain-codex#readme","_nodeVersion":"25.4.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-f8yXaF09SsfN0mK6N/7p4uUrti/c7k7Y+ZdItu8bLaCSawEbdsULIa8jJYr1aKCSokF2uTe1YZWHdVGr4R0icg==","shasum":"6b5a6a83505e6160f6de30099f6d65da394f8f43","tarball":"https://registry.npmjs.org/@alumnium/langchain-codex/-/langchain-codex-0.1.0.tgz","fileCount":9,"unpackedSize":51468,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCaUkFS82EG11f7/GP6qsxBlCp6M/9CvHRB3GUcyoFj8QIhAMKhbBd8N6nSDtoX4h5R0onCNmGV7qLJY81ceHmnx0DC"}]},"_npmUser":{"name":"p0deje","email":"p0deje@gmail.com"},"directories":{},"maintainers":[{"name":"kossnocorp","email":"koss@nocorp.me"},{"name":"p0deje","email":"p0deje@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/langchain-codex_0.1.0_1777130277444_0.3838660113789907"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-25T14:17:30.589Z","modified":"2026-04-25T15:17:57.760Z","0.1.0-alpha.0":"2026-04-25T14:17:30.782Z","0.1.0":"2026-04-25T15:17:57.625Z"},"bugs":{"url":"https://github.com/p0deje/langchain-codex/issues"},"author":{"name":"Alex Rodionov"},"license":"MIT","homepage":"https://github.com/p0deje/langchain-codex#readme","keywords":["langchain","openai","codex","chatgpt","oauth"],"repository":{"type":"git","url":"git+https://github.com/p0deje/langchain-codex.git"},"description":"LangChain chat model for OpenAI via OAuth (ChatGPT Plus/Pro)","maintainers":[{"name":"kossnocorp","email":"koss@nocorp.me"},{"name":"p0deje","email":"p0deje@gmail.com"}],"readme":"# langchain-codex\n\nLangChain chat model that uses OpenAI models via your ChatGPT Plus/Pro subscription (OAuth) instead of an API key.\n\nBuilt on top of [`openai-oauth`](https://github.com/nicepkg/openai-oauth) and [`@langchain/openai`](https://github.com/langchain-ai/langchainjs).\n\n## Installation\n\n```bash\nnpm install langchain-codex @langchain/openai\n```\n\nYou must be logged in to the [Codex CLI](https://github.com/nicepkg/openai-oauth#authentication) — the library reads your OAuth tokens from `~/.codex/auth.json`.\n\n## Usage\n\n### Basic\n\n```typescript\nimport { ChatCodex } from \"langchain-codex\";\n\nconst llm = new ChatCodex(); // defaults to gpt-5.4\nconst response = await llm.invoke(\"Hello!\");\nconsole.log(response.content);\n\nawait llm.close(); // shut down the local proxy server\n```\n\n### With a Specific Model\n\n```typescript\nconst llm = new ChatCodex(\"gpt-5.4-mini\");\n// or\nconst llm = new ChatCodex({ model: \"gpt-5.4-mini\" });\n```\n\n### Structured Output\n\n```typescript\nimport { z } from \"zod\";\n\nconst llm = new ChatCodex(\"gpt-5.4-mini\");\nconst structured = llm.withStructuredOutput(\n  z.object({\n    steps: z.array(z.string()),\n    answer: z.string(),\n  })\n);\n\nconst result = await structured.invoke(\"How to make coffee?\");\nconsole.log(result.steps);\nawait llm.close();\n```\n\n## How It Works\n\n`ChatCodex` extends `ChatOpenAI` and transparently starts a local OAuth proxy server (via `openai-oauth`) on first use. The proxy handles token management and exposes a standard OpenAI-compatible API on localhost. All LangChain features — tool calling, streaming, structured output — work out of the box.\n\nThe proxy server starts lazily on the first request and binds to a random available port. Call `close()` when done to shut it down.\n\n## Supported Models\n\nAny model available through your ChatGPT subscription. At the moment of writing, the list included:\n\n- `gpt-5.4`, `gpt-5.4-mini`\n- `gpt-5.3-codex`\n- `gpt-5.2`, `gpt-5.2-codex`\n- `gpt-5.1-codex-max`, `gpt-5.1-codex-mini`\n\n### Image Input\n\nCodex models require images to be provided as `https://` URLs — base64-encoded images are not supported. By default, passing a base64 image will throw an error.\n\nTo handle this automatically, enable the **litterbox upload** feature. When enabled, base64 images are uploaded to [litterbox.catbox.moe](https://litterbox.catbox.moe) (a temporary file host) and replaced with the returned URL before being sent to the model. An in-memory cache ensures the same image is not uploaded twice during the lifetime of the instance.\n\n```typescript\n// Enable via constructor option\nconst llm = new ChatCodex({ litterboxUpload: true });\n\n// Or via environment variable\nprocess.env.LANGCHAIN_CODEX_LITTERBOX_UPLOAD = \"true\"\nconst llm = new ChatCodex();\n```\n\nBoth `image_url` blocks with `data:` URIs and LangChain `image` blocks with inline base64 are handled. Images with `https://` URLs are passed through unchanged.\n\nYou can control how long uploaded images are kept with the `litterboxTtl` option (defaults to `\"1h\"`):\n\n```typescript\nconst llm = new ChatCodex({ litterboxUpload: true, litterboxTtl: \"24h\" });\n// Supported values: \"1h\", \"12h\", \"24h\", \"72h\"\n```\n\n## API\n\n### `new ChatCodex(fields?)`\n\nAccepts all [`ChatOpenAI`](https://js.langchain.com/docs/integrations/chat/openai/) options except `apiKey` and `configuration` (managed internally), plus:\n\n- **`oauthServerOptions`** — Options passed to the `openai-oauth` server (e.g., `{ authFilePath: \"/custom/path/auth.json\" }`).\n- **`litterboxUpload`** — Enable automatic upload of base64 images to litterbox.catbox.moe. Also settable via `LANGCHAIN_CODEX_LITTERBOX_UPLOAD=true`. Defaults to `false`.\n- **`litterboxTtl`** — TTL for uploaded images: `\"1h\"` (default), `\"12h\"`, `\"24h\"`, or `\"72h\"`.\n\n### `close(): Promise<void>`\n\nShuts down the local OAuth proxy server. Call this when you're done using the instance.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}