httpx-sse

Consume Server-Sent Event (SSE) streams with HTTPX

Library
PyPI
v0.4.3
213 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
35 /100 Needs Attention
Development Activity 0
Maintenance 20
Community 48
Maturity 52
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
74 /100 Good
Architecture 72
Code Quality 78
Innovation 60
Learning Curve 85

httpx-sse adds Server-Sent Events (SSE) support on top of the HTTPX client, since HTTPX itself has no built-in SSE parsing. It provides connect_sse/aconnect_sse context managers that open a streaming request against an SSE endpoint and return an EventSource object, whose .iter_sse()/.aiter_sse() methods yield parsed events (with event, data, id, and retry fields) as they arrive over the wire.

Both synchronous and async usage are first-class, matching HTTPX’s own sync/async client split, so the same parsing logic works whether you’re using httpx.Client or httpx.AsyncClient. It is explicitly positioned as beta software (pin your version), and is commonly used as a building block by higher-level libraries that need to consume SSE-based streaming APIs — including LLM streaming responses that use the SSE wire format.

What You Get

  • connect_sse/aconnect_sse context managers for opening a streaming SSE connection with httpx.Client/httpx.AsyncClient
  • An EventSource object exposing .iter_sse()/.aiter_sse() to iterate over parsed events synchronously or asynchronously
  • ServerSentEvent model objects carrying event, data, id, and retry fields per the SSE spec
  • Low-level SSE decoders that handle multi-line data fields and comment lines per the WHATWG SSE specification
  • Explicit exception types for malformed SSE responses or non-SSE content types

Common Use Cases

  • Consuming streaming LLM API responses (OpenAI-style chat completions, etc.) that use SSE as their wire format
  • Building a Python client for any backend that pushes live updates via Server-Sent Events (progress bars, notifications, live feeds)
  • Testing an SSE-emitting backend (e.g. built with Starlette/FastAPI + sse-starlette) end-to-end from Python
  • Adding SSE support to an existing codebase already standardized on HTTPX as its HTTP client

Under The Hood

Architecture - Four small modules make up the whole package: _api.py defines connect_sse/aconnect_sse context managers that open an HTTPX streaming request and wrap the response in an EventSource; _models.py defines the EventSource/ServerSentEvent data classes and the .iter_sse()/.aiter_sse() iteration methods; _decoders.py implements the line-by-line SSE decoding state machine (buffering data:/event:/id:/retry: fields across multi-line events); _exceptions.py defines typed errors for non-SSE responses. Tech Stack - Pure Python with httpx as its only runtime dependency, setuptools-scm for version derivation from git tags, requires Python 3.9+, and CI runs on Azure Pipelines. Code Quality - tests/ has one file per module (test_decoders.py, test_models.py, test_api.py, test_event_source.py, test_exceptions.py) plus an ASGI integration test, giving focused unit coverage; however development activity has slowed considerably (recent-activity health sub-score of 1/25), consistent with a small, feature-complete beta library. API Design - The connect_sse(client, method, url) signature mirrors httpx.Client.stream() closely, and the sync/async method-naming convention (iter_sse/aiter_sse) matches HTTPX’s own iter_bytes/aiter_bytes pattern, so existing HTTPX users can adopt it with almost no new concepts.

Used by 5 apps in this directory

Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 5 days ago
TypeScript
50%
Other

Dify

AI Development · Design Tools · Developer Tools

157,364

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
66
Dependency
Built with
TypeScript 50%
Python 47%
Updated 5 days ago
Python
70%
Apache 2.0

GPT Researcher

AI Assistants · Productivity

29,650

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
91
Repo Health
91
Technical
63
Dependency
Built with
Python 70%
TypeScript 18%
Updated 1 weeks ago
Python
67%
Apache 2.0

SurfSense

AI Assistants · Search

16,270

The open-source, unlimited NotebookLM alternative with real-time collaboration, a desktop app, and no vendor lock-in.

View details
87
Repo Health
71
Technical
66
Dependency
Built with
Python 67%
TypeScript 30%
Updated 1 weeks ago
Rust
79%
Apache 2.0

TensorZero

Ab Testing Experimentation · AI Development · Monitoring

11,717

TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.

View details
53
Repo Health
87
Technical
69
Dependency
Built with
Rust 79%
TypeScript 15%
Updated 3 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers