Documentation
¶
Overview ¶
Package payment implements the x402 micropayment protocol for DOSRouter. x402 enables pay-per-request LLM access without API keys or accounts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatPaymentInfo ¶
func FormatPaymentInfo(pr PaymentRequired) string
FormatPaymentInfo returns a human-readable payment summary.
func IsPaymentRequired ¶
IsPaymentRequired checks if a response is a 402 payment required.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles x402 payment flows.
func (*Client) HandlePaymentRequired ¶
func (c *Client) HandlePaymentRequired(resp *http.Response, originalReq *http.Request, model string) (*PaymentResult, error)
HandlePaymentRequired processes a 402 response by signing and submitting payment.
type PaymentRequired ¶
type PaymentRequired struct {
Amount float64 `json:"amount"`
Currency string `json:"currency"`
PayTo string `json:"payTo"`
Network string `json:"network"`
Description string `json:"description"`
ExpiresAt string `json:"expiresAt,omitempty"`
PaymentToken string `json:"paymentToken,omitempty"` // Token to include after payment
}
PaymentRequired represents a 402 response from the upstream server.
Click to show internal directories.
Click to hide internal directories.