{"id":19000226,"url":"https://github.com/wzpan/chatgpt-python-example","last_synced_at":"2026-03-16T20:02:02.892Z","repository":{"id":142780380,"uuid":"608465119","full_name":"wzpan/ChatGPT-python-example","owner":"wzpan","description":"演示如何使用4行代码调用ChatGPT的官方API","archived":false,"fork":false,"pushed_at":"2023-11-08T09:36:28.000Z","size":9,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T17:05:26.295Z","etag":null,"topics":["chatgpt","chatgpt-api","chatgpt-python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/wzpan.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}},"created_at":"2023-03-02T04:13:56.000Z","updated_at":"2024-07-07T15:11:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed5c003b-4b3b-475d-806f-937b2e5635dc","html_url":"https://github.com/wzpan/ChatGPT-python-example","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/wzpan%2FChatGPT-python-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wzpan%2FChatGPT-python-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wzpan%2FChatGPT-python-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wzpan%2FChatGPT-python-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wzpan","download_url":"https://codeload.github.com/wzpan/ChatGPT-python-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249279416,"owners_count":21242923,"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":["chatgpt","chatgpt-api","chatgpt-python"],"created_at":"2024-11-08T18:06:36.423Z","updated_at":"2026-03-16T20:02:02.831Z","avatar_url":"https://github.com/wzpan.png","language":"Python","readme":"# ChatGPT-python-example\n\n演示如何使用 4 行代码调用 ChatGPT 的官方API。要求 Python 版本 \u003e 3.6 。\n\n## 1. 安装依赖\n\n``` bash\npip3 install openai\n```\n\n## 2. 执行demo\n\n``` bash\npython3 bot.py\n```\n\n## 3. 修改对话内容\n\n修改第 4 行代码里的 `content` 参数即可。例如：\n\n``` py\ncompletion = openai.ChatCompletion.create(model=\"gpt-3.5-turbo\", \\\n                                       messages=[{\"role\": \"user\", \"content\": \"请使用 Python 实现一个二分查找算法\"}])\n```\n\n## 4. 切换模型（可选）\n\n通过修改第 4 行代码里的 `model` 参数即可指定模型。可选的模型详见 [models](https://platform.openai.com/docs/models) 。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwzpan%2Fchatgpt-python-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwzpan%2Fchatgpt-python-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwzpan%2Fchatgpt-python-example/lists"}