# SystemOne decision

`POST /api/v1/systemone`

> Eevo docs. Every page as Markdown is listed at https://eevo.io/llms.txt; the API is described at https://eevo.io/api/openapi.json.

Answer one or more questions based on the given state (context). This endpoint is compatible with the SystemOne endpoint format introduced by Typesafe.

## Quick example

Below is a quick example of making a SystemOne request to Eevo via curl:

```shell
curl https://eevo.io/api/v1/systemone \
  -H "Authorization: Bearer $EEVO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "eevo-1",
  "state": "Support ticket: a customer was charged twice for an €80 order because of an error in our billing system. Agents may refund up to €50 without approval.",
  "questions": {
    "action": {
      "type": "choice",
      "instructions": "What should the support agent do?",
      "criteria": {
        "refuse": "Refuse, and cite the €50 limit",
        "partial": "Refund €50 and ask the customer to contact billing for the rest",
        "refund": "Refund the €80 duplicate charge and record the exception"
      }
    },
    "urgency": {
      "type": "score",
      "instructions": "How urgent is the ticket?",
      "criteria": [
        "Not urgent",
        "Somewhat urgent",
        "Urgent",
        "Critical"
      ]
    },
    "fraud": {
      "type": "noul",
      "instructions": "The customer is attempting fraud."
    }
  }
}'
```

The response:

```json
{
  "model": "eevo-1.2",
  "answers": {
    "action": {
      "type": "choice",
      "choice": "refund",
      "confidence": 0.71,
      "probabilities": {
        "refuse": 0.07,
        "partial": 0.22,
        "refund": 0.71
      }
    },
    "urgency": {
      "type": "score",
      "score": 2,
      "confidence": 0.58,
      "legend": {
        "0": "Not urgent",
        "1": "Somewhat urgent",
        "2": "Urgent",
        "3": "Critical"
      },
      "probabilities": {
        "0": 0.03,
        "1": 0.31,
        "2": 0.58,
        "3": 0.08
      }
    },
    "fraud": {
      "type": "noul",
      "noul": 0.04
    }
  },
  "usage": {
    "input_tokens": 412,
    "output_tokens": 0
  },
  "meta": {
    "orderings": 3
  }
}
```

The response includes a `meta` field only when a choice question was asked in more than one order of its options. Its `orderings` value is the highest number of orderings used for any question in the request; see Option order below.

## Supported question types

Requests can have multiple questions, and it is possible to mix questions of different types. Questions can be any of the following types:

| Type | Description | Output |
|---|---|---|
| `choice` | A multiple-choice question | Probability for each choice |
| `score` | A question whose answer is a number on a scale | Estimated score with its confidence |
| `noul` | A yes-or-no question, or a statement that is true or false | Probability of yes, or of the statement being true |
| `box` (preview) | Where one named object is in an image | The probability that it is there, and its bounding box as fractions of the image’s height and width, with a confidence |

A `noul` question can also define when its statement counts as true and when as false, in `criteria` under `true` and `false`. Either may be left out; any other key is refused. The answer is still the probability that the statement is true:

```json
{
  "questions": {
    "refundable": {
      "type": "noul",
      "instructions": "The order qualifies for a refund.",
      "criteria": {
        "true": "The item arrived damaged or not as described, and the claim was made within 30 days of delivery",
        "false": "The customer changed their mind, or the claim was made more than 30 days after delivery"
      }
    }
  }
}
```

**Several choices that apply (preview).** A `choice` question with `"multiple": true` returns every choice that applies, any number of them, rather than one. Eevo asks each choice as its own yes/no question about the same state, so `probabilities` gives each choice's own probability, and they need not sum to 1. `choices` lists those at 0.5 or above, in the question's order; for another cut-off, read `probabilities`. The request has the same format as Liquid's. Each choice is asked, and billed, as one yes/no question.

```json
{
  "questions": {
    "teams": {
      "type": "choice",
      "multiple": true,
      "instructions": "Which teams must act on this incident?",
      "criteria": {
        "billing": "Billing: wrong charges, invoices and refunds",
        "support": "Support: customers who need an answer or an apology",
        "security": "Security: leaked data, passwords or access"
      }
    }
  }
}
```

```json
{
  "answers": {
    "teams": {
      "type": "choice",
      "multiple": true,
      "choices": [
        "billing",
        "security"
      ],
      "probabilities": {
        "billing": 0.94,
        "support": 0.12,
        "security": 0.88
      }
    }
  }
}
```

[Writing requests for Eevo](https://eevo.io/api/docs/how-to/writing-requests.md) covers how to write each type of question.

## Option order

Eevo averages over the order of a choice question's options, so you do not need to ask the same question in different orders yourself. A choice question with n options is asked in min(n, 3) rotations of its options in parallel, and `choice` and `confidence` come from the averaged probabilities. Although a question may be asked several times, your input is billed only once.

Score and yes/no questions are asked once, in the order sent. So is a choice question whose text refers to an option by its key, such as "Option A is the status quo", and so is every question in a request with images.

## Images and box questions (preview)

**Preview: images and box questions.** Send images in `assets`, keyed by a reference you write as plain text where the image belongs: in a string value of `state`, or in a question's `instructions` or `criteria` (a yes/no question's `true` and `false` included, with their example images). Every image must be referenced. A reference that appears only as an object key, such as a field name in `state` or a choice label, does not count: in the Typesafe format, keys stay text. A `box` question names one target and returns its bounding box as fractions of the image's height (`top`, `bottom`, from the top) and width (`left`, `right`, from the left), and `found`, the probability that the target is in the image. Below 0.5, `box` is `null` and there is no `confidence`. Eevo reads `found` from a yes/no question it asks with the box, billed as one. For a target that is always there, such as "the most damaged area", `found` says little; ask your own yes/no question about what you are looking for. Only Eevo versions that accept images take them; the others answer 400. The image tokens are billed as input tokens, about one per 32×32 pixels.

