For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
GPT-Live

Built-in delegation with Decisions

In this lesson, we’ll look at another built-in integration with the Decisions API.

Decisions gives you real-time results for questions with predefined answers. It accepts three types of input:

  • Text

    “The package arrived dented. Can someone check if the item needs replacing?”

  • Image
    A cardboard package with a dent in one corner
  • JSON
    {
      "item": "package",
      "condition": "dented"
    }

And it supports three types of questions:

predicate

Returns a probability from 0 to 1 that a condition is true.

Are the contents damaged?
Probability that the condition is true: 0.37.
choice

Selects an option from your list and returns a probability for each.

Which team should handle it?
  • Shippingselected88%
  • Returns12%
  • Support0%
Confidence 82%
score

Rates the input on a predefined scale. The score can fall between levels.

How severe is the damage?
Damage severity score 0.9. 0 is Low, 1 is Medium, 2 is High.
Confidence 85%

You can ask multiple questions about the same input.

Let’s look at how GPT-Live can delegate to Decisions to update an app by voice. In this example, we’ll use an apartment search app.

Let’s walk through how this works.

Step 1 of 9

When we create the session, we configure Decisions with four questions about the renter’s search. In the GPT-Live prompt, we specify when to delegate to Decisions: in this case, whenever the renter gives or changes a preference.

Our server sends the session request to OpenAI. This sets up GPT-Live with our prompt and Decisions with the questions we defined.

As before, GPT-Live keeps track of the conversation so it can pass that context along when it delegates.

When GPT-Live delegates, it sends the conversation so far to Decisions.

The browser receives a trace event for that delegation, including an ID it can use to follow the related events.

Decisions returns its answers with the same delegation ID.

The browser can apply the choice answers directly to the area and bedroom filters. For a predicate, we choose a threshold to turn its probability into an on-or-off setting. Here, we enable a filter when the probability is at least 0.85.

Once the filters are applied, the browser lets GPT-Live know the update is complete.

GPT-Live can then confirm the update aloud. This can continue as the renter changes their search. We can also change the Decisions questions during the session with session.update and wait for session.updated before using the new questions.

Your application

Browser

Server

model
gpt-live-1.1
instructions
session.delegation
type
decisions
decisions
model
gpt-6-luna
questions
areatypechoice
name
area
type
choice
instructions
Which New York boroughs should the current apartment search include, considering all renter requests and corrections in the conversation?
choices
  • value
    all
    description
    No borough preference or all NYC
  • value
    brooklyn
    description
    Brooklyn only
  • value
    manhattan
    description
    Manhattan only
  • value
    both
    description
    Both Brooklyn and Manhattan
bedroomstypechoice
name
bedrooms
type
choice
instructions
What bedroom count does the renter currently want? Use any if unspecified. Consider the conversation and latest corrections.
choices
  • value
    any
    description
    No bedroom count specified
  • value
    1
    description
    One bedroom
  • value
    2
    description
    Two bedrooms
  • value
    3
    description
    Three bedrooms
pets_requiredtypepredicate
name
pets_required
type
predicate
instructions
Does the renter currently require an apartment that allows pets? A renter who has a dog or cat needs pet-friendly housing unless they explicitly say otherwise.
laundry_requiredtypepredicate
name
laundry_required
type
predicate
instructions
Does the renter currently require an in-unit washer and dryer? Use the latest requests and corrections.
Show full JSONHide JSON
{
  "session": {
    "model": "gpt-live-1.1",
    "audio": {
      "output": {
        "voice": "ripple"
      }
    },
    "instructions": "You are Haven, a friendly apartment search assistant. Help renters narrow fictional New York listings. Keep replies brief and natural.\n\nBackchannel policy\nListen quietly while the renter describes what they want.\n\nInterruption policy\nPause and listen when the renter interrupts or corrects a preference.\n\nDelegation policy\nDelegate to Decisions whenever the renter gives or changes search preferences. Decisions identifies the current area, bedroom count, pet requirement, and in-unit laundry requirement. Wait for the application to confirm the filters were applied before saying the search changed. Do not guess the results. Ask a short clarifying question only if needed.\n\nConfirmation policy\nAfter the application confirms success, say what you’ve already done. Use a short first-person confirmation like “I’ve filtered the search” or “I’ve added Manhattan.” Keep any follow-up open-ended. Only offer filters Haven supports.",
    "delegation": {
      "type": "decisions",
      "decisions": {
        "model": "gpt-6-luna",
        "questions": [
          {
            "type": "choice",
            "name": "area",
            "instructions": "Which New York boroughs should the current apartment search include, considering all renter requests and corrections in the conversation?",
            "choices": [
              {
                "value": "all",
                "description": "No borough preference or all NYC"
              },
              {
                "value": "brooklyn",
                "description": "Brooklyn only"
              },
              {
                "value": "manhattan",
                "description": "Manhattan only"
              },
              {
                "value": "both",
                "description": "Both Brooklyn and Manhattan"
              }
            ]
          },
          {
            "type": "choice",
            "name": "bedrooms",
            "instructions": "What bedroom count does the renter currently want? Use any if unspecified. Consider the conversation and latest corrections.",
            "choices": [
              {
                "value": "any",
                "description": "No bedroom count specified"
              },
              {
                "value": "1",
                "description": "One bedroom"
              },
              {
                "value": "2",
                "description": "Two bedrooms"
              },
              {
                "value": "3",
                "description": "Three bedrooms"
              }
            ]
          },
          {
            "type": "predicate",
            "name": "pets_required",
            "instructions": "Does the renter currently require an apartment that allows pets? A renter who has a dog or cat needs pet-friendly housing unless they explicitly say otherwise."
          },
          {
            "type": "predicate",
            "name": "laundry_required",
            "instructions": "Does the renter currently require an in-unit washer and dryer? Use the latest requests and corrections."
          }
        ]
      }
    }
  },
  "transport": {
    "type": "webrtc",
    "sdp": "<SDP offer from the browser>"
  }
}
OpenAI

