pay-for-service

Make paid requests to x402-enabled APIs using USDC. Use when you or the user want to call a paid API, make an x402 payment, use a bazaar service, or pay for an API request. Covers phrases like "call this API", "use this service", "pay for the request", "make a paid call", "fetch from x402 endpoint".

3,891 stars
Complexity: medium

About this skill

The `pay-for-service` skill empowers AI agents to interact with and pay for external API services that utilize the x402 protocol. By executing the `npx awal@latest x402 pay` command, the agent can send requests to specified URLs, include HTTP methods, data payloads, query parameters, and custom headers, while automatically settling the required payment in USDC on the Base network. This abstracts the complexity of cryptocurrency transactions, making it straightforward for the agent to access premium or monetized functionalities. This capability is crucial for AI agents needing to leverage a wider ecosystem of services, including those offering premium data, specialized computations, or other value-added features that operate on a pay-per-use model. It ensures that the agent can autonomously proceed with tasks that involve financial transactions without requiring manual user intervention for each payment. The skill is designed to be used in conjunction with other skills, such as `search-for-service`, to first identify a suitable paid endpoint before making the actual request.

Best use case

The primary use case for `pay-for-service` is to allow AI agents to programmatically and autonomously pay for access to web3-enabled API services, specifically those adhering to the x402 payment protocol on the Base network. This benefits developers, researchers, or automated systems that require seamless integration with paid external services for tasks like data retrieval, specialized processing, or interaction with decentralized applications where a micro-payment model is in place. It eliminates the need for manual payment steps, enabling truly autonomous workflows for utilizing paid API resources.

Make paid requests to x402-enabled APIs using USDC. Use when you or the user want to call a paid API, make an x402 payment, use a bazaar service, or pay for an API request. Covers phrases like "call this API", "use this service", "pay for the request", "make a paid call", "fetch from x402 endpoint".

The skill will successfully execute the paid API request to the x402 endpoint, automatically handle the USDC payment, and return the API's response data to the AI agent.

Practical example

Example input

Use the `pay-for-service` skill to call the current weather data API at `https://api.weather-x402.com/current?city=London` with a GET request, allowing a maximum payment of 100000 atomic units ($0.10).

Example output

{"payment_status": "success", "amount_paid_usdc_atomic": 50000, "api_response": {"city": "London", "temperature_celsius": 12, "condition": "Cloudy", "timestamp": "2023-10-27T10:00:00Z"}}

When to use this skill

  • When the AI agent needs to access a third-party API that charges for its services.
  • When the target API endpoint uses the x402 payment protocol.
  • After a service requiring payment has been identified, potentially by a `search-for-service` skill.
  • When automatic USDC payment on the Base network is the required method for an API call.

When not to use this skill

  • When the API to be called is free or does not require any form of payment.
  • If the user's `awal` wallet is not initialized, authenticated, or lacks sufficient USDC on the Base network.
  • For internal or local operations that do not involve external paid services.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/agnicpay-pay-for-service/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/agnicpay-prog/agnicpay-pay-for-service/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/agnicpay-pay-for-service/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How pay-for-service Compares

Feature / Agentpay-for-serviceStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexitymediumN/A

Frequently Asked Questions

What does this skill do?

Make paid requests to x402-enabled APIs using USDC. Use when you or the user want to call a paid API, make an x402 payment, use a bazaar service, or pay for an API request. Covers phrases like "call this API", "use this service", "pay for the request", "make a paid call", "fetch from x402 endpoint".

How difficult is it to install?

The installation complexity is rated as medium. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Paying for x402 Services

Use the `npx agnic@latest x402 pay` command to call x402-enabled API endpoints with automatic USDC payment on Base.

## Confirm wallet is initialized and authed

```bash
npx agnic@latest status
```

If the wallet is not authenticated, refer to the `authenticate-wallet` skill.

## Command Syntax

```bash
npx agnic@latest x402 pay <url> [-X <method>] [-d <json>] [-q <params>] [-h <json>] [--max-amount <n>] [--json]
```

## Arguments & Options

| Option                  | Description                                        |
| ----------------------- | -------------------------------------------------- |
| `<url>`                 | Full URL of the x402-enabled API endpoint          |
| `-X, --method <method>` | HTTP method (default: GET)                         |
| `-d, --data <json>`     | Request body as JSON string                        |
| `-q, --query <params>`  | Query parameters as JSON string                    |
| `-h, --headers <json>`  | Custom HTTP headers as JSON string                 |
| `--max-amount <amount>` | Max payment in USDC atomic units (1000000 = $1.00) |
| `--correlation-id <id>` | Group related operations                           |
| `--json`                | Output as JSON                                     |

## USDC Amounts

X402 uses USDC atomic units (6 decimals):