```json
{
  "model": "eevo-1",
  "state": "A photo of the returned parcel: photo_1",
  "questions": {
    "damaged": {
      "type": "noul",
      "instructions": "The parcel in the image is damaged."
    },
    "label": {
      "type": "box",
      "instructions": "the shipping label"
    }
  },
  "assets": {
    "photo_1": {
      "type": "image",
      "format": "jpg",
      "data_base64": "/9j/4AAQSkZJRgABAQ…"
    }
  }
}
```

```json
{
  "model": "eevo-1",
  "answers": {
    "damaged": {
      "type": "noul",
      "noul": 0.87
    },
    "label": {
      "type": "box",
      "found": 0.97,
      "box": {
        "top": 0.18,
        "bottom": 0.41,
        "left": 0.52,
        "right": 0.86
      },
      "confidence": 0.79
    }
  },
  "usage": {
    "input_tokens": 1311,
    "output_tokens": 0
  }
}
```

A box whose target is most likely not in the image:

```json
{
  "answers": {
    "customs_form": {
      "type": "box",
      "found": 0.03,
      "box": null
    }
  }
}
```

**Naming an image in a question.** In a question's `instructions` or `criteria`, a state field in backticks names the image held in that field: `photo`, or a path such as `faces.happy` or `frames[2].frame`. The field's value must be the image's reference, or a text with exactly one reference in it. A field that holds anything else stays as written. Writing the reference itself works too.

**A box with several images.** When a request has more than one image, each `box` question must name the one image it searches, by its state field in backticks or by its reference. A box that names none, or more than one, is refused with 400. Every image in `assets` counts, example images in a yes/no definition included, so one photo with example images still needs its box to name the photo. With one image there is nothing to name.

```json
{
  "model": "eevo-1",
  "state": {
    "notes": "The parcel before and after transit.",
    "before": "photo_1",
    "after": "photo_2"
  },
  "questions": {
    "dent": {
      "type": "box",
      "instructions": "the largest dent in `after`"
    }
  },
  "assets": {
    "photo_1": {
      "type": "image",
      "format": "jpg",
      "data_base64": "/9j/4AAQSkZJRgABAQ…"
    },
    "photo_2": {
      "type": "image",
      "format": "jpg",
      "data_base64": "/9j/4AAQSkZJRgABAQ…"
    }
  }
}
```

**Example images in a yes/no definition.** Each side of a `noul` question's `criteria` can be a text, or a description with example images, each written as its reference: `{"description": "…", "examples": ["<reference>", …]}`. The example images count as references, so send them in `assets` like any other image.

```json
{
  "questions": {
    "damaged": {
      "type": "noul",
      "instructions": "The parcel in `photo` is damaged.",
      "criteria": {
        "true": {
          "description": "Torn, crushed or wet",
          "examples": [
            "torn_example",
            "crushed_example"
          ]
        },
        "false": {
          "description": "Scuffed tape or dust only",
          "examples": [
            "scuffed_example"
          ]
        }
      }
    }
  }
}
```

To send the images as files rather than base64, post the request to this endpoint, with your API key, as `multipart/form-data`, the format of TypeSafe's System One API. The first part, named `request`, holds the JSON request, and each image is a part of its own with a unique name. An asset names its part as `{"type": "image", "part": "<part name>"}` instead of giving `data_base64`, and its `format` is then optional: Eevo reads it from the image. Every image part must be used by exactly one asset.

```bash
curl https://eevo.io/api/v1/systemone \
  -H "Authorization: Bearer $EEVO_API_KEY" \
  -F 'request={"model": "eevo-1", "state": "A photo of the returned parcel: photo_1", "questions": {"label": {"type": "box", "instructions": "the shipping label"}}, "assets": {"photo_1": {"type": "image", "part": "photo_1"}}};type=application/json' \
  -F 'photo_1=@parcel.jpg'
```

## How-to guides

Examples of tasks the SystemOne decision endpoint answers:

- [Model routing with Eevo](https://eevo.io/api/docs/how-to/model-routing.md): Route each request to a model by the task’s attributes and your own policy.
- [Ranking search results with Eevo](https://eevo.io/api/docs/how-to/ranking.md): Score how well each result answers the query, and sort the results by the scores.
- [Content filtering with Eevo](https://eevo.io/api/docs/how-to/content-filtering.md): Publish, hold or reject a text under your own policy.
- [Injection safeguards with Eevo](https://eevo.io/api/docs/how-to/injection-safeguards.md): Check untrusted content for instructions aimed at your agent.
- [PII detection with Eevo](https://eevo.io/api/docs/how-to/pii-detection.md): Find personal data in a text before it leaks.
- [Investment thesis match screening with Eevo](https://eevo.io/api/docs/how-to/thesis-screening.md): Evaluate a list of companies against an investment thesis.