GPT-Live

As we discussed earlier, you can also attach a sideband WebSocket if you want your server to receive the session events.

Decisions triggers

We’ve seen how GPT-Live can choose to delegate to Responses or Decisions. We can also set up a Decisions trigger to monitor the user’s or GPT-Live’s transcript without waiting for GPT-Live to delegate. Triggers can run alongside a delegation configuration, such as Responses or client delegation.

For example, we can use a trigger to change an avatar’s expression as the user speaks.

User

“Hey, can I tell you about my day?”

0:00 / 0:24

Let’s see how to set that up.

Step 1 of 4

When we create the session, we add a Decisions trigger on the input transcript and define a choice question for the avatar’s expression. For other applications, we can monitor the output transcript instead, or set up multiple triggers.

Our server sends the session request to OpenAI, setting up GPT-Live and the Decisions trigger.

As the user speaks, GPT-Live transcribes the audio. Decisions evaluates the transcript as it comes through and sends the result to the browser, which can update the avatar’s expression.

Decisions continues monitoring throughout the conversation, so the expression can change as the user keeps talking. We can also update the triggers during the session with session.update.

Your application

Browser

Server

model
gpt-live-1
instructions
session.triggers
type
decisions
event_type
session.input_transcript.delta
decisions
questions
expressiontypechoice
name
expression
type
choice
instructions
Which expression should a listening assistant show in response to the user's latest words? Follow the newest development in the story. Keep the current expression until the story changes.
choices
  • value
    listening
    description
    Starting a conversation or listening to neutral news
  • value
    sympathetic
    description
    A rough day, setback, or disappointment
  • value
    surprised
    description
    An unexpected twist or a surprise whose outcome is still unknown
  • value
    delighted
    description
    Happy news, a welcome outcome, or excitement
Show full JSONHide JSON
{
  "session": {
    "model": "gpt-live-1",
    "instructions": "You’re a warm, easygoing personal assistant. Speak like a friend one-on-one, with a relaxed, gently expressive voice. If someone asks to tell you about their day, say ‘Of course. How did it go?’ with genuine curiosity. Listen quietly through the pauses. If they share good news, let a smile come through in your voice and give them a short send-off. For movie tickets, say ‘Oh, I love that! Have fun at the movie.’",
    "triggers": [
      {
        "type": "decisions",
        "event_type": "session.input_transcript.delta",
        "decisions": {
          "questions": [
            {
              "type": "choice",
              "name": "expression",
              "instructions": "Which expression should a listening assistant show in response to the user's latest words? Follow the newest development in the story. Keep the current expression until the story changes.",
              "choices": [
                {
                  "value": "listening",
                  "description": "Starting a conversation or listening to neutral news"
                },
                {
                  "value": "sympathetic",
                  "description": "A rough day, setback, or disappointment"
                },
                {
                  "value": "surprised",
                  "description": "An unexpected twist or a surprise whose outcome is still unknown"
                },
                {
                  "value": "delighted",
                  "description": "Happy news, a welcome outcome, or excitement"
                }
              ]
            }
          ]
        }
      }
    ],
    "audio": {
      "output": {
        "voice": "willow"
      }
    }
  },
  "transport": {
    "type": "webrtc",
    "sdp": "<SDP offer from the browser>"
  }
}
OpenAI

