Skip to main content
DecisionModel asks typed questions about a state and gets calibrated probabilities back, with no generated text to parse. This example uses Google’s gemini-decision-1 to decide what to do with a customer’s return request, then checks an attached photo.

Setup

The model name picks the provider: any name that starts with gemini-decision goes to Gemini’s Decisions API. There is no google-genai dependency, since the client calls the HTTP API directly.

The example

How it works

  1. One request, four questions. run() sends the request and all four questions together. Each question is answered on its own against the same state, so adding a question does not change the other answers.
  2. Structured state. The state is a dict, which is sent to Gemini as JSON text. Instructions can name its fields by key path, as within_window does with order.age_days.
  3. Three question types. choice picks one option, score rates the state against ordered levels, and noul returns the probability that a statement is true.
  4. Yes/no descriptions. The true and false criteria on is_damaged say what each side means. DecisionModel renames them to the keys Gemini expects.
  5. Thresholds in code. The request is approved automatically only when the resolution is confident and both policy checks pass. Everything else goes to a person.
  6. Media. A list of content blocks passes through to Gemini unchanged, so the second call sends a text block and a base64 image. The same shape works for audio, video and PDFs.
  7. Cost. calculate_cost() prices the tokens of both requests. Gemini bills input tokens only.

Output

The values depend on the model. The shape is:
Yes/no probabilities from Gemini fall between 0.01 and 0.99, so a threshold above 0.99 never matches.

Switching provider

The questions and answers have the same shape for every provider, so the text part of this example runs on another decision model by changing the name:
The list of content blocks is Gemini’s format. OpenAI takes images as a list of user messages instead; see the reference.

DecisionModel reference

Every provider, method and question type

Source

The example file in the swarms repo