Recipe

Elysia Primer

Elysia is an ergonomic Bun-native web framework that pairs naturally with Meridian's unified inference gateway. This primer walks you through wiring a typed Elysia route that streams completions from llm.getnimbus.net, validates payloads with the built-in schema layer, and ships to production in under five minutes.

1Install and bootstrap

Elysia ships as a single dependency. Bun handles TypeScript natively, so no transpile step is required. Create a fresh project and add the Meridian SDK alongside it.

bun create elysia meridian-app
cd meridian-app
bun add @meridian/sdk
bun run dev

2Wire a streaming completion route

Elysia's t schema validates the incoming body. The handler forwards the prompt to the Meridian gateway and streams tokens back to the client as Server-Sent Events.

import { Elysia, t } from 'elysia';
import { meridian } from '@meridian/sdk';

new Elysia()
  .post('/chat', async ({ body }) => {
    const stream = await meridian.chat.stream({
      model: 'azure/model-router',
      messages: [{ role: 'user', content: body.prompt }],
    });
    return stream;
  }, {
    body: t.Object({ prompt: t.String() }),
  })
  .listen(3000);

3Deploy to the edge

Elysia compiles to a single Bun executable or runs on any Node-compatible runtime. For lowest latency, pair it with a Cloudflare Worker or Azure Container App in the same region as your Meridian gateway. The SDK auto-detects the best route through the adaptive model router.