{
  "openapi": "3.1.0",
  "info": {
    "title": "Spec Slice — OpenAPI & GraphQL Subgraph Extractor",
    "version": "1.0.0",
    "summary": "Shrink 200k-token OpenAPI 3.1 and GraphQL schemas by 90-99% into valid, cycle-safe mini-specs in <20ms.",
    "description": "Surgical OpenAPI 3.0/3.1, Swagger 2.0, and GraphQL SDL subgraph slicer for coding and tool-use agents. Ranks operations by BM25 intent + structural boosts and extracts the exact cycle-safe transitive closure of referenced schemas, parameters, unions, interfaces, inputs, and enums.\n\nEliminates context-window overflow on massive Stripe/GitHub/Shopify specs, avoids broken $ref pointers or infinite recursive schema loops, and saves $0.10-$0.50 in LLM input tokens for $0.001.",
    "contact": {
      "name": "API Keg",
      "url": "https://apikeg.com"
    }
  },
  "servers": [
    {
      "url": "https://spec-slice.apikeg.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Keg Key (ak_live_...)",
        "description": "Optional per-email monthly subscription API key ($5/$20/$50 tiers at https://apikeg.com/account). Omit this header to pay per request inline via HTTP 402 (x402 USDC)."
      }
    }
  },
  "security": [
    {},
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/slice-openapi-spec": {
      "post": {
        "operationId": "slice_openapi_spec",
        "summary": "Slice OpenAPI 3.0/3.1 or Swagger 2.0 Specification",
        "description": "Scores OpenAPI/Swagger endpoints against a natural-language `query` (BM25 + boosted `operationId`, `summary`, `tags`, and path tokens) or explicit `operationIds`/`pathPatterns`, walks every reachable JSON Pointer `$ref` with cycle protection, prunes unused paths/components, and emits ready-to-use `curl` + TypeScript `fetch` snippets. Why call instead of DIY: Saves 50,000-250,000 prompt tokens per large enterprise OpenAPI spec ($0.15+ LLM input cost) while guaranteeing zero broken `#/components/...` `$ref` links or recursive schema crashes. Pricing: $0.001 USD per OpenAPI/Swagger subgraph slice (x402 instant micropayment). Pass ?dry_run=true on REST to validate schema free.",
        "tags": [
          "developer-tools",
          "api-tooling",
          "context-compression",
          "agent-infrastructure"
        ],
        "externalDocs": {
          "description": "Slice OpenAPI 3.0/3.1 or Swagger 2.0 Specification Specification & Examples",
          "url": "https://spec-slice.apikeg.com/tools/slice-openapi-spec"
        },
        "x-x402": {
          "version": 2,
          "scheme": "exact",
          "priceUsd": "0.001",
          "amountAtomicUnits": "1000",
          "network": "eip155:8453",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "payTo": "0x000000000000000000000000000000000000dEaD",
          "extensions": {
            "bazaar": {
              "discoverable": true,
              "category": [
                "developer-tools",
                "api-tooling",
                "context-compression",
                "agent-infrastructure"
              ],
              "info": {
                "input": {
                  "type": "http",
                  "method": "POST",
                  "bodyType": "json",
                  "example": {
                    "query": "create credit note and refund invoice",
                    "maxOperations": 2,
                    "compactDescriptions": true,
                    "includeSnippets": true,
                    "spec": {
                      "openapi": "3.1.0",
                      "info": {
                        "title": "Billing API",
                        "version": "2.4.0"
                      },
                      "servers": [
                        {
                          "url": "https://api.billing.example.com"
                        }
                      ],
                      "paths": {
                        "/v1/invoices/{invoiceId}/refunds": {
                          "post": {
                            "operationId": "refundInvoice",
                            "summary": "Refund an invoice",
                            "tags": [
                              "Invoices"
                            ],
                            "requestBody": {
                              "content": {
                                "application/json": {
                                  "schema": {
                                    "$ref": "#/components/schemas/RefundRequest"
                                  }
                                }
                              }
                            },
                            "responses": {
                              "200": {
                                "description": "Refund created",
                                "content": {
                                  "application/json": {
                                    "schema": {
                                      "$ref": "#/components/schemas/Refund"
                                    }
                                  }
                                }
                              }
                            }
                          }
                        },
                        "/v1/warehouses": {
                          "get": {
                            "operationId": "listWarehouses",
                            "summary": "List inventory warehouses",
                            "responses": {
                              "200": {
                                "description": "OK",
                                "content": {
                                  "application/json": {
                                    "schema": {
                                      "$ref": "#/components/schemas/Warehouse"
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      },
                      "components": {
                        "schemas": {
                          "RefundRequest": {
                            "type": "object",
                            "required": [
                              "amountCents"
                            ],
                            "properties": {
                              "amountCents": {
                                "type": "integer"
                              }
                            }
                          },
                          "Refund": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string"
                              }
                            }
                          },
                          "Warehouse": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "location": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "output": {
                  "type": "json",
                  "summary": "Retains refundInvoice + RefundRequest + Refund, prunes listWarehouses + Warehouse, and emits curl + TypeScript fetch snippets."
                }
              },
              "schema": {
                "inputSchema": {
                  "type": "object",
                  "properties": {
                    "spec": {
                      "description": "OpenAPI 3.0/3.1 or Swagger 2.0 specification provided as either a parsed JSON object or a serialized JSON string (up to 5 MiB)."
                    },
                    "query": {
                      "type": "string",
                      "maxLength": 500,
                      "description": "Natural-language task intent (e.g. 'create credit note and refund invoice') scored via Okapi BM25 plus boosted matches on operationId, summary, tags, and path segments."
                    },
                    "operationIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "maxItems": 50,
                      "description": "Explicit operationId values to extract (case-insensitive)."
                    },
                    "pathPatterns": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 300
                      },
                      "maxItems": 50,
                      "description": "Explicit path templates or 'METHOD /v1/path/*' glob patterns to extract (e.g. 'POST /v1/invoices/*/refund')."
                    },
                    "methods": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "GET",
                          "POST",
                          "PUT",
                          "PATCH",
                          "DELETE",
                          "HEAD",
                          "OPTIONS",
                          "TRACE"
                        ]
                      },
                      "maxItems": 8,
                      "description": "Optional HTTP method allowlist."
                    },
                    "maxOperations": {
                      "type": "integer",
                      "default": 5,
                      "minimum": 1,
                      "maximum": 50,
                      "description": "Maximum number of matched operations to retain in the sliced OpenAPI spec."
                    },
                    "compactDescriptions": {
                      "type": "boolean",
                      "default": false,
                      "description": "Strip verbose prose descriptions, examples, and externalDocs while keeping spec-valid response descriptions."
                    },
                    "includeSnippets": {
                      "type": "boolean",
                      "default": true,
                      "description": "Generate ready-to-use curl and TypeScript fetch code snippets for each selected operation."
                    }
                  },
                  "required": [
                    "spec"
                  ],
                  "additionalProperties": false
                },
                "outputSchema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data",
                    "_meta"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "description": "Deterministic structured tool result payload."
                    },
                    "_meta": {
                      "type": "object",
                      "required": [
                        "requestId",
                        "durationMs",
                        "chargedUsd",
                        "dryRun"
                      ],
                      "properties": {
                        "requestId": {
                          "type": "string"
                        },
                        "durationMs": {
                          "type": "number"
                        },
                        "chargedUsd": {
                          "type": "string"
                        },
                        "dryRun": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "dry_run",
            "in": "query",
            "required": false,
            "description": "Validate request schema for free ($0.00) without executing or settling payment.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "spec": {
                    "description": "OpenAPI 3.0/3.1 or Swagger 2.0 specification provided as either a parsed JSON object or a serialized JSON string (up to 5 MiB)."
                  },
                  "query": {
                    "type": "string",
                    "maxLength": 500,
                    "description": "Natural-language task intent (e.g. 'create credit note and refund invoice') scored via Okapi BM25 plus boosted matches on operationId, summary, tags, and path segments."
                  },
                  "operationIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 50,
                    "description": "Explicit operationId values to extract (case-insensitive)."
                  },
                  "pathPatterns": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 300
                    },
                    "maxItems": 50,
                    "description": "Explicit path templates or 'METHOD /v1/path/*' glob patterns to extract (e.g. 'POST /v1/invoices/*/refund')."
                  },
                  "methods": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "GET",
                        "POST",
                        "PUT",
                        "PATCH",
                        "DELETE",
                        "HEAD",
                        "OPTIONS",
                        "TRACE"
                      ]
                    },
                    "maxItems": 8,
                    "description": "Optional HTTP method allowlist."
                  },
                  "maxOperations": {
                    "type": "integer",
                    "default": 5,
                    "minimum": 1,
                    "maximum": 50,
                    "description": "Maximum number of matched operations to retain in the sliced OpenAPI spec."
                  },
                  "compactDescriptions": {
                    "type": "boolean",
                    "default": false,
                    "description": "Strip verbose prose descriptions, examples, and externalDocs while keeping spec-valid response descriptions."
                  },
                  "includeSnippets": {
                    "type": "boolean",
                    "default": true,
                    "description": "Generate ready-to-use curl and TypeScript fetch code snippets for each selected operation."
                  }
                },
                "required": [
                  "spec"
                ],
                "additionalProperties": false
              },
              "example": {
                "query": "create credit note and refund invoice",
                "maxOperations": 2,
                "compactDescriptions": true,
                "includeSnippets": true,
                "spec": {
                  "openapi": "3.1.0",
                  "info": {
                    "title": "Billing API",
                    "version": "2.4.0"
                  },
                  "servers": [
                    {
                      "url": "https://api.billing.example.com"
                    }
                  ],
                  "paths": {
                    "/v1/invoices/{invoiceId}/refunds": {
                      "post": {
                        "operationId": "refundInvoice",
                        "summary": "Refund an invoice",
                        "tags": [
                          "Invoices"
                        ],
                        "requestBody": {
                          "content": {
                            "application/json": {
                              "schema": {
                                "$ref": "#/components/schemas/RefundRequest"
                              }
                            }
                          }
                        },
                        "responses": {
                          "200": {
                            "description": "Refund created",
                            "content": {
                              "application/json": {
                                "schema": {
                                  "$ref": "#/components/schemas/Refund"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "/v1/warehouses": {
                      "get": {
                        "operationId": "listWarehouses",
                        "summary": "List inventory warehouses",
                        "responses": {
                          "200": {
                            "description": "OK",
                            "content": {
                              "application/json": {
                                "schema": {
                                  "$ref": "#/components/schemas/Warehouse"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  },
                  "components": {
                    "schemas": {
                      "RefundRequest": {
                        "type": "object",
                        "required": [
                          "amountCents"
                        ],
                        "properties": {
                          "amountCents": {
                            "type": "integer"
                          }
                        }
                      },
                      "Refund": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          }
                        }
                      },
                      "Warehouse": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "location": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful execution result.",
            "headers": {
              "PAYMENT-RESPONSE": {
                "description": "Base64-encoded x402 v2 payment settlement receipt (when paid).",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object"
                    },
                    "_meta": {
                      "type": "object",
                      "properties": {
                        "requestId": {
                          "type": "string"
                        },
                        "durationMs": {
                          "type": "number"
                        },
                        "chargedUsd": {
                          "type": "string"
                        },
                        "dryRun": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Schema validation error (unbilled, $0.00)."
          },
          "402": {
            "description": "Payment Required. Decode the Base64 PAYMENT-REQUIRED header and retry with PAYMENT-SIGNATURE.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded x402 v2 PaymentRequired JSON object.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/slice-graphql-schema": {
      "post": {
        "operationId": "slice_graphql_schema",
        "summary": "Slice GraphQL SDL Schema to Minimal Subgraph",
        "description": "Parses GraphQL Schema Definition Language (`Query`, `Mutation`, `Subscription`, `type`, `input`, `interface`, `union`, `enum`, `scalar`), scores root fields against `query` or explicit `rootFields`, and emits a valid mini-SDL containing only selected root fields and the transitive closure of referenced types. Why call instead of DIY: Replaces heavyweight `graphql-js` AST bundlers on edge runtimes and shrinks 10,000-line federated GraphQL schemas into minimal, copy-pasteable mini-SDL + sample operations. Pricing: $0.001 USD per GraphQL SDL subgraph slice (x402 instant micropayment). Pass ?dry_run=true on REST to validate schema free.",
        "tags": [
          "developer-tools",
          "api-tooling",
          "context-compression",
          "agent-infrastructure"
        ],
        "externalDocs": {
          "description": "Slice GraphQL SDL Schema to Minimal Subgraph Specification & Examples",
          "url": "https://spec-slice.apikeg.com/tools/slice-graphql-schema"
        },
        "x-x402": {
          "version": 2,
          "scheme": "exact",
          "priceUsd": "0.001",
          "amountAtomicUnits": "1000",
          "network": "eip155:8453",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "payTo": "0x000000000000000000000000000000000000dEaD",
          "extensions": {
            "bazaar": {
              "discoverable": true,
              "category": [
                "developer-tools",
                "api-tooling",
                "context-compression",
                "agent-infrastructure"
              ],
              "info": {
                "input": {
                  "type": "http",
                  "method": "POST",
                  "bodyType": "json",
                  "example": {
                    "query": "issue credit note for invoice",
                    "maxRootFields": 2,
                    "compactDescriptions": true,
                    "sdl": "scalar DateTime\nenum CreditReason { DUPLICATE OVERCHARGE }\ninput IssueCreditNoteInput { invoiceId: ID! reason: CreditReason! }\ntype CreditNote { id: ID! issuedAt: DateTime! }\ntype Warehouse { id: ID! code: String! }\ntype Query { warehouses: [Warehouse!]! }\ntype Mutation { issueCreditNote(input: IssueCreditNoteInput!): CreditNote! }"
                  }
                },
                "output": {
                  "type": "json",
                  "summary": "Emits mini-SDL with DateTime, CreditReason, IssueCreditNoteInput, CreditNote, and Mutation.issueCreditNote while pruning Warehouse and Query.warehouses."
                }
              },
              "schema": {
                "inputSchema": {
                  "type": "object",
                  "properties": {
                    "sdl": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Full GraphQL Schema Definition Language (SDL) string."
                    },
                    "query": {
                      "type": "string",
                      "maxLength": 500,
                      "description": "Natural-language task intent scored against root Query, Mutation, and Subscription fields."
                    },
                    "rootFields": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "maxItems": 50,
                      "description": "Explicit root field names to extract (e.g. 'createCreditNote' or 'Mutation.refundInvoice')."
                    },
                    "operationTypes": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "Query",
                          "Mutation",
                          "Subscription"
                        ]
                      },
                      "maxItems": 3,
                      "description": "Optional filter restricting root operation containers."
                    },
                    "maxRootFields": {
                      "type": "integer",
                      "default": 5,
                      "minimum": 1,
                      "maximum": 50,
                      "description": "Maximum number of matched root fields to retain in the mini-SDL."
                    },
                    "compactDescriptions": {
                      "type": "boolean",
                      "default": false,
                      "description": "Strip triple-quoted and single-line descriptions from the emitted mini-SDL."
                    }
                  },
                  "required": [
                    "sdl"
                  ],
                  "additionalProperties": false
                },
                "outputSchema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data",
                    "_meta"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "description": "Deterministic structured tool result payload."
                    },
                    "_meta": {
                      "type": "object",
                      "required": [
                        "requestId",
                        "durationMs",
                        "chargedUsd",
                        "dryRun"
                      ],
                      "properties": {
                        "requestId": {
                          "type": "string"
                        },
                        "durationMs": {
                          "type": "number"
                        },
                        "chargedUsd": {
                          "type": "string"
                        },
                        "dryRun": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "dry_run",
            "in": "query",
            "required": false,
            "description": "Validate request schema for free ($0.00) without executing or settling payment.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sdl": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Full GraphQL Schema Definition Language (SDL) string."
                  },
                  "query": {
                    "type": "string",
                    "maxLength": 500,
                    "description": "Natural-language task intent scored against root Query, Mutation, and Subscription fields."
                  },
                  "rootFields": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "maxItems": 50,
                    "description": "Explicit root field names to extract (e.g. 'createCreditNote' or 'Mutation.refundInvoice')."
                  },
                  "operationTypes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "Query",
                        "Mutation",
                        "Subscription"
                      ]
                    },
                    "maxItems": 3,
                    "description": "Optional filter restricting root operation containers."
                  },
                  "maxRootFields": {
                    "type": "integer",
                    "default": 5,
                    "minimum": 1,
                    "maximum": 50,
                    "description": "Maximum number of matched root fields to retain in the mini-SDL."
                  },
                  "compactDescriptions": {
                    "type": "boolean",
                    "default": false,
                    "description": "Strip triple-quoted and single-line descriptions from the emitted mini-SDL."
                  }
                },
                "required": [
                  "sdl"
                ],
                "additionalProperties": false
              },
              "example": {
                "query": "issue credit note for invoice",
                "maxRootFields": 2,
                "compactDescriptions": true,
                "sdl": "scalar DateTime\nenum CreditReason { DUPLICATE OVERCHARGE }\ninput IssueCreditNoteInput { invoiceId: ID! reason: CreditReason! }\ntype CreditNote { id: ID! issuedAt: DateTime! }\ntype Warehouse { id: ID! code: String! }\ntype Query { warehouses: [Warehouse!]! }\ntype Mutation { issueCreditNote(input: IssueCreditNoteInput!): CreditNote! }"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful execution result.",
            "headers": {
              "PAYMENT-RESPONSE": {
                "description": "Base64-encoded x402 v2 payment settlement receipt (when paid).",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object"
                    },
                    "_meta": {
                      "type": "object",
                      "properties": {
                        "requestId": {
                          "type": "string"
                        },
                        "durationMs": {
                          "type": "number"
                        },
                        "chargedUsd": {
                          "type": "string"
                        },
                        "dryRun": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Schema validation error (unbilled, $0.00)."
          },
          "402": {
            "description": "Payment Required. Decode the Base64 PAYMENT-REQUIRED header and retry with PAYMENT-SIGNATURE.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded x402 v2 PaymentRequired JSON object.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}