01Understand the provider's application primitive
Modern provider APIs represent messages, content, actions, and tool calls through structured request and response types. OpenAI's Responses API is one concrete example; other providers expose similar capabilities through different contracts. Build around the durable concepts rather than one vendor's naming.
Build an internal protocol around meaning: text deltas, tool proposals, tool observations, usage, errors, and terminal completion. A provider-specific payload maps to these events through an adapter. Preserve required capability information rather than flattening everything into text. Treat “stream closed” separately from “operation completed successfully,” because network closure can also mean failure.
Persist application run identity and business state even if a provider stores conversation state. The product still owns access, retention, approval, and recovery semantics. Record the provider mapping and versions used for a run so a later migration can reproduce or diagnose behavior. Learn the durable boundaries while checking volatile endpoint details in current official documentation.
- Keep an internal adapter around vendor specifics
- Use typed streaming lifecycle events
- Persist your own product state and audit semantics