# JSDoc Comment Generator

> JSDoc Comment Generator is a paid API for AI agents from api.strale.io, paid per call via x402, $0.054001/call, status unknown (last checked 2026-09-13).

Automatically generates JSDoc comments for JavaScript/TypeScript functions and classes, inferring parameter types, return types, and thrown exceptions.

## Facts

- Endpoint: GET https://api.strale.io/x402/jsdoc-generate
- Price: $0.054001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/api-strale-io-5a8c9f39
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_nOI-pGADN2_UMWcVHTr31

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability api-strale-io-5a8c9f39
```

Example prompt: Can you add JSDoc comments to this JavaScript function — infer the param types, return type, and any thrown errors: `function divide(a, b) { if (b === 0) throw new Error('Division by zero'); return a / b; }`?

## When to prefer this

Choose this endpoint when you need to automatically document JavaScript or TypeScript code with JSDoc comments, especially when type inference for params, returns, and throws is needed without running a full TypeScript compiler or linter.

## Known failure modes

- Missing 'code' query parameter returns a validation error
- Unparseable or syntactically invalid code may produce incomplete or malformed JSDoc
- Very large code blocks may time out or return partial results
- Non-JavaScript/TypeScript input (e.g. Python) may yield nonsensical annotations

## How this service works

Add JSDoc comments to JavaScript/TypeScript functions and classes. Infers param types, return types, and throws.

## Output

Returns the original code enhanced with JSDoc block comments including @param tags with inferred types, @returns tag with inferred return type, and @throws tags for any detected exceptions.

## Example request

```json
{
 "code": "function add(x, y) { if (typeof x !== 'number' || typeof y !== 'number') throw new TypeError('Arguments must be numbers'); return x + y; }"
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "code"
     ],
     "properties": {
      "code": {
       "type": "string"
      }
     }
    }
   },
   "additionalProperties": false
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/api-strale-io-5a8c9f39/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.strale.io](https://www.zero.xyz/host/api.strale.io/llms.txt)
