rudra-js

Running without a model

Leave provider out of createComponentGenerator, or pass null. Core then builds the block itself. Nothing calls a model, and nothing is billed. The page in the quick start runs this way.

What you get

Every page view gets the block core builds without a model. generate returns a spec with source: 'fallback', and its event has degradedReason: 'no-provider'.

Bundles don't appear until a model is on, because only a model asks for a bundle block.

Adding the model later

You can start without a model and add one later. This generator calls Claude only when an API key is set:

import { createAnthropicProvider } from '@rudra-js/anthropic';
import { createComponentGenerator } from '@rudra-js/core';

const apiKey = process.env.ANTHROPIC_API_KEY;

export const generator = createComponentGenerator({
  provider: apiKey ? createAnthropicProvider({ apiKey }) : null,
});
  • With no key, provider is null and core builds every block itself.
  • generate returns a promise with or without a provider, so the code that awaits it stays the same.
  • Set the key and the same code calls Claude. Then check that the model answered.

Showing a block you wrote yourself

To show a block you designed, still with no model, pass createFixedSpecProvider as the provider. It answers every page view with your spec. Rendering a spec you wrote by hand has an example.

Core checks your spec the way it checks a model's answer.

Skipping the model for one page view

With a provider set, call generator.generateDeterministic to get the block core builds without a model for a single page view. A shopper who objects to profiling shows it in use.