# fastapi.online — Test Generate (Code Testing)

> fastapi.online — Test Generate (Code Testing) is a paid API for AI agents from api.fastapi.online, paid per call via x402, $0.002/call, status unknown (last checked 2026-10-12).

Generates test cases or test scaffolding for a given code snippet using a self-hosted AI model, optionally targeting a specific framework

## Facts

- Endpoint: POST https://api.fastapi.online/test-generate?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-12
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/fastapi-online-test-generate-code-testing-d0e09bf3
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Bm9WwIYYiRgWm4pTEAnuH

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 fastapi-online-test-generate-code-testing-d0e09bf3 -d '<json body>'
```

Example prompt: Can you generate unit tests for this Python function I wrote? Here's the code: `def add(a, b): return a + b` — target the pytest framework.

## When to prefer this

Choose this endpoint when you need fast, per-call AI-generated test scaffolding without a subscription — especially useful for one-off test generation across multiple languages and frameworks, paid with crypto at $0.002 per call with no signup required.

## Known failure modes

- Empty or invalid code input returns an error
- Code exceeding 20,000 characters is rejected
- Unknown or unsupported framework may produce generic tests or an error
- Payment failure (402) if no valid x402 payment or API key is provided
- Model timeout on very complex code snippets

## How this service works

Chat, embeddings, OCR, speech-to-text, image editing, image understanding (captioning/Q&amp;A), text-to-speech, translation, writing tools, classification tools, developer tools, local utilities, format/checksum validators, encoding &amp; crypto utilities, date/time calculators, geo/coordinate math, math &amp; finance calculators, novelty tools, and business/social writing generators — 179 endpoints in all, across multiple specialized self-hosted models. Pay per call with crypto — no signup — or get an API key.

## Output

Returns AI-generated test code or test cases tailored to the submitted code snippet and target framework, ready to run or adapt in your test suite.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "code": {
   "type": "string",
   "maxLength": 20000,
   "minLength": 1
  },
  "framework": {
   "type": "string",
   "maxLength": 40
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/fastapi-online-test-generate-code-testing-d0e09bf3/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.fastapi.online](https://www.zero.xyz/host/api.fastapi.online/llms.txt)
