Skip to content

Add first-class UsageTap gateway provider (usagetapAdapter) - #21

Merged
PredictabilityAtScale merged 1 commit into
mainfrom
codex/add-usagetap-llm-gateway-support
Jul 27, 2026
Merged

Add first-class UsageTap gateway provider (usagetapAdapter)#21
PredictabilityAtScale merged 1 commit into
mainfrom
codex/add-usagetap-llm-gateway-support

Conversation

@PredictabilityAtScale

Copy link
Copy Markdown
Owner

Motivation

  • Add native UsageTap LLM Gateway support as a distinct provider named usagetap modeled after the existing LLMAsAService adapter so prompt assets can target the first-party UsageTap gateway without changing llmasaservice behavior.
  • Ensure prompt schema, defaults/override merging, raw passthrough, rendering, and provider registry treat usagetap as a first-class, provider-scoped option.
  • Provide an OpenAI-compatible SDK helper so callers can construct an OpenAI client pointing at the gateway with runtime credentials that are never serialized into prompt artifacts.
  • Keep existing UsageTap lifecycle/meters and LLMAsAService integrations unchanged so gateway calls are not double-metered.

Description

  • Added a new provider adapter usagetapAdapter and SDK helper createUsageTapGatewayOpenAIConfig plus constants USAGETAP_GATEWAY_BASE_URL, USAGETAP_GATEWAY_DEFAULT_MODEL, and USAGETAP_GATEWAY_RESPONSE_HEADER_NAMES, and exported the new symbols from the package root and promptopskit/usagetap.
  • Extended types and runtime options with UsageTapGatewayRuntimeOptions (runtime apiKey and optional idempotencyKey) and added UsageTapGatewayOpenAIConfig/UsageTapGatewayOpenAIConfigOptions types.
  • Added schema support for provider_options.usagetap, optional rich customer attribution, and provider_options.usagetap.compress (and raw.usagetap passthrough), and wired these into defaults/override merging and raw merging logic.
  • Reused the existing OpenAI chat mapping for messages/tools/streaming and implemented gateway-specific behavior: default model usagetap/standard, GPT-5 max_tokensmax_completion_tokens compatibility, ordered fallback_modelsmodels mapping (avoid duplicating primary), injection of customer/feature/conversation/project/compress fields, raw-last override semantics, and runtime-only Idempotency-Key header emission.

Testing

  • Ran the repository checks: npm run lint (tsc --noEmit) completed with no errors.
  • Ran the unit test suite with npm test (vitest run) and all tests passed: 15 test files, 275 tests passed.
  • Built distributables with npm run build (tsup) which completed successfully and produced ESM/CJS and DTS artifacts for the new usagetap entries.
  • Ran package/type-quality checks npm run attw (node scripts/check-attw.mjs) and it reported "No problems found" for all entries including the new usagetap outputs.

Public API added: USAGETAP_GATEWAY_BASE_URL, USAGETAP_GATEWAY_DEFAULT_MODEL, USAGETAP_GATEWAY_RESPONSE_HEADER_NAMES, UsageTapGatewayRuntimeOptions, UsageTapGatewayOpenAIConfig, UsageTapGatewayOpenAIConfigOptions, createUsageTapGatewayOpenAIConfig, and usagetapAdapter.

Compatibility decisions: usagetap is a separate provider and does not replace or alter llmasaservice; UsageTap lifecycle/mediation helpers remain available but must not be used to wrap gateway calls (to avoid double-metering).


Codex Task

@PredictabilityAtScale
PredictabilityAtScale merged commit 6938c07 into main Jul 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant