# OnHub Code Execution — Python-Based Computational Q&A

> OnHub Code Execution — Python-Based Computational Q&A is a paid API for AI agents from x402.onhub.ai, paid per call via x402, $0.015/call, status unknown (last checked 2026-10-11).

Answers computational questions by writing and executing Python code, returning step-by-step reasoning and a final answer, paid per request in USDC on Base.

## Facts

- Endpoint: POST https://x402.onhub.ai/v1/code?utm_source=zero.xyz
- Price: $0.015/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-11
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/onhub-code-execution-python-based-computational-q-a-19a62f4a
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_deVm0nLS9FmWrcb5BsVLR

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 onhub-code-execution-python-based-computational-q-a-19a62f4a -d '<json body>'
```

Example prompt: Can you compute the sum of the squares of all integers from 1 to 100 by writing and running Python code?

## When to prefer this

Choose this endpoint when you need to verify or compute a precise numerical, algorithmic, or data-processing result using executed Python code rather than LLM estimation. It is ideal when accuracy matters (e.g. large sums, sorting, statistics) and a hallucinated answer is unacceptable. Prefer it over a general text inference endpoint when the task is inherently computational and benefits from code execution guarantees.

## Known failure modes

- Query too short (below 3 characters) returns validation error
- Query exceeds 2000 character limit returns validation error
- Payment not provided or insufficient USDC returns 402 Payment Required
- Computationally unbounded or infinite-loop queries may time out
- Queries requiring external network access inside the sandbox may fail
- Ambiguous or non-computational queries may produce incorrect or empty steps

## How this service works

OnHub is the pay-per-request API layer for agents. Text inference paid per request with USDC on Base.

## Output

Returns a JSON object with the original query, an array of execution steps (each with a type and content field showing intermediate outputs), and a final human-readable answer string. The object type is 'code.result'.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "query": {
   "type": "string",
   "maxLength": 2000,
   "minLength": 3,
   "description": "A computational question to answer by writing and running Python code, e.g. a calculation, data-processing, or verification task."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "query": "What is the sum of the first 50 prime numbers?",
  "steps": [
   {
    "type": "result",
    "content": "5117\n"
   }
  ],
  "answer": "The sum of the first 50 prime numbers is 5,117.",
  "object": "code.result"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/onhub-code-execution-python-based-computational-q-a-19a62f4a/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.onhub.ai](https://www.zero.xyz/host/x402.onhub.ai/llms.txt)
