# Code Agent — JS Function Generator (x402/USDC)

> Code Agent — JS Function Generator (x402/USDC) is a paid API for AI agents from code.mamenesia.com, paid per call via x402, $1/call, status unknown (last checked 2026-09-15).

Generates a JavaScript function from a natural language prompt, paid per-request via USDC on Base using the x402 standard.

## Facts

- Endpoint: POST https://code.mamenesia.com/service/generate-function
- Price: $1/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/code-agent-js-function-generator-x402-usdc-9eb65676
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_cx0NbmQFCg9yVvTKeEE6j

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 code-agent-js-function-generator-x402-usdc-9eb65676 -d '<json body>'
```

Example prompt: Can you generate a JavaScript function that takes an array of objects and groups them by a specified key property, returning an object where each key maps to an array of matching items?

## When to prefer this

Choose this endpoint when you need to programmatically generate JavaScript functions on demand and are willing to pay per-request via USDC on Base. It is well-suited for AI agents that need to dynamically create utility code, scaffold functions, or prototype JS logic without managing an LLM API key directly. Prefer this over general-purpose LLM APIs when you want a simple, payment-gated code generation call with no authentication setup beyond x402.

## Known failure modes

- Payment failure: insufficient USDC balance or invalid x402 payment header returns 402
- Vague prompt: ambiguous descriptions may produce incorrect or incomplete functions
- Token limit: very complex prompts may hit token limits, truncating output
- Network timeout: LLM inference may time out on complex requests
- Invalid JSON response: upstream model errors may produce malformed output

## How this service works

Pay-per-request AI developer tools in USDC on Base. Generate code, audit smart contracts, review diffs, summarize text, and convert data formats via the x402 payment standard. Powered by glm-5.2.

## Output

Returns a JSON object containing the generated JavaScript code string under result.code, the model used (e.g. glm-5.2), the number of tokens consumed, the amount paid (1 USDC), the transaction hash on Base, and the service name 'generate-function'.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "prompt": {
   "type": "string",
   "description": "Describe the JS function to generate"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "paid": "1 USDC",
  "result": {
   "code": "// generated output",
   "model": "glm-5.1",
   "tokens": 100
  },
  "txHash": "0x...",
  "service": "generate-function"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/code-agent-js-function-generator-x402-usdc-9eb65676/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from code.mamenesia.com](https://www.zero.xyz/host/code.mamenesia.com/llms.txt)
