Skip to content
developer · developer · openapi · pytest · testing · code-generation · api · requests · smoke-tests

OpenAPI pytest generator

Generate deterministic, syntax-validated pytest and requests smoke tests from a caller-supplied OpenAPI 3 document, with mutating operations disabled by default.

$0.1 USDCBase + Solanax402 v2POST
Pay $0.1 USDC and run in your browserView free result sampleDownload demo pytest

Endpoint

https://apiacre.com/v1/developer/openapi-test-generate

Send the JSON body below. An unpaid request returns HTTP 402 with a PAYMENT-REQUIRED header; an x402-compatible buyer signs the requirement and retries with PAYMENT-SIGNATURE.

Pay $0.1 USDC and run in your browser

Official Coinbase agent path

Coinbase Agentic Wallet can satisfy this x402 request in one command. Running it may pay automatically, so --max-amount is fixed to $0.1 USDC in atomic units. Copying the command does not install, authenticate, sign, or pay; review the request and use a separate low-value wallet before running it.

npx --yes awal@latest x402 pay https://apiacre.com/v1/developer/openapi-test-generate \
  -X POST \
  -d '{"document":"{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Widget API\",\"version\":\"1\"},\"servers\":[{\"url\":\"https://api.example.com\"}],\"paths\":{\"/health\":{\"get\":{\"operationId\":\"getHealth\",\"responses\":{\"200\":{\"description\":\"Healthy\"}}}},\"/widgets\":{\"post\":{\"operationId\":\"createWidget\",\"requestBody\":{\"required\":true,\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"required\":[\"name\"],\"properties\":{\"name\":{\"type\":\"string\",\"example\":\"Acre\"}}}}}},\"responses\":{\"201\":{\"description\":\"Created\"}}}}}}","format":"json","max_operations":25,"include_optional":false,"timeout_seconds":20}' \
  --max-amount 100000 \
  --json

Coinbase pay-for-service documentation · Buyer setup and wallet safety

Alternative third-party AgentCash commands

Run check first without payment. Its fetch command may automatically pay up to the exact listed price.

npx --yes agentcash@latest check https://apiacre.com/v1/developer/openapi-test-generate
npx --yes agentcash@latest fetch https://apiacre.com/v1/developer/openapi-test-generate \
  --method POST \
  --header 'content-type: application/json' \
  --body '{"document":"{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Widget API\",\"version\":\"1\"},\"servers\":[{\"url\":\"https://api.example.com\"}],\"paths\":{\"/health\":{\"get\":{\"operationId\":\"getHealth\",\"responses\":{\"200\":{\"description\":\"Healthy\"}}}},\"/widgets\":{\"post\":{\"operationId\":\"createWidget\",\"requestBody\":{\"required\":true,\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"required\":[\"name\"],\"properties\":{\"name\":{\"type\":\"string\",\"example\":\"Acre\"}}}}}},\"responses\":{\"201\":{\"description\":\"Created\"}}}}}}","format":"json","max_operations":25,"include_optional":false,"timeout_seconds":20}' \
  --payment-protocol x402 \
  --payment-network base \
  --max-amount 0.100

AgentCash CLI documentation

Input example

{
  "document": "{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Widget API\",\"version\":\"1\"},\"servers\":[{\"url\":\"https://api.example.com\"}],\"paths\":{\"/health\":{\"get\":{\"operationId\":\"getHealth\",\"responses\":{\"200\":{\"description\":\"Healthy\"}}}},\"/widgets\":{\"post\":{\"operationId\":\"createWidget\",\"requestBody\":{\"required\":true,\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"required\":[\"name\"],\"properties\":{\"name\":{\"type\":\"string\",\"example\":\"Acre\"}}}}}},\"responses\":{\"201\":{\"description\":\"Created\"}}}}}}",
  "format": "json",
  "max_operations": 25,
  "include_optional": false,
  "timeout_seconds": 20
}

Response shape

View free static sample JSON

