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

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'
}));

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.

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 _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.

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.