The decision that matters
Define a narrow internal contract for the capability your application needs. Normalize successful text output, usage and completion status, then handle provider-specific requests inside adapters. Treat missing keys and incomplete responses as explicit errors. Avoid silently changing providers when a request fails unless the workflow permits it and the operator can see that the route changed.
A practical scenario
A response-drafting service may support Anthropic, OpenAI and Gemini. Its internal result could include text, provider, model, usage and finish state. A truncated response should not be accepted merely because it contains some text. The adapter must recognize that provider’s incomplete state so the application can request review or a bounded retry.
Before you ship
- Test each adapter against its native response schema.
- Keep provider keys restricted to the intended endpoint.
- Display the provider and model used for an important result.
A useful next step
Create fixtures for success, timeout, missing credentials and incomplete generation before enabling another provider. Then run a small live test with an approved task. Compatibility should mean the workflow remains understandable and correct, not simply that every provider returns a string.
Primary reference & further reading
This guide combines general engineering recommendations with an illustrative scenario. Provider behavior can change; check current documentation before applying it. Read our editorial approach.