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
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.
| Provider | Decisions requests (/v1/decisions) | SystemOne requests (/v1/systemone) |
|---|---|---|
| OpenAI | Sent natively. | Translated to the OpenAI Decisions API format. |
| TypeSafe | Translated to the SystemOne API format. | Sent natively. |
Azure with the Foundry resource type | Translated to the SystemOne API format. | Sent natively. |
Custom with Decisions, without SystemOne | Sent natively. | Translated to the OpenAI Decisions API format. |
Custom with SystemOne, without Decisions | Translated to the SystemOne API format. | Sent natively. |
Custom with Decisions and SystemOne | Sent 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 field | Translated SystemOne API field |
|---|---|
input as a string | Sent as state, unchanged. |
input as a list of messages | Sent 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 input | Not supported. The request is rejected with a 400 error that contains unsupported content. |
questions | Sent 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 question | predicate is sent as noul. choice and score keep their names. |
choices in a choice question | Each 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 question | Each 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_identifier | Dropped. |
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 field | Translated OpenAI Decisions API field |
|---|---|
state as a string | Sent as input, unchanged. |
state as another value, such as a list of messages | Sent as input text that contains the state value as JSON. |
questions | Sent as a list. Each question key becomes the question name. |
type of a question | noul is sent as predicate. choice and score keep their names. |
criteria in a noul question | The true and false descriptions are appended to the instructions of the predicate question. |
criteria in a choice question | Each key becomes a choice value in choices. The value of that key becomes the choice description. |
criteria in a score question | Each entry becomes a level in levels, as follows.
|
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
- Install and set up an agentgateway proxy.
- 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/decisionstoDecisions./v1/systemonetoSystemOne.
If you already set up multiple endpoints, add both paths to your existing AgentgatewayBackend.
Update the
openaiAgentgatewayBackend 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" EOFReview the following table to understand this configuration. For more information, see the API docs.
Setting Description 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 omitroutes, 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.
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?"}] }' | jqExample output:
{ "model": "<decisions-model>", "answers": [ {"type": "predicate", "name": "visible_damage", "probability": 0.64} ], "usage": {"input_tokens": 156, "output_tokens": 0, "total_tokens": 156} }Optional: Send the same question in SystemOne. Use
statefor the input and a map keyed by name for the questions.The
noulquestion type returns the probability that a statement is true. It corresponds topredicatein 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?"}} }' | jqExample 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.
Port-forward the agentgateway proxy on port 15020.
kubectl port-forward deployment/agentgateway-proxy -n agentgateway-system 15020 &Open the agentgateway metrics endpoint.
Look for the
agentgateway_gen_ai_client_token_usagemetric. The metric includes labels for the token type (inputoroutput) 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.