x402

Metaplex x402 API Reference

Last updated September 8, 2026

The Metaplex x402 API is served at https://api.metaplex.com/x402 and exposes three paid services, two free discovery endpoints, and four agent delegation routes. This page is the endpoint, pricing, and client-export reference; the payment modes guide covers how to build the payment-aware fetch that paid endpoints require.

Summary

Every paid endpoint answers an unpaid request with HTTP 402 and a PAYMENT-REQUIRED header describing exactly what to pay, and the client retries with a payment proof. Standard-wallet and direct Core asset or agent modes sign each payment locally; a delegated agent instead authenticates once with a message signature and lets the service build payments from the agent's wallet. Discovery endpoints need no payment and no signer.

  • Base URLs — https://api.metaplex.com/x402 for the API, https://api.metaplex.com/x402/rpc for Solana JSON-RPC
  • Wire format — canonical OpenAI request and response bodies for chat and images, standard Solana JSON-RPC for RPC
  • Settlement — USDC on Solana mainnet, x402 protocol version 2, exact scheme
  • Client version — @metaplex-foundation/x402 0.1.0, Node.js 20.18+, ESM only

Base URLs and Constants

The client exports both base URLs so applications do not hardcode them.

ConstantValue
METAPLEX_X402_BASE_URLhttps://api.metaplex.com/x402
METAPLEX_X402_RPC_URLhttps://api.metaplex.com/x402/rpc

Endpoints

Paid endpoints require a payment-aware fetch; free endpoints do not.

MethodPathPaymentDescription
GET/x402/modelsFreeAvailable model IDs
GET/x402/pricingFreeModel rates, request minimums, RPC method prices, legal URLs
POST/x402/chat/completionsPaidOpenAI-compatible chat completions
POST/x402/images/generationsPaidOpenAI-compatible image generation
POST/x402/rpcPaidSolana JSON-RPC and DAS, HTTP only
GET/x402/core-execute-delegate/statusFreeDelegation status for a Core asset
POST/x402/core-execute-delegate/approveFreeApprove execution delegation
POST/x402/core-execute-delegate/revokeFreeRevoke execution delegation
POST/x402/core-execute-delegate/authFreeExchange a Sign-In-With-X signature for a 24-hour bearer token

The delegation routes are wrapped by the SDK helpers listed under client exports; call those rather than the routes directly.

Discovery Endpoints

Discovery endpoints are free to call and return typed data through the client's helpers.

Read models and pricing without paying
import { getModels, getPricing } from '@metaplex-foundation/x402';
// Available model IDs, e.g. 'openai/gpt-5.4-mini'.
const models = await getModels();
// Per-model token rates, request minimums, RPC method prices, and legal URLs.
const pricing = await getPricing();

GET /x402/models returns an OpenAI-shaped model list:

GET /x402/models response (excerpt)
{
"object": "list",
"data": [
{ "id": "anthropic/claude-opus-4.8", "object": "model", "created": 0, "owned_by": "anthropic" },
{ "id": "openai/gpt-5.4-mini", "object": "model", "created": 0, "owned_by": "openai" }
]
}

Chat Completions Endpoint

POST /x402/chat/completions accepts and returns canonical OpenAI chat completion bodies, with models addressed as <provider>/<model>.

Chat completion through the OpenAI SDK
import { METAPLEX_X402_BASE_URL } from '@metaplex-foundation/x402';
import OpenAI from 'openai';
const openai = new OpenAI({
// The OpenAI SDK requires a value, but this gateway authenticates by payment.
apiKey: 'x402',
baseURL: METAPLEX_X402_BASE_URL,
fetch: fetchWithPayment,
});
const completion = await openai.chat.completions.create({
model: 'openai/gpt-5.4-mini',
messages: [{ role: 'user', content: 'Say hi in one word.' }],
});

The Vercel AI SDK reaches the same endpoint through its OpenAI-compatible provider:

Chat completion through the Vercel AI SDK
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { METAPLEX_X402_BASE_URL } from '@metaplex-foundation/x402';
import { generateText } from 'ai';
const metaplex = createOpenAICompatible({
name: 'metaplex-x402',
apiKey: 'x402',
baseURL: METAPLEX_X402_BASE_URL,
fetch: fetchWithPayment,
});
const { text } = await generateText({
model: metaplex.chatModel('openai/gpt-5.4-mini'),
prompt: 'Say hi in one word.',
});

