{
  "openapi": "3.1.0",
  "info": {
    "title": "NoJunk AI Text",
    "version": "1.0.0",
    "description": "Pay-per-call text intelligence for agents: summarize any text (paragraph, bullets or TL;DR, in any language), extract named fields into strict JSON (null for anything not in the text, nothing invented), or classify text into your own labels. Up to 24,000 characters per call. You are only charged when a valid result is returned.",
    "x-guidance": "Three POST endpoints, JSON in, JSON out, paid per call in USDC on Base via x402 (you are only charged when a valid result is returned; all 4xx/5xx are free). POST /summarize {text, style?: paragraph|bullets|tldr, max_sentences?: 1-10, language?} -> {summary, ...} costs $0.005. POST /extract {text, fields: [\"name\", ...] or {name: \"what to look for\"}, instructions?} -> {data: {field: value|null}, confidence, notes} costs $0.005; values are never invented, anything the text does not state comes back null. POST /classify {text, labels: [2-20 strings], multi?: boolean} -> {label} or {labels: [...]} costs $0.002; the answer is always from your list. Text is capped at 24000 characters per call (413 above that); runs on Llama 3.3 70B with an automatic Qwen 2.5 32B fallback. Best for: condensing articles, pages or transcripts; turning emails, invoices, job posts or listings into structured JSON; routing, tagging and sentiment on reviews, tickets or posts."
  },
  "servers": [
    {
      "url": "https://nojunk-ai-text.mick8511.workers.dev"
    }
  ],
  "paths": {
    "/summarize": {
      "post": {
        "operationId": "summarizeText",
        "summary": "Summarize text (paragraph, bullets or TL;DR, any language)",
        "tags": [
          "AI",
          "Text",
          "NLP",
          "summarize"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.005000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 24000,
                    "description": "The text to summarize (max 24000 characters)"
                  },
                  "style": {
                    "type": "string",
                    "enum": [
                      "paragraph",
                      "bullets",
                      "tldr"
                    ],
                    "default": "paragraph",
                    "description": "paragraph: one prose paragraph; bullets: '- ' lines, one sentence each; tldr: a very short direct summary"
                  },
                  "max_sentences": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10,
                    "default": 3,
                    "description": "Maximum number of sentences (or bullets)"
                  },
                  "language": {
                    "type": "string",
                    "default": "en",
                    "description": "Output language as a code or name, e.g. en, es, French"
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "summary": {
                      "type": "string",
                      "description": "The summary; for style=bullets a string of '- ' lines"
                    },
                    "style": {
                      "type": "string",
                      "enum": [
                        "paragraph",
                        "bullets",
                        "tldr"
                      ]
                    },
                    "input_chars": {
                      "type": "integer"
                    },
                    "input_words": {
                      "type": "integer"
                    },
                    "model": {
                      "type": "string",
                      "description": "Model that produced the result"
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "prompt_tokens": {
                          "type": "integer"
                        },
                        "completion_tokens": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "prompt_tokens",
                        "completion_tokens"
                      ]
                    },
                    "generated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "summary",
                    "style",
                    "input_chars",
                    "input_words",
                    "model",
                    "usage",
                    "generated_at"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (no charge)"
          },
          "402": {
            "description": "Payment Required"
          },
          "413": {
            "description": "Text longer than 24000 characters or request body too large (no charge)"
          },
          "502": {
            "description": "AI model temporarily unavailable or returned an unusable result (no charge)"
          }
        }
      }
    },
    "/extract": {
      "post": {
        "operationId": "extractText",
        "summary": "Extract named fields from text into strict JSON (null when absent, nothing invented)",
        "tags": [
          "AI",
          "Text",
          "NLP",
          "extract"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.005000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 24000,
                    "description": "The text to extract from (max 24000 characters)"
                  },
                  "fields": {
                    "oneOf": [
                      {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 20,
                        "items": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "object",
                        "minProperties": 1,
                        "maxProperties": 20,
                        "additionalProperties": {
                          "type": "string"
                        }
                      }
                    ],
                    "description": "Field names to extract (1-20), either as an array of names or an object mapping each name to a short description of what to look for"
                  },
                  "instructions": {
                    "type": "string",
                    "maxLength": 1000,
                    "description": "Optional extra guidance, e.g. 'dates as YYYY-MM-DD'"
                  }
                },
                "required": [
                  "text",
                  "fields"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "description": "Exactly the requested fields; each value is a string, number, boolean, array of strings or null (null = not present in the text)",
                      "additionalProperties": {
                        "type": [
                          "string",
                          "number",
                          "boolean",
                          "array",
                          "null"
                        ]
                      }
                    },
                    "confidence": {
                      "type": "string",
                      "enum": [
                        "high",
                        "medium",
                        "low"
                      ]
                    },
                    "notes": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "model": {
                      "type": "string",
                      "description": "Model that produced the result"
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "prompt_tokens": {
                          "type": "integer"
                        },
                        "completion_tokens": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "prompt_tokens",
                        "completion_tokens"
                      ]
                    },
                    "generated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "data",
                    "confidence",
                    "notes",
                    "model",
                    "usage",
                    "generated_at"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (no charge)"
          },
          "402": {
            "description": "Payment Required"
          },
          "413": {
            "description": "Text longer than 24000 characters or request body too large (no charge)"
          },
          "502": {
            "description": "AI model temporarily unavailable or returned an unusable result (no charge)"
          }
        }
      }
    },
    "/classify": {
      "post": {
        "operationId": "classifyText",
        "summary": "Classify text into one or more of your own labels",
        "tags": [
          "AI",
          "Text",
          "NLP",
          "classify"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.002000"
          },
          "protocols": [
            {
              "x402": {}
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 24000,
                    "description": "The text to classify (max 24000 characters)"
                  },
                  "labels": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 20,
                    "items": {
                      "type": "string"
                    },
                    "description": "Allowed labels; the result is guaranteed to be from this list"
                  },
                  "multi": {
                    "type": "boolean",
                    "default": false,
                    "description": "true: return every label that applies as labels[]; false: return the single best label"
                  }
                },
                "required": [
                  "text",
                  "labels"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string",
                      "description": "The chosen label (when multi=false), always one of the given labels"
                    },
                    "labels": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "The chosen labels (when multi=true), all from the given labels"
                    },
                    "confidence": {
                      "type": "string",
                      "enum": [
                        "high",
                        "medium",
                        "low"
                      ]
                    },
                    "model": {
                      "type": "string",
                      "description": "Model that produced the result"
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "prompt_tokens": {
                          "type": "integer"
                        },
                        "completion_tokens": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "prompt_tokens",
                        "completion_tokens"
                      ]
                    },
                    "generated_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "confidence",
                    "model",
                    "usage",
                    "generated_at"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (no charge)"
          },
          "402": {
            "description": "Payment Required"
          },
          "413": {
            "description": "Text longer than 24000 characters or request body too large (no charge)"
          },
          "502": {
            "description": "AI model temporarily unavailable or returned an unusable result (no charge)"
          }
        }
      }
    }
  }
}