Provider Abstraction and Model Selection
A provider abstraction should standardize only what your product actually needs: text generation, streaming, structured output, tool calls, embeddings, or image input. Do not flatten meaningful differences between providers into a misleading lowest-common-denominator interface. Record model identifier, version or snapshot when available, configuration, latency, token usage, and evaluation results.
Model choice is a product decision. Compare task quality, latency, availability, context length, tool reliability, multimodal capability, data handling terms, and cost. Keep a fallback policy for temporary outages, but do not silently downgrade to a model that fails your quality or privacy requirements.
export function createTextGenerator(client, model) {
return {
async generate({ instructions, input }) {
const result = await client.responses.create({
model,
instructions,
input
});
return {
text: result.output_text,
responseId: result.id
};
}
};
}- Hide provider-specific response parsing behind an adapter.
- Evaluate models on representative tasks.
- Fallbacks must preserve safety, privacy, and minimum quality requirements.
What should be recorded when comparing model choices in production?