Image Generation Endpoint

POST /x402/images/generations accepts canonical OpenAI image generation bodies.

Image generation through the OpenAI SDK
const image = await openai.images.generate({
model: 'openai/gpt-image-1.5',
prompt: 'A yellow square.',
size: '1024x1024',
});
Image generation through the Vercel AI SDK
import { generateImage } from 'ai';
const { image } = await generateImage({
model: metaplex.imageModel('openai/gpt-image-1.5'),
prompt: 'A yellow square.',
size: '1024x1024',
});

Solana RPC Endpoint

POST /x402/rpc accepts standard Solana JSON-RPC requests and passes DAS methods through, pricing and paying for each request independently.

Solana RPC through Solana Kit
import { createSolanaRpcFromTransport, type RpcTransport } from '@solana/kit';
import { METAPLEX_X402_RPC_URL } from '@metaplex-foundation/x402';
const rpcTransport: RpcTransport = async ({ payload, signal }) => {
const response = await fetchWithPayment(METAPLEX_X402_RPC_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
signal: signal ?? null,
});
return response.json();
};
const rpc = createSolanaRpcFromTransport(rpcTransport);
const slot = await rpc.getSlot().send();
Solana RPC through web3.js
import { METAPLEX_X402_RPC_URL } from '@metaplex-foundation/x402';
import { Connection } from '@solana/web3.js';
const connection = new Connection(METAPLEX_X402_RPC_URL, {
fetch: fetchWithPayment,
});
const slot = await connection.getSlot();

The x402 RPC endpoint is HTTP-only

WebSocket connections and subscriptions are not supported. Use a conventional RPC provider for accountSubscribe, logsSubscribe, and other subscription methods.

Payment Challenge Fields

An unpaid request to a paid endpoint returns HTTP 402 with a base64 PAYMENT-REQUIRED header. Clients built with @metaplex-foundation/x402 parse this automatically; the fields are documented here for debugging and for non-JavaScript clients.

FieldExample valueMeaning
x402Version2Protocol version
accepts[].schemeexactPayment scheme
accepts[].networksolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpCAIP-2 network identifier for Solana mainnet
accepts[].assetEPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1vUSDC mint
accepts[].amount1000Amount in the asset's atomic units — 1000 is $0.001
accepts[].payTo9AYgwvWMhZuir6rZoto13jrU1oZA1XxRDhqPznxyomHvPayee account
accepts[].maxTimeoutSeconds300Window in which the payment must be submitted
accepts[].extra.quoteIdUUIDIdentifies the quote being paid
accepts[].extra.usageOpenAI usage objectMeasured token usage the quote was priced from
accepts[].extra.memometaplex:x402:chat.completionsMemo written with the settlement
accepts[].extra.feePayerPublic keyAccount paying the payment transaction's network fee
extensions["metaplex-core-execute-delegate"]ObjectDelegation auth details — sign-in-with-x, bearer token, token endpoint, and the X-METAPLEX-CORE-ASSET header used to name the paying asset

Quotes are priced from measured usage

The 402 challenge for an inference request carries a quoteId and a populated usage object, so the amount reflects the tokens the request actually consumed rather than an estimate. Response headers PAYMENT-REQUIRED and PAYMENT-RESPONSE are both CORS-exposed.

Chat Completion Pricing

Chat models are priced per million tokens with separate input, cached-input, and output rates, subject to a $0.001 per-request minimum. The rates below were read from GET /x402/pricing on 2026-09-08.

ModelInputCached inputOutput
anthropic/claude-opus-4.8$5.00$0.50$25.00
anthropic/claude-opus-4.7$5.00$0.50$25.00
anthropic/claude-opus-4.6$5.00$0.50$25.00
anthropic/claude-opus-4.5$5.00$0.50$25.00
anthropic/claude-sonnet-4.6$3.00$0.30$15.00
anthropic/claude-sonnet-4.5$3.00$0.30$15.00
anthropic/claude-haiku-4.5$1.00$0.10$5.00
openai/gpt-5.5$5.00$0.50$30.00
openai/gpt-5.4$2.50$0.25$15.00
openai/gpt-5.4-mini$0.75$0.075$4.50
openai/gpt-5.4-nano$0.20$0.02$1.25

