A vendor-agnostic Interchange ProviderAdapter for the OpenAI Responses API
wire protocol. Vendor differences (headers, system-prompt placement,
session-id routing, request-body switches) are config, not forked code.
src/responses.ts holds the quirks schema + resolver, the header
extractors, and the factory that wires src/protocol/ together, following
Interchange's inference-discovery-openai layout. src/index.ts is
re-exports plus the provider ids and factory record:
src/responses.ts—ResponsesQuirksand its resolver,ResponsesHooks, the rate-limit header extractors, andcreateOpenAIResponsesAdapter/responsesAdapterFactory.src/protocol/body.ts—buildResponsesRequestwith its content, tool, system-prompt, and reasoning helpers, plus reasoningencrypted_contentsignature tag/replay.src/protocol/iterator.ts— event schemas, SSE streaming parse, non-streaming JSON parse, block indexing, and terminal-event detection.src/index.ts— re-exports of the above plus the two provider-id constants (OPENAI_COMPATIBLE_RESPONSES_PROVIDERis deprecated, removed in 0.3.0) andresponsesAdapterFactories.src/*.test.ts— unit tests for the wire codec and parser, excluded from the build.e2e/—runInferencethrough@intx/inference-testing, plus the opt-in live suite (OPENAI_RESPONSES_LIVE_URL).
- Consume
@intx/inferenceand@intx/typesaspeerDependencies(^0.4.0), pinned0.4.0indevDependenciesfor typecheck — never vendor, neverworkspace:. A host must resolve exactly one copy; a second copy breaksinstanceof ProtocolMismatchError. - Parse every trust boundary (the
quirksbag, everyresponse.*SSE event, the non-streaming JSON body) with arktype; neveras Tuntrusted input. exactOptionalPropertyTypesis on: omit optional keys, never assignundefinedto one.- No product strings baked in — anything vendor-specific is a config field the caller supplies.
- Public surface is
src/index.ts's export list only:createOpenAIResponsesAdapter,responsesAdapterFactory,responsesAdapterFactories,ResponsesQuirks,ResponsesHooks, and the two provider-id constants. Everything else insrc/responses.tsandsrc/protocol/(parseResponse,parseJSONResponse,isResponsesStreamTerminal, block indexing, signature tag/replay, the resolved quirks type) is package-private. Tests go through the public factory only — never import./responsesdirectly from a test. - Tests only for load-bearing risk (wire-format encoding, state machines, hostile-input parsing) — not for trivial mapping or "returns what I passed in".
bun install && bun run check