{"uid":"cap_A3Laii9t5A2ADMQxd_SoV","slug":"onhub-code-execution-api-2aeb3fe1","name":"OnHub Code Execution API","description":"Writes and runs Python to compute or verify an answer, returning the code, its output, and a final answer.","url":"https://api.onhub.ai/v1/code?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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."}}},"responseSchema":{"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"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.015","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.015/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.015","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.015","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_KZ6x2XXhcMS6GbmOfG8cA","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.015","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Writes and runs Python code to compute or verify an answer, returning the generated code, its output, and a final human-readable result","exampleAgentPrompt":"Can you calculate what the sum of the squares of the first 100 Fibonacci numbers is? Write and run the Python code to get me the exact answer.","exampleUseCases":[{"title":"Prime number sequence calculation","prompt":"What is the sum of all prime numbers below 10,000? Run the code and give me the exact number."},{"title":"Verify algorithmic complexity claim","prompt":"Can you write and run Python to verify that sorting a list of 1 million random numbers with quicksort actually runs faster than bubble sort on the same input?"},{"title":"Statistical computation on described data","prompt":"I have a dataset of values: [14, 22, 8, 45, 31, 17, 9, 52, 27, 38]. Can you compute the mean, median, standard deviation, and interquartile range for me?"}],"resultDescription":"Returns a JSON object containing the original query, an array of steps (each with a type and content field showing the code output), and a final human-readable answer string summarizing the computed result, along with an object type identifier 'code.result'.","failureModes":["Query too short (below 3 characters) or too long (above 2000 characters) returns a validation error","Code execution errors such as division by zero or import of unavailable libraries may result in an error step rather than a valid answer","Ambiguous or non-computational queries may produce incorrect or nonsensical Python code","Network timeout if the code execution takes too long for complex computations","Payment failure via x402 protocol if insufficient USDC balance"],"whenToPreferThis":"Choose this endpoint when you need a precise, verifiable answer to a computational or mathematical question and want to see the Python code and its raw output alongside the result. It is especially valuable when correctness must be demonstrated (not just asserted), when calculations involve large numbers or complex sequences, or when you need to verify a claim programmatically. Prefer it over plain text inference endpoints for any task where running actual code produces a more trustworthy answer than language model estimation.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-02T18:36:39.409Z","isFirstParty":false,"canonicalSlug":"onhub-code-execution-api-2aeb3fe1"}