openai/gpt-5.5 and openai/gpt-5.4 carry higher long-context rates above 272,000 input tokens — $10.00 input and $45.00 output for gpt-5.5, and $5.00 input and $22.50 output for gpt-5.4.

Image Generation Pricing

Image models are priced per million tokens across four categories, with the same $0.001 per-request minimum.

ModelInput textInput imageOutput imageOutput text
openai/gpt-image-1.5$5.00$8.00$32.00$10.00
openai/gpt-image-2$5.00$8.00$30.00$10.00

Solana RPC Pricing

RPC calls are priced per request at $0.00001 by default, with higher rates for heavier methods.

MethodPrice per request
Default (any method not listed)$0.00001
getBlockTime$0.00001
getTransaction$0.00002
getBlocks$0.00002
getBlocksWithLimit$0.00002
getConfirmedTransaction$0.00002
getBlock$0.00005
getConfirmedBlock$0.00005
getSignaturesForAddress$0.00010

MetaplexSvmExactScheme Options

MetaplexSvmExactScheme is the payment scheme used for Core asset and agent payments.

OptionRequiredDescription
rpcUrlYesRPC endpoint used to build payment transactions
coreExecute.assetFor Core asset paymentsCore asset or agent whose signer PDA funds payments
coreExecute.collectionWhen the asset is in a collectionThe asset's Core collection
coreExecute.executionDelegateRecordNoAdvanced: override the execution delegate record
commitmentNoCommitment for blockhash fetches; defaults to confirmed
computeUnitLimitNoDefaults to 200,000 for Core execute payments, 20,000 otherwise

The scheme accepts Umi signers and Solana Kit partial transaction signers, but not sign-and-send signers. Kit signers are adapted internally.

Client Exports

@metaplex-foundation/x402 centralizes its public API in the package root.

CategoryExports
PaymentsMetaplexSvmExactScheme, MetaplexSvmSigner, kitPartialTransactionSignerToUmiSigner
Agent delegationfetchMetaplexCoreExecuteDelegateStatus, approveMetaplexCoreExecuteDelegate, revokeMetaplexCoreExecuteDelegate, authorizeMetaplexCoreExecuteDelegate
Agent payment transportscreateMetaplexCoreExecuteDelegateClientExtension, wrapFetchWithMetaplexCoreExecuteDelegate, the token-store implementations
DiscoverygetModels, getPricing, METAPLEX_X402_BASE_URL, METAPLEX_X402_RPC_URL

Option and result types, protocol constants, and delegate route schemas are exported from the package root as well.

Environment Variables

The runnable examples in the x402 repository read the following variables.

VariableRequiredDescription
SVM_PRIVATE_KEYYesBase58-encoded 64-byte development keypair
CORE_ASSET_ADDRESSCore asset and agent examplesMetaplex Core asset owned by the keypair
SVM_RPC_URLNoCustom Solana RPC URL used by the x402 SVM scheme
METAPLEX_X402_BASE_URLNoAPI base URL; defaults to https://api.metaplex.com/x402
METAPLEX_X402_RPC_URLNoRPC URL; defaults to https://api.metaplex.com/x402/rpc
METAPLEX_API_BASE_URLNoAPI-root override for local development, e.g. http://localhost:3000/api

Notes

  • Prices in this reference are a snapshot read on 2026-09-08. GET /x402/pricing on the live service is the operative price list and is free to call.
  • Payments settle in USDC from a classic SPL Token associated token account. Token-2022 payment mints are not currently supported.
  • Core asset and agent payment modes require SOL in the asset signer PDA to cover Core execute fees; standard wallet payments do not.
  • The hosted server is not open source. The client, its examples, and the protocol types are published under Apache-2.0.
  • Using the API means agreeing to the Metaplex.com Terms of Use and Privacy Policy.

Quick Reference

ItemValue
API base URLhttps://api.metaplex.com/x402
RPC URLhttps://api.metaplex.com/x402/rpc
JS client@metaplex-foundation/x402 (0.1.0)
RuntimeNode.js 20.18+, ESM
Protocolx402 version 2, exact scheme
Networksolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp (Solana mainnet)
Payment mintEPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v (USDC)
Operating agentMECHjj31U1hBapoVeJtZo5U5WGRd2293JEwRErvPTuF
SourceGitHub (Apache-2.0)

Maintained by Metaplex Foundation. Last verified: 2026-09-08. Client version: @metaplex-foundation/x402 0.1.0. View source on GitHub.