{"id":23506986,"url":"https://github.com/abacaj/unofficial-chatgpt-api","last_synced_at":"2025-06-28T21:37:50.806Z","repository":{"id":64224501,"uuid":"574218719","full_name":"abacaj/unofficial-chatgpt-api","owner":"abacaj","description":"Node.js client for the chatgpt API. No third party dependencies.","archived":false,"fork":false,"pushed_at":"2024-08-29T01:21:44.000Z","size":46,"stargazers_count":73,"open_issues_count":3,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-14T13:56:50.614Z","etag":null,"topics":["ai","chatbot","chatgpt","openai"],"latest_commit_sha":null,"homepage":"","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/abacaj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2022-12-04T19:35:35.000Z","updated_at":"2025-06-03T07:45:35.000Z","dependencies_parsed_at":"2025-06-20T15:02:38.541Z","dependency_job_id":null,"html_url":"https://github.com/abacaj/unofficial-chatgpt-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abacaj/unofficial-chatgpt-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abacaj%2Funofficial-chatgpt-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abacaj%2Funofficial-chatgpt-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abacaj%2Funofficial-chatgpt-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abacaj%2Funofficial-chatgpt-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abacaj","download_url":"https://codeload.github.com/abacaj/unofficial-chatgpt-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abacaj%2Funofficial-chatgpt-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260966752,"owners_count":23090084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["ai","chatbot","chatgpt","openai"],"created_at":"2024-12-25T10:13:49.719Z","updated_at":"2025-06-20T15:06:47.487Z","avatar_url":"https://github.com/abacaj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# unofficial-chatgpt-api\n\n[![version](https://img.shields.io/npm/v/unofficial-chatgpt-api)](https://www.npmjs.com/package/unofficial-chatgpt-api)\n[![downloads](https://img.shields.io/npm/dw/unofficial-chatgpt-api)](https://www.npmjs.com/package/unofficial-chatgpt-api)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/abacaj/unofficial-chatgpt-api/blob/main/LICENSE)\n\n## Getting Started\n\n## NOTICE\nThis library may or may not still work, ChatGPT has antibot measures in place and managing the session requires browsers.\n\n### Installation\n\nTo use ChatGPT in your application, run:\n\n```bash\nnpm i unofficial-chatgpt-api\n# or `yarn add unofficial-chatgpt-api`\n# or `pnpm i unofficial-chatgpt-api`\n```\n\n### Configuration\n\n```js\n// dual token\nconst { ChatGPTClient } = require('unofficial-chatgpt-api');\nconst gpt = new ChatGPTClient({\n  clearanceToken: '\u003c--BOT_CLEARANCE_TOKEN--\u003e',\n  sessionToken0: '\u003c--SESSION_TOKEN_0--\u003e',\n  sessionToken1: '\u003c--SESSION_TOKEN_1--\u003e',\n});\n```\n\n```js\n// single token\nconst { ChatGPTClient } = require('unofficial-chatgpt-api');\nconst gpt = new ChatGPTClient({\n  clearanceToken: '\u003c--BOT_CLEARANCE_TOKEN--\u003e',\n  sessionToken0: '\u003c--SESSION_TOKEN--\u003e',\n});\n```\n\n### Auto-refresh\n\nLibrary manages auto-refreshing tokens.\n\n**Dual tokens**\n\nSome accounts require dual tokens:\n\n1. Visit: https://chat.openai.com/chat\n2. Open devtools in chrome: visit the application tab\n3. Click on cookies in the left under storage, click on the chat.openai.com domain\n4. Copy the value of the first cookie and paste it in the client (Name: `__Secure-next-auth.session-token.0`)\n5. Copy the value of the second cookie and paste it in the client (Name: `__Secure-next-auth.session-token.1`)\n\n**Single token**\n\nSome accounts require single token:\n\n1. Visit: https://chat.openai.com/chat\n2. Open devtools in chrome: visit the application tab\n3. Click on cookies in the left under storage, click on the chat.openai.com domain\n4. Copy the value of the first cookie and paste it in the client (Name: `__Secure-next-auth.session-token`)\n\n### Chatting\n\n```js\nconst convo = await gpt.startConversation();\nconst m1 = await convo.chat('show me some javascript code:');\n\nconst m2 = await convo.chat('who created you?');\nconsole.log(m2.message.content.parts);\n```\n\n### Multiple conversations\n\n```js\nconst convo1 = await gpt.startConversation();\nconst convo2 = await gpt.startConversation();\n\nconst m1 = await convo1.chat('show me some javascript code:');\nconst m2 = await convo2.chat('who created you?');\nconsole.log(m2.message.content.parts);\n```\n\n### Reset conversation (thread)\n\n```js\nconvo.reset();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabacaj%2Funofficial-chatgpt-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabacaj%2Funofficial-chatgpt-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabacaj%2Funofficial-chatgpt-api/lists"}