# ForgeMesh Linear Regression API

> ForgeMesh Linear Regression API is a paid API for AI agents from x402.forgemesh.io, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-15).

Fits a least-squares linear regression line through paired x/y data, returning slope, intercept, R-squared, and the line equation.

## Facts

- Endpoint: POST https://x402.forgemesh.io/linear-regression
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/forgemesh-linear-regression-api-cb7ffe25
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Dfy4n23IApnlXsvg4I9nH

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 forgemesh-linear-regression-api-cb7ffe25 -d '<json body>'
```

Example prompt: Fit a linear regression line through these data points — x: [1, 2, 3, 4, 5] and y: [2.1, 3.9, 6.2, 7.8, 10.1] — and give me the slope, intercept, R-squared, and the equation of the line.

## When to prefer this

Use this endpoint when you need a fast, deterministic, exact least-squares linear regression with slope, intercept, and R-squared — especially in data science pipelines, trend analysis workflows, or forecasting preprocessing steps where you need a reliable numeric result without spinning up a full ML environment.

## Known failure modes

- Mismatched array lengths for x and y returns a validation error
- Empty or single-element arrays may return undefined slope/intercept
- Non-numeric values in input arrays cause schema validation failure
- Arrays with zero variance in x (all same x value) produce undefined slope (vertical line singularity)

## How this service works

Linear regression API: fit a least-squares line through paired x/y data and get slope, intercept, R-squared goodness-of-fit, and the line equation. For trend analysis, forecasting inputs, and data-science agents. Exact and deterministic.

## Output

Returns the slope, intercept, R-squared goodness-of-fit statistic, and the full line equation for the best-fit least-squares line through the provided x/y data pairs. Results are exact and deterministic.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "x": {
   "type": "array",
   "items": {
    "type": "number"
   }
  },
  "y": {
   "type": "array",
   "items": {
    "type": "number"
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "slope": 1.9,
  "equation": "y = 1.9x + -0.5",
  "intercept": -0.5,
  "r_squared": 0.966
 }
}
```

## More

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