| Atomic Units | USD   |
| ------------ | ----- |
| 1000000      | $1.00 |
| 100000       | $0.10 |
| 50000        | $0.05 |
| 10000        | $0.01 |

## Input Validation

Before constructing the command, validate:

- **url**: Must be a valid HTTPS URL (`^https://[^\s;|&]+$`). Reject URLs containing spaces, semicolons, pipes, or backticks.
- **method**: Must be one of GET, POST, PUT, DELETE, PATCH (case-insensitive).
- **data**: Must be valid JSON. Parse it first; reject if parsing fails.
- **max-amount**: Must be a positive integer (`^\d+$`).

Do not pass unvalidated user input into the command.

## Workflow

1. **Check requirements first** (optional but recommended):
   ```bash
   npx agnic@latest x402 details <url>
   ```
   This shows the price, method, and schema without making a payment.

2. **Verify balance**:
   ```bash
   npx agnic@latest balance --network base
   ```

3. **Make the paid request**:
   ```bash
   npx agnic@latest x402 pay <url> --json
   ```

## Examples

```bash
# Make a GET request (auto-pays)
npx agnic@latest x402 pay https://example.com/api/weather

# Make a POST request with body
npx agnic@latest x402 pay https://example.com/api/sentiment -X POST -d '{"text": "I love this product"}'

# Limit max payment to $0.10
npx agnic@latest x402 pay https://example.com/api/data --max-amount 100000

# Get JSON output
npx agnic@latest x402 pay https://example.com/api/weather --json
```

## Prerequisites

- Must be authenticated (`npx agnic@latest auth login`)
- Wallet must have sufficient USDC balance on Base

## Error Handling

Common errors:

- "Not authenticated" — Run `npx agnic@latest auth login` first
- "Insufficient balance" — Fund wallet with USDC (`npx agnic@latest balance` to check)
- "No X402 payment requirements found" — URL may not be an x402 endpoint
- Invalid JSON in `--data` — Ensure the body is valid JSON before passing
- HTTP 4xx/5xx from the API — Show the status code and response body to the user

Related Skills

search-for-service

3891
from openclaw/skills

Search and browse the x402 bazaar marketplace for paid API services. Use when you or the user want to find available services, see what's available, discover APIs, or need an external service to accomplish a task. Also use as a fallback when no other skill clearly matches — search the bazaar to see if a paid service exists. Covers "what can I do?", "find me an API for...", "what services are available?", "search for...", "browse the bazaar".

API Discovery & Integration

monetize-service

3891
from openclaw/skills

Build and deploy a paid API that other agents can pay to use via x402. Use when you or the user want to monetize an API, make money, earn money, offer a service, sell a service to other agents, charge for endpoints, create a paid endpoint, or set up a paid service. Covers "make money by offering an endpoint", "sell a service", "monetize your data", "create a paid API".

Monetization & Resource Management

setup-services

3891
from openclaw/skills

Set up OpenSpend CLI and optional Coinbase payments-mcp for payment-enabled workflows. Use when openspend is missing, command not found, whoami fails, or user asks to install/update/authenticate.

find-services

3891
from openclaw/skills

Find and shortlist third-party services using OpenSpend CLI marketplace search. Use when asked to discover providers for a capability, compare options, and return a justified recommendation for discovery tasks only.

ecommerce-customer-service-pro

3891
from openclaw/skills

行业可选的智能电商客服技能。用于售前咨询、售中跟进、催付催单、发货物流、售后处理、退款退换、投诉安抚、差评挽回、FAQ整理、达人与机构商务沟通等场景;先识别行业与场景,再输出全面、合规、可直接发送的话术与处理建议。

SLA Manager — Service Level Agreement Framework

3891
from openclaw/skills

You are a Service Level Agreement specialist. Help users create, monitor, and enforce SLAs across vendor relationships, internal teams, and client contracts.

---

3891
from openclaw/skills

name: article-factory-wechat

Content & Documentation

humanizer

3891
from openclaw/skills

Remove signs of AI-generated writing from text. Use when editing or reviewing text to make it sound more natural and human-written. Based on Wikipedia's comprehensive "Signs of AI writing" guide. Detects and fixes patterns including: inflated symbolism, promotional language, superficial -ing analyses, vague attributions, em dash overuse, rule of three, AI vocabulary words, negative parallelisms, and excessive conjunctive phrases.

Content & Documentation

find-skills

3891
from openclaw/skills

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

General Utilities

tavily-search

3891
from openclaw/skills

Use Tavily API for real-time web search and content extraction. Use when: user needs real-time web search results, research, or current information from the web. Requires Tavily API key.

Data & Research

baidu-search

3891
from openclaw/skills

Search the web using Baidu AI Search Engine (BDSE). Use for live information, documentation, or research topics.

Data & Research

agent-autonomy-kit

3891
from openclaw/skills

Stop waiting for prompts. Keep working.

Workflow & Productivity