Skip to content
Back to skills

Openrouter Streaming Setup

ASecurity

Implement streaming responses with OpenRouter. Use when building real-time chat interfaces or reducing time-to-first-token. Trigger with phrases like 'openrouter streaming', 'openrouter sse', 'stream response', 'real-time openrouter'.

  • 4 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 10, 2026
documentationapifrontenddocumentation

Works with

  • api

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned September 10, 2026

npx -y skills add micsapp/micstec-skills --skill openrouter-streaming-setup --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Openrouter Streaming Setup?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Openrouter Streaming Setup
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/micsapp-openrouter-streaming-setup/badge)](https://www.skillsdirectory.com/skills/micsapp-openrouter-streaming-setup)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: openrouter-streaming-setup
description: |
  Implement streaming responses with OpenRouter. Use when building real-time chat interfaces or reducing time-to-first-token. Trigger with phrases like 'openrouter streaming', 'openrouter sse', 'stream response', 'real-time openrouter'.
allowed-tools: Read, Write, Edit, Grep
version: 1.0.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
compatible-with: claude-code, codex, openclaw
---
# Openrouter Streaming Setup

## Overview

This skill demonstrates streaming response implementation for lower perceived latency and real-time output display.

## Prerequisites

- OpenRouter integration
- Frontend capable of handling SSE/streaming

## Instructions

1. **Enable streaming**: Set `stream: true` in your chat completion request body
2. **Handle SSE chunks**: Parse each `data: {...}` line from the response stream, extracting `choices[0].delta.content` from each chunk
3. **Detect stream end**: Watch for `data: [DONE]` to know when the stream is complete; accumulate chunks for the full response
4. **Implement frontend rendering**: Use `ReadableStream` or `EventSource` in the browser to display tokens as they arrive
5. **Add error recovery**: Handle mid-stream disconnections with automatic retry and partial response preservation

## Output

- Real-time token-by-token text output in the UI
- Reduced time-to-first-token compared to non-streaming requests
- Complete response assembled from all chunks with usage stats from the final chunk

## Error Handling

| Error | Cause | Fix |
|-------|-------|-----|
| Stream cuts off mid-response | Network timeout or model error | Implement reconnection logic; save partial output |
| Missing `usage` in stream | Some models omit usage in streaming mode | Set `stream_options: { include_usage: true }` or make a separate token count call |
| Empty delta chunks | Keep-alive pings from the server | Filter chunks where `delta.content` is null or empty |

See `${CLAUDE_SKILL_DIR}/references/errors.md` for full error reference.

## Examples

See `${CLAUDE_SKILL_DIR}/references/examples.md` for runnable code samples.

## Resources

- [OpenRouter Documentation](https://openrouter.ai/docs)
- [OpenRouter Models](https://openrouter.ai/models)
- [OpenRouter API Reference](https://openrouter.ai/docs/api-reference)
- [OpenRouter Status](https://status.openrouter.ai)

Files in this skill

  • SKILL.md2.3 KB
  • references/async-streaming.md1.1 KB
  • references/basic-streaming.md1.5 KB
  • references/error-handling-in-streams.md1.9 KB
  • references/errors.md323 B
  • references/examples.md3.3 KB
  • references/frontend-integration.md2 KB
  • references/stream-processing.md1.9 KB
  • references/web-framework-integration.md2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.