Skip to content
Help guide the future of agentgateway — Take the survey

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Decisions and SystemOne

Page as Markdown

Route OpenAI Decisions and TypeSafe SystemOne requests through agentgateway and track token usage.

About

The OpenAI Decisions API (/v1/decisions) asks a model to answer a list of questions about an input. Each question has one of three types.

  • A predicate returns the probability that a statement is true.
  • A choice picks one option from a list that you define, and returns the probability of each option.
  • A score rates the input on a scale of levels that you define, and returns the probability of each level.

Some providers use a different API for the same kind of request. The TypeSafe SystemOne API (/v1/systemone) covers the same three question types, but it names and arranges the request and the reply differently. For example, SystemOne sends the input as state and keys the questions by name, where the OpenAI Decisions API uses input and a list of questions. TypeSafe accepts only requests in SystemOne API format, so a client that sends requests in OpenAI Decisions API format could not call it without a translation.

Supported providers

The following providers accept Decisions and SystemOne API requests. Other providers, such as Anthropic, Bedrock, and Vertex AI, reject requests in these formats with a 400 error.

In the table, “Sent natively” means that the provider accepts the format, so agentgateway forwards the request unchanged. “Translated” means that agentgateway converts the request to the format that the provider accepts.

ProviderDecisions requests (/v1/decisions)SystemOne requests (/v1/systemone)
OpenAISent natively.Translated to the OpenAI Decisions API format.
TypeSafeTranslated to the SystemOne API format.Sent natively.
Azure with the Foundry resource typeTranslated to the SystemOne API format.Sent natively.
Custom with Decisions, without SystemOneSent natively.Translated to the OpenAI Decisions API format.
Custom with SystemOne, without DecisionsTranslated to the SystemOne API format.Sent natively.
Custom with Decisions and SystemOneSent natively.Sent natively.

A custom provider must declare at least one of Decisions and SystemOne. Otherwise, it rejects both request formats with a 400 error. The error names the request format and provider:

failed to process LLM request: unsupported conversion: from Decisions to provider custom

How translation works

Agentgateway translates a request only when the request format differs from the format that the provider accepts. The request is converted before it reaches the provider, and the reply is converted back to the format of the client.

Some fields in one API format have no match in the other format. Review the following tables to see how each field is translated.

OpenAI Decisions API requests to SystemOne API

Review how agentgateway translates the fields of an OpenAI Decisions API request to a SystemOne API request.

OpenAI Decisions API request fieldTranslated SystemOne API field
input as a stringSent as state, unchanged.
input as a list of messagesSent as state, as a list of objects with the role and content of each message. If a message has a list of text parts, the parts are joined with newlines.
An image in inputNot supported. The request is rejected with a 400 error that contains unsupported content.
questionsSent as an object keyed by question name. A question without a name is keyed by its position in the list, starting at 0. If another question already uses that position number as its name, underscores are appended to the key until it is unique, such as 1_. Two questions with the same name are rejected with a 400 error.
type of a questionpredicate is sent as noul. choice and score keep their names.
choices in a choice questionEach choice value becomes a key in the criteria object of the SystemOne question. The value of that key is the choice description, or null if the choice has no description. Two choices with the same value are rejected with a 400 error.
levels in a score questionEach level becomes an entry in the criteria list of the SystemOne question, either the level label alone or an object with the level label and description. The probabilities in the answer include the labels from the request.
Other fields, such as safety_identifierDropped.

The reply lists the answers in the order that the provider returns them, which might differ from the order of questions. The usage field reports the input and output tokens from the provider. The total_tokens field is the sum of the input and output tokens.

A boolean choice value is sent as the string true or false and comes back as a boolean. A string value of true comes back as a string. A boolean and a string with the same text count as duplicate choice values.

The answer to a question without a name also has no name. To match answers to questions, give every question a name.

For example, the following Decisions request has two questions without a name.

{
  "model": "<decisions-model>",
  "input": "I want my money back. This is the second time my order arrived broken.",
  "questions": [
    {"type": "predicate", "instructions": "Is the customer asking for a refund?"},
    {"type": "predicate", "instructions": "Is the customer angry?"}
  ]
}

The SystemOne provider receives the questions keyed by position, 0 and 1.

{
  "model": "<decisions-model>",
  "state": "I want my money back. This is the second time my order arrived broken.",
  "questions": {
    "0": {"type": "noul", "instructions": "Is the customer asking for a refund?"},
    "1": {"type": "noul", "instructions": "Is the customer angry?"}
  }
}

The following reply shows only the answers field. Neither answer has a name. If the provider returns the answers in a different order than the questions, the reply does not show which answer belongs to which question.

{
  "answers": [
    {"type": "predicate", "probability": 0.81},
    {"type": "predicate", "probability": 0.93}
  ]
}

SystemOne API requests to OpenAI Decisions API

Review how agentgateway translates the fields of a SystemOne API request to an OpenAI Decisions API request.

