{
 "schema_version": 1,
 "generated": "2026-10-26",
 "id": "tencentcloud-octop-gateway--stream-llm-tokens-to-chat",
 "repo": "TencentCloud/octop-gateway",
 "repo_url": "https://github.com/TencentCloud/octop-gateway",
 "repo_slug": "tencentcloud-octop-gateway",
 "title": "Stream an LLM agent's reply token by token into chat",
 "page_title": "How to stream an LLM agent's reply token by token into chat with Octop Gateway",
 "summary": "Use DELTA events and a final COMPLETED event so users see the answer as it is generated.",
 "who": "A developer whose agent produces long answers and who wants users to see text appear live in IM.",
 "problem": "Waiting for a full answer before sending makes chat feel slow, especially for long responses.",
 "outcome": "A processor that yields DELTA events as tokens arrive and a COMPLETED event at the end, with the reply appearing progressively in the IM client.",
 "steps": [
  "Run `pip install octop-gateway` in a Python 3.12+ environment.",
  "Write an async generator processor that takes InboundMessage and yields MessageEvent objects.",
  "Inside the processor, yield a DELTA event for each token from your model, then yield a COMPLETED event when the stream ends.",
  "Wrap the processor in a ChannelManager and attach one channel, such as Telegram, using its config class.",
  "Send a prompt that asks for a long answer and confirm the reply updates while it is generated."
 ],
 "agent_prompt": "Using the octop-gateway repo, write an async processor that streams tokens from <model client> as MessageEvent DELTA events and ends with COMPLETED, then attach it to a Telegram channel. Expected output: a chat reply that grows over time for a long prompt. Verify that an ERROR event is never yielded for a normal run.",
 "agents": [
  "any"
 ],
 "difficulty": "Intermediate",
 "time": "1 hour",
 "basis": "readme",
 "caveat": "The README says DELTA streams tokens, but whether each platform shows partial text live depends on that platform's behavior, so test on your target channel.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "python",
 "requirements": [
  "Python 3.12+",
  "Credentials for each platform you connect, such as a Telegram bot token, Feishu app ID and secret, or a Discord bot token",
  "Access to the developer portal of each platform you use",
  "A processor function that reads InboundMessage and yields MessageEvent objects"
 ],
 "risk": "sensitive",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/tencentcloud-octop-gateway/stream-llm-tokens-to-chat/",
 "md": "https://dedupedai.com/use-cases/tencentcloud-octop-gateway/stream-llm-tokens-to-chat/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/tencentcloud-octop-gateway--stream-llm-tokens-to-chat.json",
 "api_version": "v1"
}