GPT-Live

Using a trigger as a guardrail

Suppose GPT-Live tells a caller, “Your order has been canceled.” A Decisions trigger can watch the output transcript and flag a claim that a cancellation succeeded. Your server receives the result over its sideband connection and checks the order record. If the order has already shipped, the server can send session.instructions.append to ask GPT-Live to correct its reply.

For applications that need to review speech before the caller hears it, see Check speech before playback.

Using a trigger to start a delegation

We’ve seen how GPT-Live decides when to delegate to a backend. We can also use a Decisions trigger to predict when a delegation should occur. If GPT-Live hasn’t already delegated, our application can force a delegation.

Step 1 of 5

When we create the session, we set up a Decisions trigger on the user’s input transcript with a predicate question. The instructions for when to delegate depend on the application. For the shopping assistant from Lesson 5, we ask whether the user has given enough information to start a product search.

Our server creates the session with GPT-Live, the Decisions trigger, and the Responses backend.

Decisions returns a probability from 0 to 1, so we need a threshold to decide when a delegation should occur. Let’s say we use 0.75 here. Decisions returns 0.93, which is above that threshold.

Our application then checks whether GPT-Live has already delegated this request. If it hasn’t, it sends response.create to start a delegation.

As before, the browser receives a delegation notice, followed by the Responses events with the same delegation ID. We can use that ID to follow the task through to the answer.

Your application

Browser

Server

model
gpt-live-1.1
instructions
session.delegation
type
responses
responses
model
gpt-6-luna
instructions
tools
  • type
    web_search
session.triggers
type
decisions
event_type
session.input_transcript.delta
decisions
questions
should_delegatetypepredicate
name
should_delegate
type
predicate
instructions
Does the latest request need a product lookup now? A recommendation is ready for search when the shopper has described what the product is for and narrowed the options with concrete buying requirements. A category or broad intended use alone is too early. Consider a reply to a follow-up in the context of the earlier request. If the shopper is still specifying a requirement, wait until it is complete. A request for a specific current price or availability also needs a lookup. General advice or questions already answered by the conversation do not.
Show full JSONHide JSON
{
  "session": {
    "model": "gpt-live-1.1",
    "instructions": "You are Scout, a friendly shopping assistant. If the shopper only names a product category, ask what they plan to use it for. Keep the question short and open-ended. Delegate to the backend when you know what the shopper needs. Wait for its findings before recommending anything. Briefly explain each option and its price in everyday language.",
    "delegation": {
      "type": "responses",
      "responses": {
        "model": "gpt-6-luna",
        "instructions": "Research the shopper's request using the conversation so far. Use web search to check current listings. Recommend up to two options that fit the shopper's needs. For each, give the product name, listed price and one reason it fits. Cite the listing for each price and flag any uncertainty about availability.",
        "tools": [
          {
            "type": "web_search"
          }
        ]
      }
    },
    "triggers": [
      {
        "type": "decisions",
        "event_type": "session.input_transcript.delta",
        "decisions": {
          "questions": [
            {
              "name": "should_delegate",
              "type": "predicate",
              "instructions": "Does the latest request need a product lookup now? A recommendation is ready for search when the shopper has described what the product is for and narrowed the options with concrete buying requirements. A category or broad intended use alone is too early. Consider a reply to a follow-up in the context of the earlier request. If the shopper is still specifying a requirement, wait until it is complete. A request for a specific current price or availability also needs a lookup. General advice or questions already answered by the conversation do not."
            }
          ]
        }
      }
    ]
  },
  "transport": {
    "type": "webrtc",
    "sdp": "<SDP offer from the browser>"
  }
}
OpenAI

GPT-Live

Try it yourself

Use the prompts below to build the demos yourself and see how each application responds as you talk to GPT-Live.

Build the apartment search
@OpenAI Developers, build and run a voice apartment search with GPT-Live and built-in Decisions delegation. Let me describe what I’m looking for and change my preferences as I browse. Show the actual events alongside the listings so I can follow the handoff to Decisions and see how its answers change the search filters. Lesson 6: https://developers.openai.com/api/training/gpt-live/6-built-in-delegation-with-decisions.md
Build the expressive assistant
@OpenAI Developers, build and run a GPT-Live assistant with an avatar that reacts to what I say. Use a Decisions trigger to choose an expression as I speak. Show the actual trigger results beside the avatar so I can see which event changed its expression while the conversation continues. Lesson 6: https://developers.openai.com/api/training/gpt-live/6-built-in-delegation-with-decisions.md