C.W.K.
Stream
Lesson 06 of 06 · published

Deno, Bun, and Cross-Runtime Reality

~12 min · deno, bun, edge, cross-runtime

Level 0Observer
0 XP0/64 lessons0/13 achievements
0/150 XP to next level150 XP to go0% complete

Bun is mostly drop-in

Bun runs the SDK with no special configuration. bun add @anthropic-ai/sdk, bun run app.ts, done. Bun's TypeScript-native pipeline often makes development noticeably faster than Node + tsx.

Deno needs an import map

Deno can run the SDK via npm: specifiers (import Anthropic from "npm:@anthropic-ai/sdk";). Set permissions explicitly: --allow-net=api.anthropic.com and --allow-env are usually enough.

Cloudflare Workers and Vercel Edge share constraints

Workers and Vercel Edge both run on V8 isolates with a web-standard API surface. Streaming and tool use work; file streams and Node-only Files API helpers do not. Test your specific code path on the runtime you ship to — 'works in Node' does not transfer for free.

Principle: Pick the runtime by your latency and feature needs. The SDK works on all of them; only some helpers do.

Code

Bun script (zero config)·typescript
// app.ts
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic();
const r = await client.messages.create({
  model: 'claude-haiku-4-5-20251001',
  max_tokens: 64,
  messages: [{ role: 'user', content: 'bun says hi' }],
});
console.log(r.content);

// Run: bun run app.ts
Deno with explicit permissions·typescript
// deno-app.ts
import Anthropic from 'npm:@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: Deno.env.get('ANTHROPIC_API_KEY'),
});
const r = await client.messages.create({
  model: 'claude-haiku-4-5-20251001',
  max_tokens: 64,
  messages: [{ role: 'user', content: 'deno says hi' }],
});
console.log(r.content);

// Run: deno run --allow-net=api.anthropic.com --allow-env deno-app.ts

External links

Exercise

Run the same minimal Messages script under Node, Bun, and Deno. Note which permission flags or config files were required for each. Pick which runtime you would use for production and write one sentence justifying it.
Hint
If 'because it is what I know' is your justification, that is also a valid answer — write it.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.