{"id":14006915,"url":"https://github.com/yusukebe/chatgpt-streaming","last_synced_at":"2025-07-11T20:32:56.685Z","repository":{"id":194950179,"uuid":"691920714","full_name":"yusukebe/chatgpt-streaming","owner":"yusukebe","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-30T09:18:01.000Z","size":49,"stargazers_count":45,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T10:57:09.961Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://chatgpt-streaming.pages.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yusukebe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-09-15T07:08:51.000Z","updated_at":"2024-08-16T05:51:49.000Z","dependencies_parsed_at":"2024-04-13T18:04:41.470Z","dependency_job_id":null,"html_url":"https://github.com/yusukebe/chatgpt-streaming","commit_stats":null,"previous_names":["yusukebe/chatgpt-streaming"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yusukebe/chatgpt-streaming","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fchatgpt-streaming","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fchatgpt-streaming/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fchatgpt-streaming/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fchatgpt-streaming/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusukebe","download_url":"https://codeload.github.com/yusukebe/chatgpt-streaming/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2Fchatgpt-streaming/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264892917,"owners_count":23679383,"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-10T10:01:42.719Z","updated_at":"2025-07-11T20:32:56.636Z","avatar_url":"https://github.com/yusukebe.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# ChatGPT Streaming Example\n\nAn example using the ChatGPT API and responding with a streaming response.\n\n## Stack\n\n* ChatGPT API\n* [Sonik](https://github.com/yusukebe/sonik) - The [Hono](https://hono.dev/) based meta-framework.\n* [`c.stream()`](https://github.com/honojs/hono/pull/1437) - A new feature of the Hono.\n* React\n* Cloudflare Pages\n\n## From the source code\n\nHere is the key code:\n\n```ts\nexport const route = defineRoute\u003cEnv\u003e((app) =\u003e {\n  app.post('/api', async (c) =\u003e {\n    const body = await c.req.json\u003c{ message: string }\u003e()\n\n    const openai = new OpenAI({\n      apiKey: c.env.OPENAI_API_KEY\n    })\n\n    const chatStream = await openai.chat.completions.create({\n      messages: PROMPT(body.message),\n      model: 'gpt-3.5-turbo',\n      stream: true\n    })\n\n    return c.streamText(async (stream) =\u003e {\n      for await (const message of chatStream) {\n        await stream.write(message.choices[0]?.delta.content ?? '')\n      }\n    })\n  })\n})\n```\n\n## Demo\n\nhttps://github.com/yusukebe/chatgpt-streaming/assets/10682/ef0eedfc-813b-4eb3-941a-769319a3ed18\n\n## Authors\n\n- Yusuke Wada \u003chttps://github.com/yusukebe\u003e\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusukebe%2Fchatgpt-streaming","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusukebe%2Fchatgpt-streaming","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusukebe%2Fchatgpt-streaming/lists"}