{
  "request_id": "018f1f54-7f38-7ba2-8dc3-5f90272d9f1a",
  "service": "developer.openapi-test-generate",
  "version": "1",
  "data": {
    "documentSha256": "2f27879b24323466c5dbca7df9bf137561b826bd43c318b8642b92f04b17930d",
    "openapiVersion": "3.1.0",
    "apiTitle": "Widget API",
    "baseUrlDefault": "https://api.example.com",
    "operationCount": 2,
    "generatedTestCount": 2,
    "guardedMutationCount": 1,
    "truncated": false,
    "sourceFileName": "test_openapi_generated.py",
    "sourceSha256": "44d05573bd64ef63deb934c9bef7b1ed6c618e4093c9cc7eee8e3a55b12b0f26",
    "source": "\"\"\"Generated API smoke tests. Review targets and payloads before running.\"\"\"\n\nimport os\n\nimport pytest\nimport requests\n\nDEFAULT_BASE_URL = 'https://api.example.com'\nBASE_URL = os.environ.get(\"API_BASE_URL\", DEFAULT_BASE_URL).rstrip(\"/\")\nTIMEOUT_SECONDS = 20\n\n\ndef _require_base_url():\n    if not BASE_URL:\n        pytest.skip(\"Set API_BASE_URL to the API origin\")\n    return BASE_URL\n\n\ndef _headers(extra=None):\n    headers = dict(extra or {})\n    if token := os.environ.get('API_BEARER_TOKEN'):\n        headers[\"Authorization\"] = f\"Bearer {token}\"\n    if api_key := os.environ.get('API_KEY'):\n        headers[\"X-API-Key\"] = api_key\n    return headers\n\n\ndef test_gethealth():\n    base_url = _require_base_url()\n    response = requests.request('GET', base_url + '/health', headers=_headers({}), timeout=TIMEOUT_SECONDS)\n    assert response.status_code in [200]\n\[email protected](\n    os.environ.get(\"API_ALLOW_MUTATING_TESTS\") != \"1\",\n    reason=\"POST test disabled; set API_ALLOW_MUTATING_TESTS=1\",\n)\ndef test_createwidget():\n    base_url = _require_base_url()\n    response = requests.request('POST', base_url + '/widgets', headers=_headers({}), json={'name': 'Acre'}, timeout=TIMEOUT_SECONDS)\n    assert response.status_code in [201]\n",
    "operations": [
      {
        "operationId": "getHealth",
        "testName": "test_gethealth",
        "method": "GET",
        "path": "/health",
        "mutatingGuard": false,
        "documentedResponses": [
          "200"
        ]
      },
      {
        "operationId": "createWidget",
        "testName": "test_createwidget",
        "method": "POST",
        "path": "/widgets",
        "mutatingGuard": true,
        "documentedResponses": [
          "201"
        ]
      }
    ],
    "requirements": [
      "pytest>=8",
      "requests>=2.31"
    ],
    "environment": {
      "baseUrl": "API_BASE_URL",
      "bearerToken": "API_BEARER_TOKEN",
      "apiKey": "API_KEY",
      "allowMutatingTests": "API_ALLOW_MUTATING_TESTS"
    },
    "warnings": [],
    "execution": {
      "sourceSyntaxValidated": true,
      "generatedTestsExecuted": false,
      "networkRequestsMade": false
    }
  },
  "meta": {
    "duration_ms": 42,
    "cached": false,
    "sources": [],
    "warnings": [],
    "next_actions": [
      {
        "service": "developer.code-metrics",
        "title": "Code metrics",
        "reason": "Measure the generated pytest module's structure, complexity, syntax status, and maintainability signals before adding it to a test suite.",
        "method": "POST",
        "path": "/v1/developer/code-metrics",
        "price": "$0.025",
        "input_template": {
          "code": "$result.data.source",
          "language": "python"
        },
        "use_output": "Require result.data.source.sha256 to equal the generator's result.data.sourceSha256, then inspect syntax and reviewSignals before retaining the generated module.",
        "handoff_path": "/catalog/developer.code-metrics",
        "checkout_path": "/try/developer.code-metrics",
        "sample_path": "/samples/developer.code-metrics",
        "maximum_atomic_usdc": "25000",
        "handoff_payment_required": false,
        "executes_automatically": false,
        "authorization_required": true
      }
    ]
  }
}

Complete recipes using this API

These buyer-controlled recipes connect this service to compatible API Acre results. Every step has its own exact price and requires separate authorization.

Continue this workflow

These optional follow-ups use this result in a larger workflow. Each call shows a fresh x402 challenge and requires separate buyer authorization.

Try the payment challenge

curl -i -X POST 'https://apiacre.com/v1/developer/openapi-test-generate' \
  -H 'content-type: application/json' \
  --data '{"document":"{\"openapi\":\"3.1.0\",\"info\":{\"title\":\"Widget API\",\"version\":\"1\"},\"servers\":[{\"url\":\"https://api.example.com\"}],\"paths\":{\"/health\":{\"get\":{\"operationId\":\"getHealth\",\"responses\":{\"200\":{\"description\":\"Healthy\"}}}},\"/widgets\":{\"post\":{\"operationId\":\"createWidget\",\"requestBody\":{\"required\":true,\"content\":{\"application/json\":{\"schema\":{\"type\":\"object\",\"required\":[\"name\"],\"properties\":{\"name\":{\"type\":\"string\",\"example\":\"Acre\"}}}}}},\"responses\":{\"201\":{\"description\":\"Created\"}}}}}}","format":"json","max_operations":25,"include_optional":false,"timeout_seconds":20}'