@dexterai/x402 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -134,27 +134,36 @@ function PayButton() {
134
134
 
135
135
  ## Supported Networks
136
136
 
137
- | Network | Identifier | Status |
138
- |---------|------------|--------|
139
- | Solana Mainnet | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | Verified |
140
- | Base Mainnet | `eip155:8453` | Verified |
137
+ | Network | Identifier | Client | Server |
138
+ |---------|------------|--------|--------|
139
+ | Solana Mainnet | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | Verified | ✅ Verified |
140
+ | Base Mainnet | `eip155:8453` | Verified | ✅ Verified |
141
141
 
142
- All networks use USDC.
142
+ All networks use USDC. Both client and server SDKs are production-tested with real payments.
143
143
 
144
144
  ---
145
145
 
146
146
  ## Package Exports
147
147
 
148
148
  ```typescript
149
- // Client - browser & Node.js
149
+ // Client - browser
150
150
  import { createX402Client } from '@dexterai/x402/client';
151
151
 
152
+ // Client - Node.js (private key wallet)
153
+ import { wrapFetch, createKeypairWallet } from '@dexterai/x402/client';
154
+
152
155
  // React hook
153
156
  import { useX402Payment } from '@dexterai/x402/react';
154
157
 
155
- // Server helpers
158
+ // Server - Express middleware
159
+ import { x402Middleware } from '@dexterai/x402/server';
160
+
161
+ // Server - manual control
156
162
  import { createX402Server } from '@dexterai/x402/server';
157
163
 
164
+ // Server - dynamic pricing
165
+ import { createDynamicPricing, createTokenPricing } from '@dexterai/x402/server';
166
+
158
167
  // Chain adapters (advanced)
159
168
  import { createSolanaAdapter, createEvmAdapter } from '@dexterai/x402/adapters';
160
169
 
@@ -0,0 +1,385 @@
1
+ Pricing
2
+ =======
3
+
4
+ ###
5
+
6
+ Text tokens
7
+
8
+ Prices per 1M tokens.
9
+
10
+ Batch
11
+
12
+ |Model|Input|Cached input|Output|
13
+ |---|---|---|---|
14
+ |gpt-5.2|$0.875|$0.0875|$7.00|
15
+ |gpt-5.1|$0.625|$0.0625|$5.00|
16
+ |gpt-5|$0.625|$0.0625|$5.00|
17
+ |gpt-5-mini|$0.125|$0.0125|$1.00|
18
+ |gpt-5-nano|$0.025|$0.0025|$0.20|
19
+ |gpt-5.2-pro|$10.50|-|$84.00|
20
+ |gpt-5-pro|$7.50|-|$60.00|
21
+ |gpt-4.1|$1.00|-|$4.00|
22
+ |gpt-4.1-mini|$0.20|-|$0.80|
23
+ |gpt-4.1-nano|$0.05|-|$0.20|
24
+ |gpt-4o|$1.25|-|$5.00|
25
+ |gpt-4o-2024-05-13|$2.50|-|$7.50|
26
+ |gpt-4o-mini|$0.075|-|$0.30|
27
+ |o1|$7.50|-|$30.00|
28
+ |o1-pro|$75.00|-|$300.00|
29
+ |o3-pro|$10.00|-|$40.00|
30
+ |o3|$1.00|-|$4.00|
31
+ |o3-deep-research|$5.00|-|$20.00|
32
+ |o4-mini|$0.55|-|$2.20|
33
+ |o4-mini-deep-research|$1.00|-|$4.00|
34
+ |o3-mini|$0.55|-|$2.20|
35
+ |o1-mini|$0.55|-|$2.20|
36
+ |computer-use-preview|$1.50|-|$6.00|
37
+
38
+ Flex
39
+
40
+ |Model|Input|Cached input|Output|
41
+ |---|---|---|---|
42
+ |gpt-5.2|$0.875|$0.0875|$7.00|
43
+ |gpt-5.1|$0.625|$0.0625|$5.00|
44
+ |gpt-5|$0.625|$0.0625|$5.00|
45
+ |gpt-5-mini|$0.125|$0.0125|$1.00|
46
+ |gpt-5-nano|$0.025|$0.0025|$0.20|
47
+ |o3|$1.00|$0.25|$4.00|
48
+ |o4-mini|$0.55|$0.138|$2.20|
49
+
50
+ Standard
51
+
52
+ |Model|Input|Cached input|Output|
53
+ |---|---|---|---|
54
+ |gpt-5.2|$1.75|$0.175|$14.00|
55
+ |gpt-5.1|$1.25|$0.125|$10.00|
56
+ |gpt-5|$1.25|$0.125|$10.00|
57
+ |gpt-5-mini|$0.25|$0.025|$2.00|
58
+ |gpt-5-nano|$0.05|$0.005|$0.40|
59
+ |gpt-5.2-chat-latest|$1.75|$0.175|$14.00|
60
+ |gpt-5.1-chat-latest|$1.25|$0.125|$10.00|
61
+ |gpt-5-chat-latest|$1.25|$0.125|$10.00|
62
+ |gpt-5.1-codex-max|$1.25|$0.125|$10.00|
63
+ |gpt-5.1-codex|$1.25|$0.125|$10.00|
64
+ |gpt-5-codex|$1.25|$0.125|$10.00|
65
+ |gpt-5.2-pro|$21.00|-|$168.00|
66
+ |gpt-5-pro|$15.00|-|$120.00|
67
+ |gpt-4.1|$2.00|$0.50|$8.00|
68
+ |gpt-4.1-mini|$0.40|$0.10|$1.60|
69
+ |gpt-4.1-nano|$0.10|$0.025|$0.40|
70
+ |gpt-4o|$2.50|$1.25|$10.00|
71
+ |gpt-4o-2024-05-13|$5.00|-|$15.00|
72
+ |gpt-4o-mini|$0.15|$0.075|$0.60|
73
+ |gpt-realtime|$4.00|$0.40|$16.00|
74
+ |gpt-realtime-mini|$0.60|$0.06|$2.40|
75
+ |gpt-4o-realtime-preview|$5.00|$2.50|$20.00|
76
+ |gpt-4o-mini-realtime-preview|$0.60|$0.30|$2.40|
77
+ |gpt-audio|$2.50|-|$10.00|
78
+ |gpt-audio-mini|$0.60|-|$2.40|
79
+ |gpt-4o-audio-preview|$2.50|-|$10.00|
80
+ |gpt-4o-mini-audio-preview|$0.15|-|$0.60|
81
+ |o1|$15.00|$7.50|$60.00|
82
+ |o1-pro|$150.00|-|$600.00|
83
+ |o3-pro|$20.00|-|$80.00|
84
+ |o3|$2.00|$0.50|$8.00|
85
+ |o3-deep-research|$10.00|$2.50|$40.00|
86
+ |o4-mini|$1.10|$0.275|$4.40|
87
+ |o4-mini-deep-research|$2.00|$0.50|$8.00|
88
+ |o3-mini|$1.10|$0.55|$4.40|
89
+ |o1-mini|$1.10|$0.55|$4.40|
90
+ |gpt-5.1-codex-mini|$0.25|$0.025|$2.00|
91
+ |codex-mini-latest|$1.50|$0.375|$6.00|
92
+ |gpt-5-search-api|$1.25|$0.125|$10.00|
93
+ |gpt-4o-mini-search-preview|$0.15|-|$0.60|
94
+ |gpt-4o-search-preview|$2.50|-|$10.00|
95
+ |computer-use-preview|$3.00|-|$12.00|
96
+ |gpt-image-1.5|$5.00|$1.25|$10.00|
97
+ |chatgpt-image-latest|$5.00|$1.25|$10.00|
98
+ |gpt-image-1|$5.00|$1.25|-|
99
+ |gpt-image-1-mini|$2.00|$0.20|-|
100
+
101
+ Priority
102
+
103
+ |Model|Input|Cached input|Output|
104
+ |---|---|---|---|
105
+ |gpt-5.2|$3.50|$0.35|$28.00|
106
+ |gpt-5.1|$2.50|$0.25|$20.00|
107
+ |gpt-5|$2.50|$0.25|$20.00|
108
+ |gpt-5-mini|$0.45|$0.045|$3.60|
109
+ |gpt-5.1-codex-max|$2.50|$0.25|$20.00|
110
+ |gpt-5.1-codex|$2.50|$0.25|$20.00|
111
+ |gpt-5-codex|$2.50|$0.25|$20.00|
112
+ |gpt-4.1|$3.50|$0.875|$14.00|
113
+ |gpt-4.1-mini|$0.70|$0.175|$2.80|
114
+ |gpt-4.1-nano|$0.20|$0.05|$0.80|
115
+ |gpt-4o|$4.25|$2.125|$17.00|
116
+ |gpt-4o-2024-05-13|$8.75|-|$26.25|
117
+ |gpt-4o-mini|$0.25|$0.125|$1.00|
118
+ |o3|$3.50|$0.875|$14.00|
119
+ |o4-mini|$2.00|$0.50|$8.00|
120
+
121
+ For faster processing of API requests, try the [priority processing service tier](https://platform.openai.com/docs/guides/priority-processing). For lower prices with higher latency, try the [flex processing tier](https://platform.openai.com/docs/guides/flex-processing).
122
+
123
+ Large numbers of API requests which are not time-sensitive can use the [Batch API](https://platform.openai.com/docs/guides/batch) for additional savings as well.
124
+
125
+ While reasoning tokens are not visible via the API, they still occupy space in the model's context window and are billed as output tokens.
126
+
127
+ For gpt-image-1.5, Text output tokens include model reasoning tokens.
128
+
129
+
130
+
131
+ ###
132
+
133
+ Image tokens
134
+
135
+ Prices per 1M tokens.
136
+
137
+ |Model|Input|Cached Input|Output|
138
+ |---|---|---|---|
139
+ |gpt-image-1.5|$8.00|$2.00|$32.00|
140
+ |chatgpt-image-latest|$8.00|$2.00|$32.00|
141
+ |gpt-image-1|$10.00|$2.50|$40.00|
142
+ |gpt-image-1-mini|$2.50|$0.25|$8.00|
143
+ |gpt-realtime|$5.00|$0.50|-|
144
+ |gpt-realtime-mini|$0.80|$0.08|-|
145
+
146
+
147
+
148
+ ###
149
+
150
+ Audio tokens
151
+
152
+ Prices per 1M tokens.
153
+
154
+ |Model|Input|Cached Input|Output|
155
+ |---|---|---|---|
156
+ |gpt-realtime|$32.00|$0.40|$64.00|
157
+ |gpt-realtime-mini|$10.00|$0.30|$20.00|
158
+ |gpt-4o-realtime-preview|$40.00|$2.50|$80.00|
159
+ |gpt-4o-mini-realtime-preview|$10.00|$0.30|$20.00|
160
+ |gpt-audio|$32.00|-|$64.00|
161
+ |gpt-audio-mini|$10.00|-|$20.00|
162
+ |gpt-4o-audio-preview|$40.00|-|$80.00|
163
+ |gpt-4o-mini-audio-preview|$10.00|-|$20.00|
164
+
165
+
166
+
167
+ ###
168
+
169
+ Video
170
+
171
+ Prices per second.
172
+
173
+ |Model|Size: Output resolution|Price per second|
174
+ |---|---|---|
175
+ |sora-2|Portrait: 720x1280 Landscape: 1280x720|$0.10|
176
+ |sora-2-pro|Portrait: 720x1280 Landscape: 1280x720|$0.30|
177
+ |sora-2-pro|Portrait: 1024x1792 Landscape: 1792x1024|$0.50|
178
+
179
+
180
+
181
+ ###
182
+
183
+ Fine-tuning
184
+
185
+ Prices per 1M tokens.
186
+
187
+ Batch
188
+
189
+ |Model|Training|Input|Cached Input|Output|
190
+ |---|---|---|---|---|
191
+ |o4-mini-2025-04-16|$100.00 / hour|$2.00|$0.50|$8.00|
192
+ |o4-mini-2025-04-16with data sharing|$100.00 / hour|$1.00|$0.25|$4.00|
193
+ |gpt-4.1-2025-04-14|$25.00|$1.50|$0.50|$6.00|
194
+ |gpt-4.1-mini-2025-04-14|$5.00|$0.40|$0.10|$1.60|
195
+ |gpt-4.1-nano-2025-04-14|$1.50|$0.10|$0.025|$0.40|
196
+ |gpt-4o-2024-08-06|$25.00|$2.225|$0.90|$12.50|
197
+ |gpt-4o-mini-2024-07-18|$3.00|$0.15|$0.075|$0.60|
198
+ |gpt-3.5-turbo|$8.00|$1.50|-|$3.00|
199
+ |davinci-002|$6.00|$6.00|-|$6.00|
200
+ |babbage-002|$0.40|$0.80|-|$0.90|
201
+
202
+ Standard
203
+
204
+ |Model|Training|Input|Cached Input|Output|
205
+ |---|---|---|---|---|
206
+ |o4-mini-2025-04-16|$100.00 / hour|$4.00|$1.00|$16.00|
207
+ |o4-mini-2025-04-16with data sharing|$100.00 / hour|$2.00|$0.50|$8.00|
208
+ |gpt-4.1-2025-04-14|$25.00|$3.00|$0.75|$12.00|
209
+ |gpt-4.1-mini-2025-04-14|$5.00|$0.80|$0.20|$3.20|
210
+ |gpt-4.1-nano-2025-04-14|$1.50|$0.20|$0.05|$0.80|
211
+ |gpt-4o-2024-08-06|$25.00|$3.75|$1.875|$15.00|
212
+ |gpt-4o-mini-2024-07-18|$3.00|$0.30|$0.15|$1.20|
213
+ |gpt-3.5-turbo|$8.00|$3.00|-|$6.00|
214
+ |davinci-002|$6.00|$12.00|-|$12.00|
215
+ |babbage-002|$0.40|$1.60|-|$1.60|
216
+
217
+ Tokens used for model grading in reinforcement fine-tuning are billed at that model's per-token rate. Inference discounts are available if you enable data sharing when creating the fine-tune job. [Learn more](https://help.openai.com/en/articles/10306912-sharing-feedback-evaluation-and-fine-tuning-data-and-api-inputs-and-outputs-with-openai#h_c93188c569).
218
+
219
+
220
+
221
+ ###
222
+
223
+ Built-in tools
224
+
225
+ |Tool|Cost|
226
+ |---|---|
227
+ |Code Interpreter|1 GB (default): $0.03 / container4 GB: $0.12 / container16 GB: $0.48 / container64 GB: $1.92 / container|
228
+ |File search storage|$0.10 / GB per day (1GB free)|
229
+ |File search tool callResponses API only|$2.50 / 1k calls|
230
+ |Web search (all models)[1]|$10.00 / 1k calls + search content tokens billed at model rates|
231
+ |Web search preview (reasoning models, including gpt-5, o-series)|$10.00 / 1k calls + search content tokens billed at model rates|
232
+ |Web search preview (non-reasoning models)|$25.00 / 1k calls + search content tokens are free|
233
+
234
+ The tokens used for built-in tools are billed at the chosen model's per-token rates. GB refers to binary gigabytes of storage (also known as gibibyte), where 1GB is 2^30 bytes.
235
+
236
+ **Web search:** There are two components that contribute to the cost of using the web search tool: (1) tool calls and (2) search content tokens. Tool calls are billed per 1000 calls, according to the tool version and model type. The billing dashboard and invoices will report these line items as “web search tool calls.”
237
+
238
+ Search content tokens are tokens retrieved from the search index and fed to the model alongside your prompt to generate an answer. These are billed at the model’s input token rate, unless otherwise specified.
239
+
240
+ \[1\] For `gpt-4o-mini` and `gpt-4.1-mini` with the web search non-preview tool, search content tokens are charged as a fixed block of 8,000 input tokens per call.
241
+
242
+
243
+
244
+ ###
245
+
246
+ AgentKit
247
+
248
+ Build, deploy, and optimize production-grade agents with Agent Builder, ChatKit, and Evals. You pay only for the compute and data you actually use.
249
+
250
+ |Usage meter|Free tier (per account, per month)|Price beyond free tier|
251
+ |---|---|---|
252
+ |Storage for ChatKit File / Image Uploads|1 GB|$0.10 / GB-day|
253
+
254
+
255
+
256
+ ###
257
+
258
+ Transcription and speech generation
259
+
260
+ Prices per 1M tokens.
261
+
262
+ #### Text tokens
263
+
264
+ |Model|Input|Output|Estimated cost|
265
+ |---|---|---|---|
266
+ |gpt-4o-mini-tts|$0.60|-|$0.015 / minute|
267
+ |gpt-4o-transcribe|$2.50|$10.00|$0.006 / minute|
268
+ |gpt-4o-transcribe-diarize|$2.50|$10.00|$0.006 / minute|
269
+ |gpt-4o-mini-transcribe|$1.25|$5.00|$0.003 / minute|
270
+
271
+ #### Audio tokens
272
+
273
+ |Model|Input|Output|Estimated cost|
274
+ |---|---|---|---|
275
+ |gpt-4o-mini-tts|-|$12.00|$0.015 / minute|
276
+ |gpt-4o-transcribe|$6.00|-|$0.006 / minute|
277
+ |gpt-4o-transcribe-diarize|$6.00|-|$0.006 / minute|
278
+ |gpt-4o-mini-transcribe|$3.00|-|$0.003 / minute|
279
+
280
+ #### Other models
281
+
282
+ |Model|Use case|Cost|
283
+ |---|---|---|
284
+ |Whisper|Transcription|$0.006 / minute|
285
+ |TTS|Speech generation|$15.00 / 1M characters|
286
+ |TTS HD|Speech generation|$30.00 / 1M characters|
287
+
288
+
289
+
290
+ ###
291
+
292
+ Image generation
293
+
294
+ Prices per image.
295
+
296
+ |Model|Quality|1024 x 1024|1024 x 1536|1536 x 1024|
297
+ |---|---|---|---|---|
298
+ |GPT Image 1.5|Low|$0.009|$0.013|$0.013|
299
+ |Medium|$0.034|$0.05|$0.05|
300
+ |High|$0.133|$0.2|$0.2|
301
+ |GPT Image Latest|Low|$0.009|$0.013|$0.013|
302
+ |Medium|$0.034|$0.05|$0.05|
303
+ |High|$0.133|$0.2|$0.2|
304
+ |GPT Image 1|Low|$0.011|$0.016|$0.016|
305
+ |Medium|$0.042|$0.063|$0.063|
306
+ |High|$0.167|$0.25|$0.25|
307
+ |GPT Image 1 Mini|Low|$0.005|$0.006|$0.006|
308
+ |Medium|$0.011|$0.015|$0.015|
309
+ |High|$0.036|$0.052|$0.052|
310
+ ||
311
+ ||
312
+ |DALL·E 3|Standard|$0.04|$0.08|$0.08|
313
+ |HD|$0.08|$0.12|$0.12|
314
+ ||
315
+ ||
316
+ |DALL·E 2|Standard|$0.016|$0.018|$0.02|
317
+
318
+
319
+
320
+ ###
321
+
322
+ Embeddings
323
+
324
+ Prices per 1M tokens.
325
+
326
+ |Model|Cost|Batch cost|
327
+ |---|---|---|
328
+ |text-embedding-3-small|$0.02|$0.01|
329
+ |text-embedding-3-large|$0.13|$0.065|
330
+ |text-embedding-ada-002|$0.10|$0.05|
331
+
332
+
333
+
334
+ ### Moderation
335
+
336
+ Our `omni-moderation` models are made available free of charge ✌️
337
+
338
+
339
+
340
+ ###
341
+
342
+ Legacy models
343
+
344
+ Prices per 1M tokens.
345
+
346
+ Batch
347
+
348
+ |Model|Input|Output|
349
+ |---|---|---|
350
+ |gpt-4-turbo-2024-04-09|$5.00|$15.00|
351
+ |gpt-4-0125-preview|$5.00|$15.00|
352
+ |gpt-4-1106-preview|$5.00|$15.00|
353
+ |gpt-4-1106-vision-preview|$5.00|$15.00|
354
+ |gpt-4-0613|$15.00|$30.00|
355
+ |gpt-4-0314|$15.00|$30.00|
356
+ |gpt-4-32k|$30.00|$60.00|
357
+ |gpt-3.5-turbo-0125|$0.25|$0.75|
358
+ |gpt-3.5-turbo-1106|$1.00|$2.00|
359
+ |gpt-3.5-turbo-0613|$1.50|$2.00|
360
+ |gpt-3.5-0301|$1.50|$2.00|
361
+ |gpt-3.5-turbo-16k-0613|$1.50|$2.00|
362
+ |davinci-002|$1.00|$1.00|
363
+ |babbage-002|$0.20|$0.20|
364
+
365
+ Standard
366
+
367
+ |Model|Input|Output|
368
+ |---|---|---|
369
+ |chatgpt-4o-latest|$5.00|$15.00|
370
+ |gpt-4-turbo-2024-04-09|$10.00|$30.00|
371
+ |gpt-4-0125-preview|$10.00|$30.00|
372
+ |gpt-4-1106-preview|$10.00|$30.00|
373
+ |gpt-4-1106-vision-preview|$10.00|$30.00|
374
+ |gpt-4-0613|$30.00|$60.00|
375
+ |gpt-4-0314|$30.00|$60.00|
376
+ |gpt-4-32k|$60.00|$120.00|
377
+ |gpt-3.5-turbo|$0.50|$1.50|
378
+ |gpt-3.5-turbo-0125|$0.50|$1.50|
379
+ |gpt-3.5-turbo-1106|$1.00|$2.00|
380
+ |gpt-3.5-turbo-0613|$1.50|$2.00|
381
+ |gpt-3.5-0301|$1.50|$2.00|
382
+ |gpt-3.5-turbo-instruct|$1.50|$2.00|
383
+ |gpt-3.5-turbo-16k-0613|$3.00|$4.00|
384
+ |davinci-002|$2.00|$2.00|
385
+ |babbage-002|$0.40|$0.40|