Skip to content
Back to skills

Creating Workers

ASecurity

``` </Tab> <Tab title="Rust"> ```rust let channel = worker.create_channel(None).await?; // channel.writer // channel.reader // channel.writer_ref // channel.reader_ref ``` </Tab> </Tabs> Write the payload to the local `writer` and close it when finished. The bytes flow through the engine to whichever worker holds the matching `reader`. <Tabs> <Tab title="Node / TypeScript"> ```typescript const channel = await worker.createChannel(); channel.writer.stream.end(Buffer.from("file contents")); ```...

  • 18,978 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 9, 2026
developmenttypescriptpythonrustgonodeapi

Works with

  • cli
  • api

Security analysis

A100/100

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

Scanned November 9, 2026

npx -y skills add iii-hq/iii --skill creating-workers --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Creating Workers?

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

Security grade badge for Creating Workers
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/iii-hq-creating-workers-3b5a143d/badge)](https://www.skillsdirectory.com/skills/iii-hq-creating-workers-3b5a143d)

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
<!-- generated by iii-skill-render. DO NOT EDIT (changes here are overwritten on the next render). Edit docs/next/creating-workers/channels.mdx. -->


Channels move large or binary payloads between iii workers without putting the data in a JSON
function payload. Use one for files, images, datasets, payloads above the JSON message limit, audio
or video streams, or incremental progress updates during long-running work. For small JSON, use a
regular `worker.trigger(...)` call.

<Note>
  For the underlying model (how channels are addressed, multiplexed, and torn down), see [Channels
  architecture](../understanding-iii/channels).
</Note>

## Payload size

As of SDK version **0.24.5**, the Rust, Node, Python, and Go SDKs reject outbound JSON envelopes larger
than **16 MiB** locally with `payload_too_large`. The size is measured in bytes across the complete
serialized UTF-8 JSON envelope, not just the function payload value. The browser SDK in version
0.24.5 does not check outbound message size before sending. For browser payloads larger than
16 MiB, use a channel.

Messages at or below 16 MiB are sent as a single WebSocket text frame. Channels stream payload
bytes separately from the JSON function envelope, making them suitable for larger data and
continuous transfers.

## Using channels

A channel is created by one worker and has two local stream ends: `writer` and `reader`; plus two
serializable refs (`writerRef` / `readerRef`) that can be handed to another function. The
subsections below cover the local-end API: creating a channel, writing bytes into its `writer`, and
reading bytes from its `reader`.

### Create a channel

`worker.createChannel()` returns a channel with two local stream objects and two serializable refs:
`writer` and `reader` are the local stream ends, and `writerRef` / `readerRef` are the tokens you
pass to another function so it can read or write the other end.

<Tabs>
  <Tab title="Node / TypeScript">
    ```typescript
    const channel = await worker.createChannel();

    // channel.writer
    // channel.reader
    // channel.writerRef
    // channel.readerRef
    ```

  </Tab>
  <Tab title="Python">
    ```python
    channel = iii_client.create_channel()

    # channel.writer
    # channel.reader
    # channel.writer_ref
    # channel.reader_ref
    ```

  </Tab>
  <Tab title="Rust">
    ```rust
    let channel = worker.create_channel(None).await?;

    // channel.writer
    // channel.reader
    // channel.writer_ref
    // channel.reader_ref
    ```

  </Tab>
</Tabs>

### Write to a channel

Write the payload to the local `writer` and close it when finished. The bytes flow through the
engine to whichever worker holds the matching `reader`.

<Tabs>
  <Tab title="Node / TypeScript">
    ```typescript
    const channel = await worker.createChannel();

    channel.writer.stream.end(Buffer.from("file contents"));
    ```

  </Tab>
  <Tab title="Python">
    ```python
    channel = await iii_client.create_channel_async()

    await channel.writer.write(b"file contents")
    await channel.writer.close_async()
    ```

  </Tab>
  <Tab title="Rust">
    ```rust
    let channel = worker.create_channel(None).await?;

    channel.writer.write(b"file contents").await?;
    channel.writer.close().await?;
    ```

  </Tab>
</Tabs>

### Read from a channel

Read the local `reader` until the other end closes. The bytes arrive in the order they were written
by whichever worker holds the matching `writer`.

<Tabs>
  <Tab title="Node / TypeScript">
    ```typescript
    const channel = await worker.createChannel();

    let bytes = 0;
    for await (const chunk of channel.reader.stream) {
      bytes += Buffer.isBuffer(chunk) ? chunk.length : Buffer.byteLength(chunk);
    }
    ```

  </Tab>
  <Tab title="Python">
    ```python
    channel = await iii_client.create_channel_async()

    bytes_total = 0
    async for chunk in channel.reader:
        bytes_total += len(chunk)
    ```

  </Tab>
  <Tab title="Rust">
    ```rust
    let channel = worker.create_channel(None).await?;

    let mut bytes = 0;
    while let Some(chunk) = channel.reader.next_binary().await? {
        bytes += chunk.len();
    }
    ```

  </Tab>
</Tabs>

## Using channels across functions

A channel only becomes useful once both ends are owned by different code paths. Typically one
function that holds the local `writer` / `reader` and another that receives the matching ref in its
payload. The two subsections below cover that handoff: first how to send a ref alongside a normal
trigger call, then how the receiving function turns it back into a live stream to read or write.

### Pass a channel ref to another function

Pass the `readerRef` (or `writerRef`) as part of a normal function invocation. The receiving
function uses the ref to read from (or write to) the channel.

<Tabs>
  <Tab title="Node / TypeScript">
    ```typescript
    const result = await worker.trigger({
      function_id: "files::process",
      payload: {
        filename: "report.csv",
        reader: channel.readerRef,
      },
    });
    ```
  </Tab>
  <Tab title="Python">
    ```python
    result = await iii_client.trigger_async({
        "function_id": "files::process",
        "payload": {
            "filename": "report.csv",
            "reader": channel.reader_ref.model_dump(),
        },
    })
    ```
  </Tab>
  <Tab title="Rust">
    ```rust
    use iii_sdk::TriggerRequest;
    use serde_json::json;

    let result = worker
        .trigger(TriggerRequest {
            function_id: "files::process".to_string(),
            payload: json!({
                "filename": "report.csv",
                "reader": channel.reader_ref,
            }),
            action: None,
            timeout_ms: None,
        })
        .await?;
    ```

  </Tab>
</Tabs>

Node and Python deserialize incoming channel refs into live `ChannelReader` / `ChannelWriter`
objects before the handler runs, so the ref arrives ready to iterate or write to. Rust receives the
ref in JSON and reconstructs the reader or writer explicitly with `ChannelReader::new(...)` or
`ChannelWriter::new(...)`.

<Tip>
  The channel belongs to the worker that created it. Keep that worker connected until the receiving
  function has attached to the ref. If the creator disconnects first, unattached ends are dropped.
  See [Channel ownership](../understanding-iii/channels#channel-ownership).
</Tip>

### Read from a channel ref

<Tabs>
  <Tab title="Node / TypeScript">
    ```typescript
    import type { ChannelReader } from "iii-sdk";

    worker.registerFunction("files::process", async (input: { reader: ChannelReader }) => {
      let bytes = 0;
      for await (const chunk of input.reader.stream) {
        bytes += Buffer.isBuffer(chunk) ? chunk.length : Buffer.byteLength(chunk);
      }
      return { bytes };
    });
    ```

  </Tab>
  <Tab title="Python">
    ```python
    async def process_file(input: dict) -> dict:
        reader = input["reader"]
        total = 0
        async for chunk in reader:
            total += len(chunk)
        return {"bytes": total}

    worker.register_function("files::process", process_file)
    ```

  </Tab>
  <Tab title="Rust">
    ```rust
    use iii_sdk::{ChannelDirection, ChannelReader, IIIError};
    use serde_json::json;

    let refs = iii_sdk::extract_channel_refs(&input);
    let (_, reader_ref) = refs
        .iter()
        .find(|(k, r)| k == "reader" && matches!(r.direction, ChannelDirection::Read))
        .ok_or_else(|| IIIError::Handler("missing reader channel ref".into()))?;

    let reader = ChannelReader::new(worker.address(), reader_ref);
    let mut bytes = 0;
    while let Some(chunk) = reader.next_binary().await? {
        bytes += chunk.len();
    }
    Ok(json!({ "bytes": bytes }))
    ```

  </Tab>
</Tabs>

### Write to a channel ref

<Tabs>
  <Tab title="Node / TypeScript">
    ```typescript
    import type { ChannelWriter } from "iii-sdk";

    worker.registerFunction("files::generate", async (input: { writer: ChannelWriter }) => {
      input.writer.stream.write(Buffer.from("hello "));
      input.writer.stream.end(Buffer.from("world"));
      return { ok: true };
    });
    ```

  </Tab>
  <Tab title="Python">
    ```python
    async def generate_file(input: dict) -> dict:
        writer = input["writer"]
        await writer.write(b"hello ")
        await writer.write(b"world")
        await writer.close_async()
        return {"ok": True}

    worker.register_function("files::generate", generate_file)
    ```

  </Tab>
  <Tab title="Rust">
    ```rust
    use iii_sdk::{ChannelDirection, ChannelWriter, IIIError};
    use serde_json::json;

    let refs = iii_sdk::extract_channel_refs(&input);
    let (_, writer_ref) = refs
        .iter()
        .find(|(k, r)| k == "writer" && matches!(r.direction, ChannelDirection::Write))
        .ok_or_else(|| IIIError::Handler("missing writer channel ref".into()))?;

    let writer = ChannelWriter::new(worker.address(), writer_ref);
    writer.write(b"hello ").await?;
    writer.write(b"world").await?;
    writer.close().await?;
    Ok(json!({ "ok": true }))
    ```

  </Tab>
</Tabs>

<Note>
  For the per-language channel API surface, see the SDK reference:
  [Node](../reference/sdk-node), [Python](../reference/sdk-python), and
  [Rust](../reference/sdk-rust).
</Note>

Files in this skill

  • channels.mdx9.1 KB
  • channels.mdx.skill.md9.1 KB
  • functions.mdx15.6 KB
  • functions.mdx.skill.md15.6 KB
  • http.mdx4.8 KB
  • http.mdx.skill.md4.8 KB
  • index.mdx2.6 KB
  • index.mdx.skill.md2.6 KB
  • observability.mdx5.4 KB
  • observability.mdx.skill.md5.4 KB
  • queues.mdx13.2 KB
  • queues.mdx.skill.md13.2 KB
  • sandboxes.mdx5 KB
  • sandboxes.mdx.skill.md5 KB
  • triggers.mdx18.2 KB
  • triggers.mdx.skill.md18.2 KB
  • worker-manager.mdx14.2 KB
  • worker-manager.mdx.skill.md14.2 KB
  • worker-manifest.mdx7.6 KB
  • worker-manifest.mdx.skill.md7.6 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.

View all in development →

Comments

Loading comments…

Newsletter

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