### Quick start Source: https://docs.x402layer.cc/cloud/sdk/python A basic example demonstrating how to initialize the `GridClient` and fetch capacity and model information. ```APIDOC ## Quick start ```python from singularity_grid import GridClient grid = GridClient() # public endpoints — no auth cap = grid.capacity() print(f"Active nodes: {cap.active_nodes}/{cap.total_nodes}") for m in grid.models(): print(f" {m.id} — {m.sgl_node_count} nodes") ``` ``` -------------------------------- ### Quick start Source: https://docs.x402layer.cc/cloud/sdk/typescript A basic example demonstrating how to initialize the GridClient and make a chat completion request. ```APIDOC ## Quick start ```typescript import { GridClient } from "@singularity-layer/grid"; const grid = new GridClient(); // public reads need no key const res = await grid.chatCompletions({ model: "", // see grid.models() messages: [{ role: "user", content: "What is confidential compute?" }], }); console.log(res.choices[0].message.content); ``` ``` -------------------------------- ### OpenWallet (OWS) Setup and Payment Source: https://docs.x402layer.cc/agentic-access/openclaw-skill Install the OpenWallet standard and configure it as a local wallet backend. Use the CLI to make payments via a URL. ```bash npm install -g @open-wallet-standard/core export OWS_WALLET="hackathon-wallet" python scripts/ows_cli.py pay-url https://api.x402layer.cc/e/weather-data --wallet hackathon-wallet ``` -------------------------------- ### Install x402-compute Skill Source: https://docs.x402layer.cc/cloud/provide/node-setup Install the x402-compute skill to have an agent manage the node setup process automatically. Alternatively, use the curl command to install. ```bash npx skills add https://github.com/ivaavimusic/singularity-skill --skill x402-compute ``` ```bash # or: curl -fsSL https://api.x402layer.cc/skill/x402-compute/install | bash ``` -------------------------------- ### Install Singularity Grid SDK Source: https://docs.x402layer.cc/cloud/sdk/python Install the core SDK using pip. Optionally, install the OpenAI compatibility helper. ```bash pip install singularity-grid # OpenAI compatibility helper: pip install "singularity-grid[openai]" ``` -------------------------------- ### Install x402-compute Skill using ClawHub Source: https://docs.x402layer.cc/agentic-access/x402-compute Install the x402-compute skill using ClawHub. Supports installation via npx, pnpm, or bunx. ```bash npx clawhub@latest install x402-compute ``` ```bash pnpm dlx clawhub@latest install x402-compute ``` ```bash bunx clawhub@latest install x402-compute ``` -------------------------------- ### Install Python SDK Source: https://docs.x402layer.cc/cloud/resources Install the Singularity Grid client for Python using pip. The OpenAI helper can be installed with an extra. ```bash pip install singularity-grid ``` ```bash # OpenAI helper: pip install "singularity-grid[openai]" ``` -------------------------------- ### Install TypeScript SDK Source: https://docs.x402layer.cc/cloud/resources Install the Singularity Grid client for JavaScript and TypeScript using npm. ```bash npm install @singularity-layer/grid ``` -------------------------------- ### Example GGUF Model Path Source: https://docs.x402layer.cc/cloud/provide/node-setup This is an example path to a local GGUF model file required for serving. ```bash # example: a small instruct model ~/models/Llama-3.2-3B-Instruct-Q4_K_M.gguf ``` -------------------------------- ### Install Python SDK Source: https://docs.x402layer.cc/cloud/sdk/overview Install the official Python SDK for the Singularity Cloud Network using pip. Add '[openai]' for the OpenAI helper. ```bash pip install singularity-grid # add [openai] for the OpenAI helper ``` -------------------------------- ### Install Node as a Service Source: https://docs.x402layer.cc/cloud/provide/node-setup Install the node as a background service for production environments. This ensures the node remains operational through reboots, logouts, and system sleep. ```bash sgl service install \ --model-path ~/models/Llama-3.2-3B-Instruct-Q4_K_M.gguf \ --model-name llama-3.2-3b \ --resource-percent 50 ``` -------------------------------- ### Install x402-compute Skill using Hosted One-liner Source: https://docs.x402layer.cc/agentic-access/x402-compute Install the latest version of the x402-compute skill with a single curl command. This method fetches the script directly from the gateway's compute skill handler. ```bash curl -fsSL https://api.x402layer.cc/skill/x402-compute/install | bash ``` -------------------------------- ### Install @singularity-layer/grid SDK Source: https://docs.x402layer.cc/cloud/sdk/typescript Install the official TypeScript/JavaScript client for SGL Grid using npm, pnpm, or yarn. ```bash npm install @singularity-layer/grid # pnpm add @singularity-layer/grid · yarn add @singularity-layer/grid ``` -------------------------------- ### Install Python Grid SDK Source: https://docs.x402layer.cc/sdks Install the Python SDK for SGL Grid inference clients. Use this for interacting with decentralized confidential inference services. ```bash pip install singularity-grid ``` -------------------------------- ### Example Endpoint URL with Slug Source: https://docs.x402layer.cc/agentic-access/introduction Provides a concrete example of a full endpoint URL when the slug is 'my-api'. ```url https://api.x402layer.cc/e/my-api ``` -------------------------------- ### Typical First Run with sgl CLI Source: https://docs.x402layer.cc/cloud/provide/cli This sequence of commands logs in, attests hardware, and installs the sgl service to run inference with a specified model. Ensure you have installed sgl and have a local inference runtime and GGUF model file. ```bash sgl login # browser-approve with your staked wallet sgl attest # produce + submit the hardware attestation sgl service install \ # run as a background service, serving a model --model-path ~/models/Llama-3.2-3B-Instruct-Q4_K_M.gguf \ --model-name llama-3.2-3b \ --resource-percent 50 ``` -------------------------------- ### Install singularity-grid Source: https://docs.x402layer.cc/cloud/sdk/python Install the `singularity-grid` Python package. An optional helper for OpenAI compatibility can also be installed. ```APIDOC ## Install ```bash pip install singularity-grid # OpenAI compatibility helper: pip install "singularity-grid[openai]" ``` ``` -------------------------------- ### Create Campaign Response Example Source: https://docs.x402layer.cc/fundraisers/api-reference An example JSON response upon successful creation of a campaign. ```JSON { "success": true, "campaign": { "id": "uuid", "slug": "my-campaign-a1b2c3d4", "title": "My Campaign", "url": "https://studio.x402layer.cc/fundraisers/my-campaign-a1b2c3d4", "endpoint_slug": "fund-my-campaign-a1b2c3d4" } } ``` -------------------------------- ### Verify sgl CLI Installation Source: https://docs.x402layer.cc/cloud/provide/node-setup Check if the sgl command-line interface has been installed correctly by running the help command. ```bash sgl --help ``` -------------------------------- ### Browse the Marketplace Source: https://docs.x402layer.cc/agentic-access/openclaw-skill Examples for discovering services on the marketplace, including listing all services, searching by keyword, and retrieving featured endpoints. ```bash # List all services python scripts/discover_marketplace.py # Search by keyword python scripts/discover_marketplace.py search weather # Get featured endpoints python scripts/discover_marketplace.py featured ``` -------------------------------- ### Install Singularity Skill Source: https://docs.x402layer.cc/agentic-access/singularity-skill Use this command to add the Singularity Skill to your project. Ensure you have npx installed. ```bash npx skills add https://github.com/ivaavimusic/singularity-skill --skill singularity ``` -------------------------------- ### Install OpenCLaw Skill via Curl Source: https://docs.x402layer.cc/agentic-access/openclaw-skill Use this command to install the skill directly from the self-hosted endpoint. You can specify a custom directory for installation. ```bash # One-line installer (recommended) curl -fsSL https://api.x402layer.cc/skill/x402-layer/install | bash ``` ```bash # Or specify a custom directory curl -fsSL https://api.x402layer.cc/skill/x402-layer/install | bash -s ./my-skills/x402-layer ``` -------------------------------- ### Install OpenCLaw Skill via Git Clone Source: https://docs.x402layer.cc/agentic-access/openclaw-skill Clone the skill repository from GitHub and install its dependencies using pip. ```bash git clone https://github.com/ivaavimusic/x402-Layer-Clawhub-Skill.git cd x402-Layer-Clawhub-Skill/scripts pip install -r ../requirements.txt ``` -------------------------------- ### Install @singularity-layer/grid Source: https://docs.x402layer.cc/cloud/sdk/typescript Install the official TypeScript/JavaScript client for SGL Grid using npm, pnpm, or yarn. ```APIDOC ## Install @singularity-layer/grid ```bash npm install @singularity-layer/grid # pnpm add @singularity-layer/grid · yarn add @singularity-layer/grid ``` ``` -------------------------------- ### Digital Product Purchase Response Example Source: https://docs.x402layer.cc/agentic-access/pay-per-request Example of a successful 200 OK response when paying for a digital product, including product details and a content download link. ```json // 200 OK { "product": { "id": "...", "name": "Ebook.pdf" }, "content": "https://download-link..." } ``` -------------------------------- ### Example Prompts for Singularity Skill Source: https://docs.x402layer.cc/agentic-access/singularity-skill A list of example prompts demonstrating various functionalities of the Singularity Skill, such as payment integration, endpoint creation, and identity management. ```text Integrate crypto payments into my app with x402 Create a paid endpoint and connect it to my API Set up webhook fulfillment and verify receipts Pay for an endpoint with AgentKit enabled Open a support thread and send an XMTP support message Use my dashboard PAT to manage my endpoints through MCP Use my owner-linked X-API-Key to create or update fundraiser campaigns Use OpenWallet / OWS to pay for an endpoint without exporting a raw key Buy credits for an endpoint and consume them Register my agent on ERC-8004 and bind my endpoint ``` -------------------------------- ### Create Campaign Request Example Source: https://docs.x402layer.cc/api-reference/fundraiser-campaigns-create This example demonstrates how to construct a request body to create a new fundraiser campaign. Ensure you include all required fields such as title, wallet_address, and target_amount. The target_amount must be at least 1000 USDC. ```json { "title": "Help us build a new community center!", "description": "All donations will go towards building a new community center for our neighborhood.", "wallet_address": "3wJz34567890abcdefghijklmnopqrstuvwxyza", "target_amount": 50000, "token_ticker": "USDC", "fee_option": "split", "fee_split_pct": 10, "images": [ "https://example.com/image1.jpg", "https://example.com/image2.png" ] } ``` -------------------------------- ### Install Node.js Payments SDK Source: https://docs.x402layer.cc/sdks Install the Node.js SDK for the Singularity Payments service. This SDK is used to verify x402 payment receipts (signed JWTs) server-side. ```bash npm install x402sgl ``` -------------------------------- ### Start Node in Foreground Source: https://docs.x402layer.cc/cloud/provide/node-setup Run the node in the foreground for testing purposes. This allows you to observe its behavior before deploying it as a service. ```bash sgl start --model-path ~/models/Llama-3.2-3B-Instruct-Q4_K_M.gguf --model-name llama-3.2-3b ``` -------------------------------- ### Pay for an Endpoint Source: https://docs.x402layer.cc/agentic-access/openclaw-skill Examples for paying for an endpoint using either the Base cryptocurrency or Solana. ```bash # Pay with Base (recommended default) python scripts/pay_base.py https://api.x402layer.cc/e/weather-data # Pay with Solana (PayAI-backed sponsored flow) python scripts/pay_solana.py https://api.x402layer.cc/e/weather-data ``` -------------------------------- ### Example Credit Balance Response Source: https://docs.x402layer.cc/agentic-access/credit-based A successful response for checking credit balance includes the available credits and the endpoint slug. ```json { "credits": 4500, "endpoint": "target-endpoint-slug" } ``` -------------------------------- ### Quick Start with Singularity Grid Client Source: https://docs.x402layer.cc/cloud/sdk/python Initialize the GridClient and fetch basic information like active nodes and available models. ```python from singularity_grid import GridClient grid = GridClient() # public endpoints — no auth cap = grid.capacity() print(f"Active nodes: {cap.active_nodes}/{cap.total_nodes}") for m in grid.models(): print(f" {m.id} — {m.sgl_node_count} nodes") ``` -------------------------------- ### Discovery (no auth) Source: https://docs.x402layer.cc/cloud/sdk/typescript Examples of how to fetch capacity, available models, and pricing information without authentication. ```APIDOC ## Discovery (no auth) ```typescript const cap = await grid.capacity(); console.log(`${cap.active_nodes} nodes online`); const models = await grid.models(); models.forEach((m) => console.log(`${m.id} — ${m.sgl_node_count} nodes`)); const pricing = await grid.pricing(); pricing.forEach((p) => console.log(`${p.model}: $${p.price_per_1k_input_tokens_usd}/1k input`)); ``` ``` -------------------------------- ### OpenAI-Compatible Client Setup Source: https://docs.x402layer.cc/cloud/sdk/python Configure an OpenAI-compatible client using either a direct base URL or the `create_openai_client` helper function. ```python # Direct from openai import OpenAI client = OpenAI(base_url="https://grid.x402compute.cc/v1", api_key="scg_your_api_key") # Or via the bundled helper (no need to copy the URL) from singularity_grid import create_openai_client client = create_openai_client(api_key="scg_your_api_key") resp = client.chat.completions.create( model="", messages=[{"role": "user", "content": "Hello from the grid"}], ) print(resp.choices[0].message.content) ``` -------------------------------- ### Deploy a Machine Source: https://docs.x402layer.cc/llms.txt Launches a cloud instance. ```APIDOC ## POST /api/machines ### Description Launches a cloud instance in minutes. Pick a plan, add an SSH key, and pay per hour. ### Method POST ### Endpoint /api/machines ### Parameters #### Request Body - **plan_id** (string) - Required - The ID of the machine plan. - **ssh_key** (string) - Required - The SSH public key for accessing the machine. - **region** (string) - Optional - The desired region for the machine deployment. ``` -------------------------------- ### Quickstart with cURL Source: https://docs.x402layer.cc/cloud/grid/api Make a chat completion request to the SGL Grid API using cURL. Ensure you replace `` with your SGL Grid API key and `` with a valid model identifier. ```bash curl https://grid.x402compute.cc/v1/chat/completions \ -H "X-API-Key: " \ -H "Content-Type: application/json" \ -d '{ "model": "", "messages": [{"role": "user", "content": "Explain confidential compute in one line."}] }' ``` -------------------------------- ### Recent Contributions Example Source: https://docs.x402layer.cc/fundraisers/api-reference An example JSON response for recent contributions. ```JSON { "contributions": [ { "who": "Alice", "amount": 500, "campaign": "My Campaign", "at": "2026-05-02T10:00:00Z" } ] } ``` -------------------------------- ### Install x402-compute Skill using npx Source: https://docs.x402layer.cc/agentic-access/x402-compute Use this command to add the x402-compute skill from its GitHub repository. This method is compatible with various AI code assistants. ```bash npx skills add https://github.com/ivaavimusic/singularity-skill --skill x402-compute ``` -------------------------------- ### Environment Setup for Base and Solana Source: https://docs.x402layer.cc/agentic-access/openclaw-skill Configure environment variables for wallet addresses and private keys. Read-only discovery does not require secrets. ```bash # Read-only discovery needs no secrets python scripts/discover_marketplace.py # For Base (EVM) - Recommended export PRIVATE_KEY="0x..." export WALLET_ADDRESS="0x..." # For Solana (Optional) export SOLANA_SECRET_KEY="base58-or-[1,2,3,...]" # base58 secret or JSON array ``` -------------------------------- ### API Call Response Example Source: https://docs.x402layer.cc/agentic-access/pay-per-request Example of a successful 200 OK response when paying for an API call, containing the actual API data. ```json // 200 OK { "result": "Analysis complete", "confidence": 0.98, "data": { ... } } ``` -------------------------------- ### Quick start with GridClient Source: https://docs.x402layer.cc/cloud/sdk/typescript Initialize the GridClient and make a basic chat completion request. Public reads do not require an API key. ```typescript import { GridClient } from "@singularity-layer/grid"; const grid = new GridClient(); // public reads need no key const res = await grid.chatCompletions({ model: "", // see grid.models() messages: [{ role: "user", content: "What is confidential compute?" }], }); console.log(res.choices[0].message.content); ``` -------------------------------- ### Browse Compute Plans Source: https://docs.x402layer.cc/cloud/machines/catalog Use this command to fetch a list of available compute plans. The catalog includes details on vCPU, RAM, and storage. ```bash # Plans curl https://grid.x402compute.cc/compute/plans ``` -------------------------------- ### OpenAI-compatible usage Source: https://docs.x402layer.cc/cloud/sdk/python Demonstrates how to use the SDK for OpenAI-compatible API calls, either directly or via a helper function. ```APIDOC ## OpenAI-compatible usage ```python # Direct from openai import OpenAI client = OpenAI(base_url="https://grid.x402compute.cc/v1", api_key="scg_your_api_key") # Or via the bundled helper (no need to copy the URL) from singularity_grid import create_openai_client client = create_openai_client(api_key="scg_your_api_key") resp = client.chat.completions.create( model="", messages=[{"role": "user", "content": "Hello from the grid"}], ) print(resp.choices[0].message.content) ``` ``` -------------------------------- ### Create and Manage a Paid Endpoint Source: https://docs.x402layer.cc/agentic-access/openclaw-skill Steps to create a paid endpoint, set up webhook fulfillment, and verify payment signatures server-side. ```bash # 1. Create or reuse a paid endpoint python scripts/create_endpoint.py my-api "My AI Service" https://api.example.com 0.01 # 2. Add webhook-based fulfillment python scripts/manage_webhook.py set my-api https://my-server.com/webhook # 3. Verify the webhook signature + receipt server-side python scripts/verify_webhook_payment.py \ --body-file ./webhook.json \ --signature 't=1700000000,v1=' \ --secret '' \ --required-source-slug my-api \ --require-receipt ``` -------------------------------- ### Install Python Payments SDK Source: https://docs.x402layer.cc/sdks Install the Python SDK for the Singularity Payments service. This SDK is used to verify x402 payment receipts (signed JWTs) server-side. ```bash pip install git+https://github.com/ivaavimusic/Singularity-SDK.git#subdirectory=python ``` -------------------------------- ### Provision AI Machine (Initial 402 Challenge) Source: https://docs.x402layer.cc/cloud/machines/ai-machines Initiate AI machine provisioning by calling the provision endpoint without payment. This will return a 402 Payment Required response with a payment challenge. ```bash curl -i -X POST https://compute.x402layer.cc/compute/provision \ -H "Content-Type: application/json" \ -d '{ "plan": "", "region": "", "os_id": , "prepaid_hours": 720, "network": "base", "ai_machine": { "model_id": "", "mode": "private" } }' ``` -------------------------------- ### OpenAPI Specification for GET /agent/endpoints Source: https://docs.x402layer.cc/api-reference/agent-endpoints-list This OpenAPI 3.1.0 specification defines the GET /agent/endpoints path for retrieving agent endpoint status. It requires a 'slug' query parameter. ```yaml GET /agent/endpoints openapi: 3.1.0 info: title: x402 Singularity Layer API description: >- OpenAPI-backed reference for marketplace discovery, payment routes, webhooks, wallet-first auth, agent endpoints, and ERC-8004 flows. version: 1.0.0 servers: - url: https://api.x402layer.cc security: [] tags: - name: Marketplace description: Public discovery and listing lookup - name: Public Endpoints description: Public endpoint metadata and hosted checkout context - name: Public Payment Links description: Hosted public payment-link lookup - name: Payments description: Hosted x402 payment challenge routes - name: Receipts description: Signed receipt lookup and verification helpers - name: Ratings description: Public listing ratings and authenticated rating actions - name: Webhooks description: Seller webhook management API - name: Agent Auth description: Wallet-first challenge and verification routes - name: Agent Endpoints description: Create, read, top up, and delete agent endpoints - name: ERC-8004 description: Agent registry and registration lifecycle routes - name: Marketplace Agents description: Public ERC-8004 marketplace discovery routes - name: Compute Catalog description: Compute plans, regions, and OS catalog - name: Compute Instances description: Provision, inspect, extend, and destroy compute instances - name: Compute API Keys description: API keys for compute agent access - name: Fundraiser Campaigns description: List, view, create, and edit fundraiser campaigns - name: Fundraiser Contributions description: Record and list campaign contributions - name: Fundraiser Comments description: Campaign comment threads - name: Fundraiser Media description: Campaign image uploads and OG images - name: Enterprise description: >- Enterprise partner configuration, endpoint listing, revenue stats, and transaction ledger - name: Staking description: Agentic $SGL staking - name: SGL Grid description: >- Decentralized, confidential, OpenAI-compatible inference served by attested TEE nodes. - name: Compute Credits description: Prepaid USDC credit balance shared across Machines and Grid. paths: /agent/endpoints: get: tags: - Agent Endpoints summary: Get agent endpoint status parameters: - name: slug in: query required: true schema: type: string responses: '200': description: Endpoint status ``` -------------------------------- ### Launch Fundraiser with Minimal Details Source: https://docs.x402layer.cc/fundraisers/sglbot Use this format for a minimal launch. The bot will reply asking for the remaining details if any are missing. ```text @SGLBot launch a fundraiser for @musician ``` -------------------------------- ### GET /grid/rewards/claimable OpenAPI Specification Source: https://docs.x402layer.cc/api-reference/grid-rewards-claimable This OpenAPI 3.1.0 specification defines the GET /grid/rewards/claimable endpoint. It includes details on parameters, responses, and data schemas for querying operator claimable rewards. ```yaml openapi: 3.1.0 info: title: x402 Singularity Layer API description: >- OpenAPI-backed reference for marketplace discovery, payment routes, webhooks, wallet-first auth, agent endpoints, and ERC-8004 flows. version: 1.0.0 servers: - url: https://api.x402layer.cc security: [] tags: - name: Marketplace description: Public discovery and listing lookup - name: Public Endpoints description: Public endpoint metadata and hosted checkout context - name: Public Payment Links description: Hosted public payment-link lookup - name: Payments description: Hosted x402 payment challenge routes - name: Receipts description: Signed receipt lookup and verification helpers - name: Ratings description: Public listing ratings and authenticated rating actions - name: Webhooks description: Seller webhook management API - name: Agent Auth description: Wallet-first challenge and verification routes - name: Agent Endpoints description: Create, read, top up, and delete agent endpoints - name: ERC-8004 description: Agent registry and registration lifecycle routes - name: Marketplace Agents description: Public ERC-8004 marketplace discovery routes - name: Compute Catalog description: Compute plans, regions, and OS catalog - name: Compute Instances description: Provision, inspect, extend, and destroy compute instances - name: Compute API Keys description: API keys for compute agent access - name: Fundraiser Campaigns description: List, view, create, and edit fundraiser campaigns - name: Fundraiser Contributions description: Record and list campaign contributions - name: Fundraiser Comments description: Campaign comment threads - name: Fundraiser Media description: Campaign image uploads and OG images - name: Enterprise description: >- Enterprise partner configuration, endpoint listing, revenue stats, and transaction ledger - name: Staking description: Agentic $SGL staking - name: SGL Grid description: >- Decentralized, confidential, OpenAI-compatible inference served by attested TEE nodes. - name: Compute Credits description: Prepaid USDC credit balance shared across Machines and Grid. paths: /grid/rewards/claimable: servers: - url: https://grid.x402compute.cc get: tags: - SGL Grid summary: Operator claimable rewards description: >- Unclaimed on-chain Merkle reward epochs for an operator wallet (their 80% share). Read-only; safe to expose — claiming still requires the wallet to sign. Base58, never lowercased. parameters: - name: wallet in: query required: true schema: type: string example: 8d3o8mLHpBA13m2CtuPSCbu1gujwjotzQvz75xGcHH5U responses: '200': description: OK content: application/json: schema: type: object properties: wallet: type: string example: 8d3o8m…HH5U total_usd: type: number example: 0.0379 epochs: type: array items: type: object properties: epoch_id: type: integer example: 1 distributor: type: string description: Merkle distributor PDA. mint: type: string example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v description: Payout mint (USDC). amount_usd: type: number example: 0.0379 amount_base: type: integer example: 37919 description: Raw mint units (USDC 6dp). leaf_index: type: integer example: 3 proof: type: array items: type: string expires_at: type: string example: '2026-09-21T06:21:00Z' ``` -------------------------------- ### Browse OS Images Source: https://docs.x402layer.cc/cloud/machines/catalog Use this command to fetch a list of available OS images for deployment. Common Linux distributions are supported. ```bash # OS images curl https://grid.x402compute.cc/compute/os ``` -------------------------------- ### Get Compute Instance OpenAPI Specification Source: https://docs.x402layer.cc/api-reference/compute-instance-get This OpenAPI definition describes the GET /compute/instances/{id} endpoint for retrieving compute instance details. It specifies the request parameters and the expected response. ```yaml GET /compute/instances/{id} openapi: 3.1.0 info: title: x402 Singularity Layer API description: >- OpenAPI-backed reference for marketplace discovery, payment routes, webhooks, wallet-first auth, agent endpoints, and ERC-8004 flows. version: 1.0.0 servers: - url: https://api.x402layer.cc security: [] tags: - name: Marketplace description: Public discovery and listing lookup - name: Public Endpoints description: Public endpoint metadata and hosted checkout context - name: Public Payment Links description: Hosted public payment-link lookup - name: Payments description: Hosted x402 payment challenge routes - name: Receipts description: Signed receipt lookup and verification helpers - name: Ratings description: Public listing ratings and authenticated rating actions - name: Webhooks description: Seller webhook management API - name: Agent Auth description: Wallet-first challenge and verification routes - name: Agent Endpoints description: Create, read, top up, and delete agent endpoints - name: ERC-8004 description: Agent registry and registration lifecycle routes - name: Marketplace Agents description: Public ERC-8004 marketplace discovery routes - name: Compute Catalog description: Compute plans, regions, and OS catalog - name: Compute Instances description: Provision, inspect, extend, and destroy compute instances - name: Compute API Keys description: API keys for compute agent access - name: Fundraiser Campaigns description: List, view, create, and edit fundraiser campaigns - name: Fundraiser Contributions description: Record and list campaign contributions - name: Fundraiser Comments description: Campaign comment threads - name: Fundraiser Media description: Campaign image uploads and OG images - name: Enterprise description: >- Enterprise partner configuration, endpoint listing, revenue stats, and transaction ledger - name: Staking description: Agentic $SGL staking - name: SGL Grid description: >- Decentralized, confidential, OpenAI-compatible inference served by attested TEE nodes. - name: Compute Credits description: Prepaid USDC credit balance shared across Machines and Grid. paths: /compute/instances/{id}: servers: - url: https://compute.x402layer.cc get: tags: - Compute Instances summary: Get compute instance parameters: - name: id in: path required: true schema: type: string format: uuid responses: '200': description: Instance details ``` -------------------------------- ### Initiate Resource Request (Bash) Source: https://docs.x402layer.cc/agentic-access/pay-per-request The agent makes an initial request to access a resource or API endpoint without any payment headers. ```bash curl -X GET https://api.x402layer.cc/e/super-ai-trader ``` -------------------------------- ### GET /api/marketplace/agents/{id} OpenAPI Specification Source: https://docs.x402layer.cc/api-reference/marketplace-agent-get This OpenAPI 3.1.0 specification defines the GET /api/marketplace/agents/{id} endpoint for retrieving marketplace agent details. It outlines parameters, request methods, and possible responses. ```yaml GET /api/marketplace/agents/{id} openapi: 3.1.0 info: title: x402 Singularity Layer API description: >- OpenAPI-backed reference for marketplace discovery, payment routes, webhooks, wallet-first auth, agent endpoints, and ERC-8004 flows. version: 1.0.0 servers: - url: https://api.x402layer.cc security: [] tags: - name: Marketplace description: Public discovery and listing lookup - name: Public Endpoints description: Public endpoint metadata and hosted checkout context - name: Public Payment Links description: Hosted public payment-link lookup - name: Payments description: Hosted x402 payment challenge routes - name: Receipts description: Signed receipt lookup and verification helpers - name: Ratings description: Public listing ratings and authenticated rating actions - name: Webhooks description: Seller webhook management API - name: Agent Auth description: Wallet-first challenge and verification routes - name: Agent Endpoints description: Create, read, top up, and delete agent endpoints - name: ERC-8004 description: Agent registry and registration lifecycle routes - name: Marketplace Agents description: Public ERC-8004 marketplace discovery routes - name: Compute Catalog description: Compute plans, regions, and OS catalog - name: Compute Instances description: Provision, inspect, extend, and destroy compute instances - name: Compute API Keys description: API keys for compute agent access - name: Fundraiser Campaigns description: List, view, create, and edit fundraiser campaigns - name: Fundraiser Contributions description: Record and list campaign contributions - name: Fundraiser Comments description: Campaign comment threads - name: Fundraiser Media description: Campaign image uploads and OG images - name: Enterprise description: >- Enterprise partner configuration, endpoint listing, revenue stats, and transaction ledger - name: Staking description: Agentic $SGL staking - name: SGL Grid description: >- Decentralized, confidential, OpenAI-compatible inference served by attested TEE nodes. - name: Compute Credits description: Prepaid USDC credit balance shared across Machines and Grid. paths: /api/marketplace/agents/{id}: get: tags: - Marketplace Agents summary: Get a single public marketplace agent parameters: - name: id in: path required: true schema: type: string - name: network in: query schema: type: string - name: contract in: query schema: type: string responses: '200': description: Marketplace agent details '404': description: Agent not found ``` -------------------------------- ### Connect to Instance via SSH Source: https://docs.x402layer.cc/cloud/machines/deploy Use this command to SSH into your deployed instance using the root user and the instance's IP address. Ensure you have the correct private key associated with the public key added during deployment. ```bash ssh root@ ``` -------------------------------- ### GET /api/campaigns/contributions OpenAPI Specification Source: https://docs.x402layer.cc/api-reference/fundraiser-contributions-feed This OpenAPI specification defines the GET endpoint for retrieving recent contributions. It outlines the request method, tags, summary, and the structure of the successful response, including the schema for contributions. ```yaml GET /api/campaigns/contributions openapi: 3.1.0 info: title: x402 Singularity Layer API description: >- OpenAPI-backed reference for marketplace discovery, payment routes, webhooks, wallet-first auth, agent endpoints, and ERC-8004 flows. version: 1.0.0 servers: - url: https://api.x402layer.cc security: [] tags: - name: Marketplace description: Public discovery and listing lookup - name: Public Endpoints description: Public endpoint metadata and hosted checkout context - name: Public Payment Links description: Hosted public payment-link lookup - name: Payments description: Hosted x402 payment challenge routes - name: Receipts description: Signed receipt lookup and verification helpers - name: Ratings description: Public listing ratings and authenticated rating actions - name: Webhooks description: Seller webhook management API - name: Agent Auth description: Wallet-first challenge and verification routes - name: Agent Endpoints description: Create, read, top up, and delete agent endpoints - name: ERC-8004 description: Agent registry and registration lifecycle routes - name: Marketplace Agents description: Public ERC-8004 marketplace discovery routes - name: Compute Catalog description: Compute plans, regions, and OS catalog - name: Compute Instances description: Provision, inspect, extend, and destroy compute instances - name: Compute API Keys description: API keys for compute agent access - name: Fundraiser Campaigns description: List, view, create, and edit fundraiser campaigns - name: Fundraiser Contributions description: Record and list campaign contributions - name: Fundraiser Comments description: Campaign comment threads - name: Fundraiser Media description: Campaign image uploads and OG images - name: Enterprise description: >- Enterprise partner configuration, endpoint listing, revenue stats, and transaction ledger - name: Staking description: Agentic $SGL staking - name: SGL Grid description: >- Decentralized, confidential, OpenAI-compatible inference served by attested TEE nodes. - name: Compute Credits description: Prepaid USDC credit balance shared across Machines and Grid. paths: /api/campaigns/contributions: servers: - url: https://studio.x402layer.cc get: tags: - Fundraiser Contributions summary: Recent contributions feed description: >- Returns the 20 most recent contributions across all campaigns. Used for the live ticker display. responses: '200': description: Recent contributions content: application/json: schema: type: object properties: contributions: type: array items: type: object properties: who: type: string amount: type: number campaign: type: string at: type: string format: date-time ``` -------------------------------- ### Create a Monetized Endpoint Source: https://docs.x402layer.cc/agentic-access/openclaw-skill Deploy a new endpoint with a one-time fee and initial credits. Remember to save the API Key for securing your origin server. ```bash # Deploy a monetized endpoint ($1 one-time fee, includes 4,000 starting credits) python scripts/create_endpoint.py my-api "My AI Service" https://api.example.com 0.01 ``` -------------------------------- ### Get Compute Credit Balance Source: https://docs.x402layer.cc/api-reference/compute-credits-balance Use this OpenAPI definition to understand the GET /compute/credits/balance endpoint. It retrieves the prepaid USDC credit balance for the authenticated wallet. Authentication can be done via signature or an API key. ```yaml GET /compute/credits/balance openapi: 3.1.0 info: title: x402 Singularity Layer API description: >- OpenAPI-backed reference for marketplace discovery, payment routes, webhooks, wallet-first auth, agent endpoints, and ERC-8004 flows. version: 1.0.0 servers: - url: https://api.x402layer.cc security: [] tags: - name: Marketplace description: Public discovery and listing lookup - name: Public Endpoints description: Public endpoint metadata and hosted checkout context - name: Public Payment Links description: Hosted public payment-link lookup - name: Payments description: Hosted x402 payment challenge routes - name: Receipts description: Signed receipt lookup and verification helpers - name: Ratings description: Public listing ratings and authenticated rating actions - name: Webhooks description: Seller webhook management API - name: Agent Auth description: Wallet-first challenge and verification routes - name: Agent Endpoints description: Create, read, top up, and delete agent endpoints - name: ERC-8004 description: Agent registry and registration lifecycle routes - name: Marketplace Agents description: Public ERC-8004 marketplace discovery routes - name: Compute Catalog description: Compute plans, regions, and OS catalog - name: Compute Instances description: Provision, inspect, extend, and destroy compute instances - name: Compute API Keys description: API keys for compute agent access - name: Fundraiser Campaigns description: List, view, create, and edit fundraiser campaigns - name: Fundraiser Contributions description: Record and list campaign contributions - name: Fundraiser Comments description: Campaign comment threads - name: Fundraiser Media description: Campaign image uploads and OG images - name: Enterprise description: >- Enterprise partner configuration, endpoint listing, revenue stats, and transaction ledger - name: Staking description: Agentic $SGL staking - name: SGL Grid description: >- Decentralized, confidential, OpenAI-compatible inference served by attested TEE nodes. - name: Compute Credits description: Prepaid USDC credit balance shared across Machines and Grid. paths: /compute/credits/balance: servers: - url: https://compute.x402layer.cc get: tags: - Compute Credits summary: Get credit balance description: >- Prepaid USDC credit balance for the authenticated wallet. Requires signature auth (`X-Auth-*`) or an API key (`X-API-Key`). parameters: - name: X-API-Key in: header required: false schema: type: string example: x402c_... description: >- Compute/Grid API key (billed to prepaid credits). Omit to pay per request via x402 `X-Payment`. responses: '200': description: Balance content: application/json: schema: type: object properties: wallet: type: string balance: type: string example: '150.00' total_deposited: type: string example: '200.00' total_spent: type: string example: '50.00' ``` -------------------------------- ### Direct Node Initialization Source: https://docs.x402layer.cc/cloud/provide/node-setup Register the node directly using the init command with your staked wallet, bypassing the browser flow. Login is recommended. ```bash sgl init --wallet ``` -------------------------------- ### Prepare and Sign Solana Transaction Source: https://docs.x402layer.cc/agentic-access/pay-per-request This snippet demonstrates how to set compute unit limits and prices, transfer tokens, add instructions to a transaction, set the recent blockhash, sign the transaction with a keypair, and serialize it into a base64 string for x402. ```python ix1 = set_compute_unit_limit(200_000) ix2 = set_compute_unit_price(1_000) ix3 = transfer_checked( TransferCheckedParams( program_id=TOKEN_PROGRAM_ID, source=source_ata, mint=mint_pubkey, dest=dest_ata, owner=agent_keypair.pubkey(), amount=int(accept['maxAmountRequired']), decimals=6 ) ) tx = Transaction() tx.add(ix1, ix2, ix3) tx.recent_blockhash = client.get_latest_blockhash().value.blockhash tx.sign(agent_keypair) import base64 serialized = base64.b64encode(tx.serialize()).decode('utf-8') ``` -------------------------------- ### Get ERC-8004 Registry Source: https://docs.x402layer.cc/api-reference/erc8004-registry Retrieves information about the ERC-8004 registry. ```APIDOC ## GET /agent/erc8004/registry ### Description Retrieves information about the ERC-8004 registry. ### Method GET ### Endpoint /agent/erc8004/registry ### Responses #### Success Response (200) - description: Registry info ``` -------------------------------- ### Manage Endpoint Credits and Marketplace Listing Source: https://docs.x402layer.cc/agentic-access/openclaw-skill Commands to top up an endpoint with credits and list it on the marketplace with category and description. ```bash # Top up YOUR endpoint with credits python scripts/topup_endpoint.py my-api 10 # Add $10 worth # List on marketplace python scripts/list_on_marketplace.py my-api --category ai --description "AI-powered analysis" ``` -------------------------------- ### Get Public Endpoint Credit Packs - OpenAPI Spec Source: https://docs.x402layer.cc/api-reference/public-endpoint-credits This OpenAPI specification defines the GET /api/public/endpoints/{slug}/credits endpoint. It is used to retrieve available credit pack information for a specific public endpoint. Ensure the 'slug' parameter is correctly provided in the path. ```yaml GET /api/public/endpoints/{slug}/credits openapi: 3.1.0 info: title: x402 Singularity Layer API description: >- OpenAPI-backed reference for marketplace discovery, payment routes, webhooks, wallet-first auth, agent endpoints, and ERC-8004 flows. version: 1.0.0 servers: - url: https://api.x402layer.cc security: [] tags: - name: Marketplace description: Public discovery and listing lookup - name: Public Endpoints description: Public endpoint metadata and hosted checkout context - name: Public Payment Links description: Hosted public payment-link lookup - name: Payments description: Hosted x402 payment challenge routes - name: Receipts description: Signed receipt lookup and verification helpers - name: Ratings description: Public listing ratings and authenticated rating actions - name: Webhooks description: Seller webhook management API - name: Agent Auth description: Wallet-first challenge and verification routes - name: Agent Endpoints description: Create, read, top up, and delete agent endpoints - name: ERC-8004 description: Agent registry and registration lifecycle routes - name: Marketplace Agents description: Public ERC-8004 marketplace discovery routes - name: Compute Catalog description: Compute plans, regions, and OS catalog - name: Compute Instances description: Provision, inspect, extend, and destroy compute instances - name: Compute API Keys description: API keys for compute agent access - name: Fundraiser Campaigns description: List, view, create, and edit fundraiser campaigns - name: Fundraiser Contributions description: Record and list campaign contributions - name: Fundraiser Comments description: Campaign comment threads - name: Fundraiser Media description: Campaign image uploads and OG images - name: Enterprise description: >- Enterprise partner configuration, endpoint listing, revenue stats, and transaction ledger - name: Staking description: Agentic $SGL staking - name: SGL Grid description: >- Decentralized, confidential, OpenAI-compatible inference served by attested TEE nodes. - name: Compute Credits description: Prepaid USDC credit balance shared across Machines and Grid. paths: /api/public/endpoints/{slug}/credits: get: tags: - Public Endpoints summary: Get public credit packs for an endpoint parameters: - name: slug in: path required: true schema: type: string responses: '200': description: Endpoint credit pack information ```