Back to docs
Runtime

Bun runtime

Use Meridian with Bun — the fast all-in-one JavaScript runtime.

Installation

bun add openai

Usage

The Bun SDK is identical to the Node.js SDK. Import and call Meridian the same way.

import { Meridian } from '@meridian/sdk';

const meridian = new Meridian({
  apiKey: process.env.MERIDIAN_API_KEY,
});

const result = await meridian.chat.completions.create({
  model: 'meridian-1',
  messages: [{ role: 'user', content: 'Hello from Bun!' }],
});

console.log(result.choices[0].message.content);

Streaming

Streaming works identically with Bun's native fetch and ReadableStream support.

const stream = await meridian.chat.completions.create({
  model: 'meridian-1',
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}

Edge compatibility

Bun implements standard Web APIs. The Meridian SDK works in Bun.serve handlers, Bun scripts, and Bun's test runner without any polyfills or configuration changes.

Note: Bun is fully compatible with the Node.js SDK. No separate package or configuration is required. Install the same @meridian/sdk package and use it identically.