Dexter
Dexter
Docs

@dexterai/x402-ads-publisher

@dexterai/x402-ads-publisher is the publisher middleware package for Sponsored Access Model B.

It is the package you install when you want sponsored recommendations to become visible in the response body seen by the agent or LLM.

What It Is

Sponsored Access has two models:

  • Model A: facilitator-native, zero publisher install
  • Model B: publisher middleware, opt-in

This package exists for Model B.

The x402-ads source README describes it as the middleware that:

  • reads sponsored recommendations from SettlementResponse.extensions
  • injects _x402_sponsored into the JSON response body
  • supports richer publisher participation than passive facilitator-native delivery

One source-quality note:

  • npm metadata confirms the package exists and is published
  • npm does not currently expose package README content
  • the authoritative implementation detail is in the Dexter-DAO/x402-ads source README and package code

When To Use It

Use @dexterai/x402-ads-publisher when:

  • you operate an x402 endpoint
  • you want recommendations visible to the agent's LLM context
  • you want Model B behavior rather than just passive receipt-level delivery
  • you want publisher-side control and premium participation in Sponsored Access

Do not use it when you only want the default facilitator-native behavior.

In that case, Model A already works without installing anything.

Install

npm install @dexterai/x402-ads-publisher

Minimal Example

import { withSponsoredAccess } from '@dexterai/x402-ads-publisher';
 
app.use('/api/data', withSponsoredAccess({
  publisherId: 'pub_abc123',
  apiKey: 'key_...',
  contentCategory: 'finance'
}));

This is the exact integration shape documented in the x402-ads source README.

Integration Shape

The x402-ads repo describes this package as the publisher-side middleware layer in a larger system:

  • facilitator matches a campaign
  • recommendation is injected into SettlementResponse.extensions
  • publisher middleware reads those extensions
  • middleware injects _x402_sponsored into the JSON response body

So this package is best understood as the bridge between settlement metadata and LLM-visible response content.

What It Adds

The x402-ads source README attributes these capabilities to Model B:

  • response body injection of _x402_sponsored
  • price discounts / subsidy mode
  • higher revenue share
  • analytics

The package is therefore not just a cosmetic add-on. It is the middleware layer that changes how sponsored recommendations become visible in the response path.

Source-Level Role In The Monorepo

The x402-ads source README places this package in:

  • packages/publisher/

and describes the implementation pieces as:

  • middleware.ts
  • manifest.ts
  • matcher.ts

That matters because the package is not just one helper function. It is part of the publisher-side campaign-matching and response-shaping path.

How It Relates To @dexterai/x402

The source README also states that @dexterai/x402 supports Sponsored Access from the SDK side:

  • server middleware can use sponsoredAccess: true
  • the client SDK decodes the PAYMENT-RESPONSE header

So the relationship is:

  • @dexterai/x402 handles the core x402 payment flow
  • @dexterai/x402-ads-publisher handles the opt-in publisher middleware layer for sponsored recommendation injection

What The Publisher Gets

The source README describes the Model B value as:

  • recommendations visible in the response body
  • price discount / subsidy behavior
  • better revenue participation than passive Model A hosting
  • analytics on impression and fill behavior

What _x402_sponsored Means

The documented effect of the middleware is that the JSON response body can include a field like:

{
  "_x402_sponsored": [
    {
      "resourceUrl": "https://x402.dexter.cash/api/tools/solscan/trending",
      "description": "Solscan Trending Tokens: real-time trending data on Solana",
      "sponsor": "Dexter"
    }
  ],
  "data": "...",
  "otherFields": "..."
}

The intent is that the agent or LLM can see the recommendation directly in the response body rather than only in protocol metadata.

What This Package Does Not Do

It does not replace the base x402 payment flow.

It does not mean every publisher must install middleware.

It does not change the fact that Model A exists underneath as the default facilitator-native base layer.

It does not exist to modify arbitrary publisher responses for unrelated reasons. Its purpose is specifically Sponsored Access delivery.

Common Failure Modes

Installing this when Model A is enough

If you do not need body injection or premium publisher behavior, this package may be unnecessary.

Assuming it replaces @dexterai/x402

It is complementary middleware, not the base seller SDK.

Confusing recommendation delivery layers

Model A delivers recommendations in settlement metadata.

Model B, using this package, is the path that makes recommendations visible in the response body.

Expecting package-only behavior without the wider Sponsored Access system

This middleware depends on the broader Sponsored Access flow already existing around it. It is not a self-contained ads platform by itself.

Publisher Dashboard

View your earnings, endpoint performance, and payout history at dexter.cash/publisher/ads. The dashboard works for both Model A (passive) and Model B (middleware) publishers.