Owctopus
Log in

Errors

A failed call returns a code. SDKs throw that code. HTTP returns it in the JSON body. The message never includes your API key.

CodeWhen
invalid_api_keyThe key is missing or not recognized.
unauthorizedThe key cannot call this decision.
invalid_requestThe body is not a decide request.
invalid_decisionThe decision name is missing or empty.
invalid_optionsOptions are missing, empty, or have no id.
rate_limitedToo many calls in a short window.
unavailableThe Owctopus API could not be reached.
decision_unavailableA decision could not be produced for this request.
timeoutThe call exceeded the client timeout.

In your backend

import { OwctopusError } from "@owctopus/sdk";

try {
  const result = await owctopus.decide({
    decision: "meal_suggestion",
    context: { caloriesSoFar: 980, hunger: "high" },
    options: [
      { id: "chicken_bowl", calories: 540 },
      { id: "salad", calories: 320 },
    ],
  });
} catch (error) {
  if (error instanceof OwctopusError) {
    console.error(error.code);
  }
}

Timeouts and unavailable responses can be retried. Invalid keys, invalid options, and unauthorized calls should be fixed before you retry. Context can be any object your app needs. Options still need an id on every item, because that id is what comes back as the decision.