Skip to content

crosswind-workers: a typed Python Workers SDK

crosswind-workers is a typed Python SDK for Cloudflare Workers. Use it to build a Python Worker with Wynd. It imports as workers and replaces Cloudflare's workers-runtime-sdk. The public names and call signatures stay the same; Crosswind adds types and Python methods. pywrangler always installs workers-runtime-sdk, so pywrangler projects use that SDK.

from env import Env
from workers import Request, Response, WorkerEntrypoint


class Default(WorkerEntrypoint[Env]):
    async def fetch(self, request: Request) -> Response:
        await self.env.CACHE.put("last-path", request.url, expiration_ttl=3600)
        return Response.json({"cached": await self.env.CACHE.get("last-path")})

Env is a class that Wynd generates from your Wrangler config. With it, your editor knows that self.env.CACHE is a KVNamespace and that get returns str | None.

How it relates to the stock SDK

Python Workers import a package called workers at startup. Cloudflare's workers-runtime-sdk provides it, and so does crosswind-workers. A project ships exactly one of them.

Code written for the stock SDK runs on crosswind-workers without changes:

  • Every name in the stock SDK's workers module exists, with the same signature.
  • camelCase JavaScript calls such as self.ctx.storage.deleteAll() still work. crosswind forwards any name its classes don't define to the JavaScript object.
  • asgi and wsgi adapters serve FastAPI, Flask and other frameworks the same way.

crosswind-workers adds:

  • WorkerEntrypoint[Env], DurableObject[Env] and WorkflowEntrypoint[Env], so self.env has a type.
  • Binding classes for KV, D1, R2, Queues, Durable Objects, service bindings, Workflows, Vectorize, Analytics Engine, Images and rate limiting, with snake_case methods that take and return Python values.
  • js_object on every wrapper, which returns the JavaScript object underneath. See Call JavaScript APIs.
  • Workflows written in Python only, with no JavaScript helper file in the package.
  • Fixes for 14 stock SDK bugs. Migrate from workers-runtime-sdk lists them.

Install

Add the package to a Python Worker project that you build with Wynd:

uv add crosswind-workers

If the project lists workers-runtime-sdk, remove it first with uv remove workers-runtime-sdk. To create a project first, follow Getting started. To move an existing project, follow Migrate from workers-runtime-sdk.

Requirements

  • Python 3.12, 3.13 or 3.14 as the Worker's runtime. The target comes from your compatibility date and flags.
  • Wynd to build and deploy the Worker. pywrangler always installs workers-runtime-sdk next to whatever SDK you declare. Both packages write to python_modules/workers/, so crosswind-workers refuses to import when it finds the stock SDK installed.

The package has no runtime dependencies.

Status

crosswind-workers is pre-1.0, and its API may change between minor releases. It is an independent community project, not an official Cloudflare SDK. These parts of the runtime have no typed API yet:

  • Module-level on_fetch handlers. The handler decorator works as in the stock SDK.
  • Streaming request and response bodies beyond the body stream property.
  • A typed WebSocket API for Durable Objects. Handlers receive a Binding around the JavaScript WebSocket.

Next steps