{"uid":"cap_J28c2D7nEhYmjxWVMs8TT","slug":"orbonomy-llm-code-generation-778958cc","name":"Orbonomy LLM Code Generation","description":"50+ pay-per-call API endpoints across accommodation, AI, content, fact-checking, and data services. Powered by x402 protocol.","url":"https://app.orbonomy.xyz/api/llm/code?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","required":["text","language"],"properties":{"text":{"type":"string"},"language":{"type":"string"}}},"responseSchema":{"type":"object","properties":{"success":{"type":"boolean"}}},"example":{"request":{"text":"Write a function that takes a list of numbers and returns the sum and average","language":"Python"},"response":{"result":"**Code Analysis**\n\nHere's a Python function that calculates the sum and average of a list of numbers:\n```python\ndef calculate_sum_and_average(numbers):\n    \"\"\"\n    Calculate the sum and average of a list of numbers.\n\n    Args:\n        numbers (list): A list of numbers.\n\n    Returns:\n        tuple: A tuple containing the sum and average of the numbers.\n    \"\"\"\n    if not numbers:\n        raise ValueError(\"Input list is empty\")\n\n    total = 0\n    for num in numbers:\n        total += num\n\n    average = total / len(numbers)\n\n    return total, average\n```\n**Bugs and Security Issues**\n\n1.  **Division by Zero**: If the input list is empty, the function raises a `ValueError`. However, if the input list contains a zero, the function will raise a `ZeroDivisionError` when calculating the average. To fix this, we can add a check for zero before calculating the average.\n2.  **Input Validation**: The function assumes that the input is a list of numbers. However, if the input is not a list or contains non-numeric values, the function will raise an error. To fix this, we can add input validation to ensure that the input is a list of numbers.\n\n**Performance Problems**\n\n1.  **Looping Over the List**: The function uses a loop to calculate the sum of the numbers. This can be inefficient for large lists. To fix this, we can use the built-in `sum` function, which is implemented in C and is much faster than a Python loop.\n2.  **Calculating the Average**: The function calculates the average by dividing the sum by the length of the list. However, this can be inefficient for large lists because it requires creating a list of numbers and then calculating its length. To fix this, we can calculate the average directly from the sum and the count of numbers.\n\n**Style Improvements**\n\n1.  **Docstring**: The function has a docstring that describes its purpose and behavior. However, the docstring could be improved by including information about the input and output types.\n2.  **Variable Names**: The variable names `total` and `average` are clear and descriptive. However, the variable name `numbers` could be improved by making it more specific, such as `input_numbers`.\n\n**Refactored Code**\n\nHere's the refactored code:\n```python\ndef calculate_sum_and_average(numbers: list[float]) -> tuple[float, float]:\n    \"\"\"\n    Calculate the sum and average of a list of numbers.\n\n    Args:\n        numbers (list[float]): A list of numbers.\n\n    Returns:\n        tuple[float, float]: A tuple containing the sum and average of the numbers.\n    \"\"\"\n    if not numbers:\n        raise ValueError(\"Input list is empty\")\n\n    total = sum(numbers)\n    count = len(numbers)\n\n    if count == 0:\n        raise ZeroDivisionError(\"Cannot calculate average of zero numbers\")\n\n    average = total / count\n\n    return total, average\n```\nThis refactored code addresses the bugs and security issues, performance problems, and style improvements mentioned above. It uses the built-in `sum` function to calculate the sum of the numbers, calculates the average directly from the sum and count, and includes input validation and docstrings to improve the code's robustness and readability.","success":true,"provider":"nim"}},"exampleRequest":{"text":"Write a function that takes a list of numbers and returns the sum and average","language":"Python"},"tags":["x402"],"displayCostAmount":"0.1","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":1,"rating":{"score":"0.83","successRate":"1.00","reviews":1,"stars":"4.3","state":"rated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.1/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.1","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.1","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_csDG1HsGXGqgPVF5GcRqP","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.1","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Generates code in a specified programming language from a natural language text description using an LLM backend.","exampleAgentPrompt":"Write me a Python function that reads a CSV file and returns the average of a numeric column — use Orbonomy's LLM code endpoint with language set to Python.","exampleUseCases":null,"resultDescription":"Returns a JSON object with a 'success' boolean and presumably the generated code content for the requested programming language based on the input text description.","failureModes":["Missing required 'text' field returns validation error","Missing required 'language' field returns validation error","Unsupported or misspelled language value may produce unexpected results","Payment failure via x402 protocol blocks request","LLM backend timeout returns error","Ambiguous or very short text prompt may produce low-quality code"],"whenToPreferThis":"Choose this endpoint when you need pay-per-call AI code generation without a subscription, especially within an x402-enabled payment workflow. Useful for agents that need on-demand code synthesis across multiple languages without managing API keys for OpenAI or similar services.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":1,"lastUsedAt":"2026-07-01T17:25:59.123Z","lastSuccessfullyRanAt":"2026-07-01T17:25:59.123Z","lastHealthCheckAt":"2026-10-11T00:40:32.385Z","isFirstParty":false,"canonicalSlug":"orbonomy-llm-code-generation-778958cc"}