{"uid":"cap_cx0NbmQFCg9yVvTKeEE6j","slug":"code-agent-js-function-generator-x402-usdc-9eb65676","name":"Code Agent — JS Function Generator (x402/USDC)","description":"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.","url":"https://code.mamenesia.com/service/generate-function","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"prompt":{"type":"string","description":"Describe the JS function to generate"}}},"responseSchema":{"type":"json","example":{"paid":"1 USDC","result":{"code":"// generated output","model":"glm-5.1","tokens":100},"txHash":"0x...","service":"generate-function"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"1","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":"$1/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"1","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"1","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_5_NZQt1rFVmIe1BMGN_89","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"1","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Generates a JavaScript function from a natural language prompt, paid per-request via USDC on Base using the x402 standard.","exampleAgentPrompt":"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?","exampleUseCases":[{"title":"Generate array utility function","prompt":"Write me a JavaScript function that flattens a deeply nested array into a single-level array, handling any depth recursively."},{"title":"Build form validation helper","prompt":"I need a JavaScript function that validates a form field value as a US phone number — it should accept formats like (555) 123-4567 or 555-123-4567 and return true or false."},{"title":"Create API fetch wrapper","prompt":"Generate a JavaScript function that wraps the native fetch API with automatic retry logic — retry up to 3 times on network errors with exponential backoff."}],"resultDescription":"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'.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T06:30:29.819Z","isFirstParty":false}