44.5 Model/provider change management

Overview and links for this section of the guide.

Model Portability

Don't hardcode `google.generativeai`. Use an adapter pattern.

interface LLM {
  generate(prompt: string): Promise;
}

class GeminiAdapter implements LLM { ... }
class OtherAdapter implements LLM { ... }

The Wrapper

This allows you to swap providers if: - One goes down. - One raises prices. - A better model comes out.

Where to go next