Zum Hauptinhalt springen
POST
/
x402
/
top-up
/api/v1/x402/top-up
curl --request POST \
  --url https://api.venice.ai/api/v1/x402/top-up \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{}'
import requests

url = "https://api.venice.ai/api/v1/x402/top-up"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({})
};

fetch('https://api.venice.ai/api/v1/x402/top-up', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.venice.ai/api/v1/x402/top-up",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.venice.ai/api/v1/x402/top-up"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.venice.ai/api/v1/x402/top-up")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.venice.ai/api/v1/x402/top-up")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
{
  "success": true,
  "data": {
    "walletAddress": "0xyour_wallet_address",
    "amountCredited": 10,
    "newBalance": 22.5,
    "paymentId": "payment_01HZY8M4W4Y6QZ8B6Q4P0V3J2K"
  }
}
{
  "error": "X402_INVALID_PAYMENT",
  "message": "Invalid payment header",
  "details": {
    "reason": "signature_mismatch"
  }
}
{
  "x402Version": 2,
  "accepts": [
    {
      "scheme": "exact",
      "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
      "amount": "5000000",
      "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "payTo": "8qUL23aSj7mDWdoLMXGHFvnVCT9wd7jXcysiekroADEL",
      "maxTimeoutSeconds": 300,
      "extra": {
        "name": "USD Coin",
        "version": "2",
        "feePayer": "BFK9TLC3edb13K6v4YyH3DwPb5DSUpkWvb7XnqCL9b4F"
      }
    }
  ]
}
{
  "error": "<string>"
}
{
  "error": "X402_INVALID_PAYMENT",
  "message": "Invalid payment header",
  "details": {
    "reason": "signature_mismatch"
  }
}

Autorisierungen

Authorization
string
header
erforderlich

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Header

PAYMENT-SIGNATURE
string

Signed x402 v2 payment payload (base64-encoded PaymentPayload) used to top up the wallet balance on a supported rail such as Base or Solana. The canonical header is PAYMENT-SIGNATURE; the X-402-Payment and X-PAYMENT names are also accepted for backwards compatibility. If no payment header is present, the endpoint returns the 402 payment requirements.

Beispiel:

"eyJ4NDAyVmVyc2lvbiI6MiwicGF5bG9hZCI6Ii4uLiJ9"

Body

application/json

No JSON body required. Payment is sent via the X-402-Payment header. Send an empty POST to discover payment requirements.

The body is of type object.

Antwort

Top-up completed successfully.

success
enum<boolean>
erforderlich
Verfügbare Optionen:
true
data
object
erforderlich