{"id":13615844,"url":"https://github.com/swordintent/chatgpt-web-api","last_synced_at":"2025-04-13T21:31:43.227Z","repository":{"id":158652469,"uuid":"576875796","full_name":"swordintent/chatgpt-web-api","owner":"swordintent","description":"A Java Version ChatGPT SDK","archived":false,"fork":false,"pushed_at":"2023-04-29T08:35:51.000Z","size":33,"stargazers_count":39,"open_issues_count":12,"forks_count":12,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-07T23:40:03.042Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/swordintent.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}},"created_at":"2022-12-11T09:21:12.000Z","updated_at":"2024-04-15T00:48:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"b2e6ae21-01ac-4813-a190-7ce295cd75e0","html_url":"https://github.com/swordintent/chatgpt-web-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swordintent%2Fchatgpt-web-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swordintent%2Fchatgpt-web-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swordintent%2Fchatgpt-web-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swordintent%2Fchatgpt-web-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swordintent","download_url":"https://codeload.github.com/swordintent/chatgpt-web-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248786375,"owners_count":21161439,"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":[],"created_at":"2024-08-01T20:01:18.956Z","updated_at":"2025-04-13T21:31:38.197Z","avatar_url":"https://github.com/swordintent.png","language":"Java","funding_links":[],"categories":["Developer Libraries, SDKs, and APIs","API tools","Addons, extensions, plug-ins for integrating LLM into third-party applications","人工智能"],"sub_categories":["Java","JavaScript","Other user interfaces","LLM客户端"],"readme":"# chatgpt-web-api\n**A Java Version ChatGPT SDK** \n\nintegrate with [acheong08/ChatGPT](https://github.com/acheong08/ChatGPT), use official Api of openAI(2023.3.2).\n\n# update\n\n`2023.3.2 use official api, model is not free, but you have $18 free quota`\n\n```\npip3 install --upgrade revChatGPT\n```\n\n# How TO\n\n[中文](https://github.com/swordintent/chatgpt-web-api/wiki/%E7%AE%80%E4%BB%8B)\n\n### Start a python server(python \u003e= 3.7)\n\nyou will find it in `src/main/resources/server.py`, and run:\n\n```\n    pip3 install flask flask-restful\n    pip3 install --upgrade revChatGPT\n    python3 server.py\n```\n\nby default, it listen on http://127.0.0.1:5000 \n\n\n### Import maven jar\n\nhttps://search.maven.org/artifact/com.swordintent.chatgpt/web-api/\n\nMaven\n```\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.swordintent.chatgpt\u003c/groupId\u003e\n      \u003cartifactId\u003eweb-api\u003c/artifactId\u003e\n      \u003cversion\u003e1.0.0\u003c/version\u003e\n    \u003c/dependency\u003e\n```\n\nGradle\n\n```\n    implementation 'com.swordintent.chatgpt:web-api:1.0.0'\n```\n\n\n### Enjoy it in your project\n\n\n1. first, you can invoke `chatgptClient.init(address, chatGptConfig)` method to init client.\n\n* you need [create](https://platform.openai.com/) your account firstly.\n* modify `password`, the `password` is your openAI's api-keys, you can find [here](https://platform.openai.com/account/api-keys).\n* set `address` to http://127.0.0.1:5000 or another.\n\n\n```\n    ChatgptClient chatgptClient = ChatgptClientImpl.getInstance();\n    ChatGptConfig chatGptConfig = ChatGptConfig.builder()\n                                    .password(\"\")\n                                    .build();\n    String address = \"http://127.0.0.1:5000\";\n    chatgptClient.init(address, chatGptConfig);\n```\n\n2. then you can invoke chat `chatgptClient.chat(request)` method to chat. \n\n* in first round chat, `conversationId` would be null. \nwhen you want reset multiple rounds set them to null too.\n\n\n```\n    //first round or reset multiple rounds\n    ChatRequest request = ChatRequest.builder()\n                                    .prompt(content)\n                                    .conversationId(null)\n                                    .build();\n    \n    ChatResponse response = chatgptClient.chat(request);\n\n```\n\n\n* if you want to chat multiple rounds. you need get `conversationId` from response and set them to next chat request. \n\n\n```\n    //multiple rounds  \n    ChatRequest request = ChatRequest.builder()\n                                    .prompt(content)\n                                    .conversationId(response.getConversationId())\n                                    .build();\n    ChatResponse response = chatgptClient.chat(request);\n```\n\n\n3. **Notice**.\n\n* the `conversationId` now is the full object of python chatbot object, so maybe it was huge. \n\n* you must set `conversationId` to null in your java program when you restart your python server.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswordintent%2Fchatgpt-web-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswordintent%2Fchatgpt-web-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswordintent%2Fchatgpt-web-api/lists"}