SystemOne API request fieldTranslated OpenAI Decisions API field
state as a stringSent as input, unchanged.
state as another value, such as a list of messagesSent as input text that contains the state value as JSON.
questionsSent as a list. Each question key becomes the question name.
type of a questionnoul is sent as predicate. choice and score keep their names.
criteria in a noul questionThe true and false descriptions are appended to the instructions of the predicate question.
criteria in a choice questionEach key becomes a choice value in choices. The value of that key becomes the choice description.
criteria in a score questionEach entry becomes a level in levels, as follows.
  • A string becomes the level label.
  • An object with a string label uses that value as the level label. If label is the only field, the level has no description. If description is the only other field, its value becomes the level description. If the object has any other field, all fields except label are sent as a JSON description.
  • Any other entry, such as a number or an object without a string label, becomes the level label, written as JSON.

The reply keys each answer by question name. Score answers include a legend that is built from the criteria in the request. The usage field reports the input and output tokens from the provider. SystemOne has no refusal answer. If the provider refuses to answer a question, the request fails with a 502 error.

Before you begin

  1. Install and set up an agentgateway proxy.
  2. Set up access to the OpenAI LLM provider.

Map the Decisions route type

Requests default to the Completions route type. On your OpenAI AgentgatewayBackend, map these paths:

  • /v1/decisions to Decisions.
  • /v1/systemone to SystemOne.

If you already set up multiple endpoints, add both paths to your existing AgentgatewayBackend.

  1. Update the openai AgentgatewayBackend from the OpenAI setup guide. This command replaces that AgentgatewayBackend.

    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayBackend
    metadata:
      name: openai
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai: {}
      policies:
        auth:
          secretRef:
            name: openai-secret
        ai:
          routes:
            "/v1/decisions": "Decisions"
            "/v1/systemone": "SystemOne"
            "/v1/chat/completions": "Completions"
            "*": "Passthrough"
    EOF

    Review the following table to understand this configuration. For more information, see the API docs.

    SettingDescription
    ai.provider.openaiThe OpenAI provider. The example sets no default model, so each request must name its model.
    policies.ai.routes."/v1/decisions"Processes requests on this path as Decisions requests. Without this entry, the "*": "Passthrough" route forwards Decisions requests without processing them. If you omit routes, agentgateway processes every request as a chat completion.
    policies.ai.routes."/v1/systemone"Processes requests on this path as SystemOne requests. The OpenAI provider receives them translated to the Decisions format. For how each field is translated, see SystemOne API requests to OpenAI Decisions API.
    policies.ai.routes."*"Passes requests on all other paths through unchanged.

Send a Decisions request

Send a request with an input and a list of questions to the /v1/decisions path.

  1. Send the request. Replace <decisions-model> with an OpenAI model that supports the Decisions API.

    curl "http://$INGRESS_GW_ADDRESS/v1/decisions" \
      -H 'Content-Type: application/json' \
      -d '{
        "model": "<decisions-model>",
        "input": [{"role": "user", "content": [{"type": "input_text", "text": "The package was left in the rain and the box is soaked through."}]}],
        "questions": [{"type": "predicate", "name": "visible_damage", "instructions": "Does the customer report visible damage to the package?"}]
      }' | jq

    Example output:

    {
      "model": "<decisions-model>",
      "answers": [
        {"type": "predicate", "name": "visible_damage", "probability": 0.64}
      ],
      "usage": {"input_tokens": 156, "output_tokens": 0, "total_tokens": 156}
    }
  2. Optional: Send the same question in SystemOne. Use state for the input and a map keyed by name for the questions.

    The noul question type returns the probability that a statement is true. It corresponds to predicate in the OpenAI Decisions API.

    curl "http://$INGRESS_GW_ADDRESS/v1/systemone" \
      -H 'Content-Type: application/json' \
      -d '{
        "model": "<decisions-model>",
        "state": [{"role": "user", "content": "The package was left in the rain and the box is soaked through."}],
        "questions": {"visible_damage": {"type": "noul", "instructions": "Does the customer report visible damage to the package?"}}
      }' | jq

    Example output:

    {
      "model": "<decisions-model>",
      "answers": {"visible_damage": {"type": "noul", "noul": 0.64}},
      "usage": {"input_tokens": 156, "output_tokens": 0}
    }

Verify token tracking

After the request completes, check that agentgateway recorded the token usage in its metrics.

  1. Port-forward the agentgateway proxy on port 15020.

    kubectl port-forward deployment/agentgateway-proxy -n agentgateway-system 15020 &
  2. Open the agentgateway metrics endpoint.

  3. Look for the agentgateway_gen_ai_client_token_usage metric. The metric includes labels for the token type (input or output) and the model.

For more information about LLM metrics, see LLM cost tracking.

Cleanup

You can remove the resources that you created in this guide.

To restore the original AgentgatewayBackend, apply the openai AgentgatewayBackend from OpenAI again.

To keep the AgentgatewayBackend but stop processing Decisions and SystemOne requests, remove the "/v1/decisions": "Decisions" and "/v1/systemone": "SystemOne" entries from its routes.

Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate ↵ select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.