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, 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.

Custom provider requirements

A custom provider must declare at least one of decisions and systemOne in formats. If formats is omitted or contains only other formats, both endpoints return 400. The error names the request format and provider:

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

Version 1.6 had no Decisions or SystemOne route type. With the llm configuration, it passed both paths through to the provider unchanged. After upgrading, add the format your upstream server supports to formats to keep serving these requests.

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.

Map the Decisions route type

With the simplified llm configuration, no route setup is needed. Agentgateway maps /v1/decisions to decisions and /v1/systemone to systemOne.

# yaml-language-server: $schema=https://agentgateway.dev/schema/config
llm:
  models:
  - name: "*"
    provider: openAI
    params:
      apiKey: "$OPENAI_API_KEY"

For a custom provider, declare the upstream format as decisions or systemOne. Agentgateway appends /decisions or /systemone to baseUrl. This example uses decisions.

# yaml-language-server: $schema=https://agentgateway.dev/schema/config
llm:
  models:
  - name: decisions-model
    provider:
      custom:
        formats:
        - type: decisions
    params:
      apiKey: "$CUSTOM_PROVIDER_API_KEY"
      baseUrl: "https://api.example.com/v1"

For explicit routing, use the gateways and routes configuration. Map /v1/decisions to decisions and /v1/systemone to systemOne in policies.ai.routes.

Without this map, requests default to completions. A Decisions request then fails with failed to parse Completions request.

# yaml-language-server: $schema=https://agentgateway.dev/schema/config
gateways:
  default:
    port: 4000
routes:
- backends:
  - ai:
      name: openai
      provider:
        openAI: {}
  policies:
    ai:
      routes:
        "/v1/decisions": "decisions"
        "/v1/systemone": "systemOne"
        "/v1/chat/completions": "completions"
        "*": "passthrough"
    backendAuth:
      key: "$OPENAI_API_KEY"

Review the following table to understand this configuration.

SettingDescription
policies.ai.routes."/v1/decisions"Processes requests on this path as Decisions requests.
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.

Tip

For detailed information about model routing and configuration modes, see Model routing and aliases.

Send a Decisions request

Send a request with an input and a list of questions to the /v1/decisions endpoint. Replace <decisions-model> with an OpenAI model that supports the Decisions API.

curl http://localhost:4000/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?"}]
  }'

Example output:

{
  "model": "<decisions-model>",
  "answers": [
    {"type": "predicate", "name": "visible_damage", "probability": 0.64}
  ],
  "usage": {"input_tokens": 156, "output_tokens": 0, "total_tokens": 156}
}

To ask the same question in SystemOne, use state for the input and a map keyed by name for the questions.

The SystemOne noul question type matches the Decisions predicate type. Both return the probability that a statement is true.

curl http://localhost:4000/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?"}}
  }'

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.

curl -s http://localhost:15020/metrics | grep 'agentgateway_gen_ai_client_token_usage_sum.*gen_ai_operation_name="decisions"'

Example output:

agentgateway_gen_ai_client_token_usage_sum{gen_ai_token_type="input",gen_ai_operation_name="decisions",gen_ai_system="openai",gen_ai_request_model="<decisions-model>",...} 156.0
agentgateway_gen_ai_client_token_usage_sum{gen_ai_token_type="output",gen_ai_operation_name="decisions",gen_ai_system="openai",gen_ai_request_model="<decisions-model>",...} 0.0

For more information about LLM metrics, see Observe traffic.

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/.