This is the 10-minute server integration with the first-party @roadie/sdk. Every snippet below is executed in CI against a live gateway; the runnable sources are in documentation/docs/snippets/node/.
Prefer to keep your existing OpenAI code? Point the official OpenAI SDK at Roadie instead — see the OpenAI drop-in quickstart.

1. Prerequisites

In the dashboard:
  1. Create a project (its development and production environments are created for you).
  2. Add and validate a provider credential (your OpenAI or Anthropic key — BYOK). See Providers & BYOK.
  3. Create a secret key (rd_sk_…) for the environment you want to call.
A secret key grants full access to your project’s data plane. Keep it on your server — never ship it in a browser or mobile app. For client apps, use client tokens.

2. Install

Set your key in the environment:

3. Construct the client

Create the client once and reuse it. Provide baseUrl only if you target a specific gateway host (self-hosted or regional); otherwise the default hosted gateway () is used.
snippets/node/client.ts

4. Send a chat completion

roadie.chat.create returns the normalized response: the assistant message, finish_reason, token usage, an estimated cost, and the gateway requestId.
snippets/node/chat.ts
model accepts an explicit provider/model id (like openai/gpt-4o) or a project alias you configure (like smart) that fails over across providers. See Models, aliases & fallback.

5. Stream the response

Iterate the async-iterable stream with for await. content_delta events carry incremental text; the terminal message_end event carries the final usage and cost.
snippets/node/stream.ts
Pass an AbortSignal to cancel a stream (or any call); NDJSON framing is available via { framing: 'ndjson' }. See Streaming.

6. Create embeddings

snippets/node/embeddings.ts

7. Handle typed errors

Every failure is a RoadieError subclass with a stable code, the requestId, the HTTP status, and (for rate limits) retryAfter. Branch on the class.
snippets/node/errors.ts
The SDK already retries transient failures (network errors, 429, 5xx) before they reach you, honoring Retry-After. See Errors & retries and the full error reference.

Next steps

Next.js quickstart

Wrap the SDK in a server-side route.

OpenAI drop-in

Keep the OpenAI SDK — change only the base URL and key.

Rate limits, quotas & budgets

Cap spend and usage before it happens.

curl / REST quickstart

The raw HTTP contract, SSE streaming included.