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 Responses

In this lesson, we’ll look at delegation, the second key idea behind GPT-Live. GPT-Live can keep talking with you while a backend handles more complex work, then share the result when it’s ready.

User and GPT-Live exchange audio in both directions at the same time. GPT-Live delegates work to Backend system and receives an answer.Input audioOutput audioDelegate workReturn responseUserGPT-LiveBackend systemUser and GPT-Live exchange audio in both directions at the same time. GPT-Live delegates work to Backend system and receives an answer.Input audioOutput audioDelegate workReturn responseUserGPT-LiveBackend system

You can connect GPT-Live to a backend in two ways.

  • With built-in delegation, GPT-Live handles the back and forth with Responses or Decisions. It automatically passes along context from the conversation and brings the result back into the session.
  • With client delegation, your application handles the back and forth between GPT-Live and the backend. This is useful if you want to add voice to an agent you’ve already built or choose what context to send to the backend and what to pass back to GPT-Live.

Let’s start with Responses delegation.

In the example below, you’ll see how GPT-Live delegates to Responses so a shopping assistant can search the web for what the shopper needs.

0:00 / 0:00
Scout

Now let’s walk through how this works.

Step 1 of 8

When our server creates a session, we set the delegation type to responses and choose the backend model and its tools. A tool can run on OpenAI’s servers or in our application. We’ll start with web search, which OpenAI hosts. As before, we tell GPT-Live when to delegate and put the detailed instructions in the backend prompt.

Our server sends the request to OpenAI to create the GPT-Live session and set up the Responses backend.

As the shopper and the assistant talk, GPT-Live automatically keeps track of the conversation.

When GPT-Live decides to delegate, it sends Responses the conversation so far and asks it to continue the task using the backend prompt.

When GPT-Live creates a delegation, the browser gets an event with the delegation ID. Each update from Responses arrives inside a response.event with that same ID, so we can trace the entire task.

Responses uses the conversation and its instructions to decide which tools to call. Here it chooses web search, and the highlighted event shows the queries it used. After reviewing the results, Responses can call a tool again if it needs more information.

Here, Responses has enough information to write an answer. You can see the text stream in along with links to its sources. The highlighted event contains the full answer.

The answer also goes back to GPT-Live automatically, so it can respond to the user out loud.

Your application

Browser

Server

model
gpt-live-1.1
instructions
session.delegation
type
responses
responses
model
gpt-6-luna
instructions
tools
  • type
    web_search
Show full JSONHide JSON
{
  "session": {
    "model": "gpt-live-1.1",
    "audio": {
      "output": {
        "voice": "marin"
      }
    },
    "input": [
      {
        "role": "developer",
        "content": [
          {
            "type": "input_text",
            "text": "Greet the shopper now in English. Say you're Scout, their shopping assistant, and ask what they're looking for. Then pause and listen."
          }
        ]
      }
    ],
    "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",
            "search_content_types": [
              "image",
              "text"
            ],
            "image_settings": {
              "max_results": 10,
              "caption": true
            }
          }
        ]
      }
    }
  },
  "transport": {
    "type": "webrtc",
    "sdp": "<browser SDP offer>"
  }
}
OpenAI

GPT-Live

Using a custom tool with Responses

Now let’s give Responses a custom tool that searches our store’s inventory instead of the web.

Step 1 of 13

Let’s say we already have a tool on our server called search_catalog. It searches the store’s inventory by category and an optional price limit. Here, the inventory is a Markdown file. You can try the tool below and open inventory.md to see all the products.

As before, we set the delegation type to responses and choose the backend model. We add the function definition to tools so Responses knows what search_catalog does and which arguments it accepts.

Our server sends the request to OpenAI. OpenAI creates the GPT-Live session, sets up the Responses backend, and returns the session ID to our server.

In the web search example, events went to the browser. Our custom tool runs on the server, so it uses the session ID to request a sideband connection. OpenAI replies with 101 Switching Protocols. The WebSocket is now open, and our server can receive tool calls directly.

As before, GPT-Live automatically keeps track of the conversation.

When GPT-Live decides to delegate, it passes the conversation so far to Responses.

Now our server gets the same updates as the browser. Over the sideband, it receives the delegation ID and the Responses events associated with it.

Here, Responses calls search_catalog. The highlighted event includes the arguments and a call ID that we’ll send back with the result.

Our server runs the tool with the arguments Responses supplied.

Our server sends the result back with the same call ID so Responses can match it to the tool call.

Responses can call multiple tools in parallel. Once our server has returned a result for every pending call, it asks Responses to continue. The highlighted event tells us the new response has started.

Responses uses the tool results to write its answer, and we can follow along as the text streams in.

As before, the answer goes back to GPT-Live automatically so it can respond out loud.

Your application

Browser

Server

Searching…
OpenAI

GPT-Live

Sharing application context with GPT Live

Let’s say we want users to keep browsing while they talk to GPT Live. Our application can share what they’re looking at so they can ask questions about the page.

Accessories
Terracotta zippered camera case

Compact travel case

Terracotta$39

Fit guide

Fits a Canon EOS R100 or EOS R50 body. Remove the lens before storing either camera.

Scout

0:00 / 0:15

Here’s how we can share application context with GPT Live.

Step 1 of 3

When our server creates a new session, it can include a summary of what the user is looking at in session.input.

As the shopper browses, we can keep GPT Live up to date by sending page changes with session.thinking.append.

The browser can use response.item.create to make an image or screenshot available to a vision-capable Responses model. To have Responses analyze it right away, send response.create. You can also leave the image queued until GPT Live delegates a question about it.

Your application

Browser

Compare cameras

Server

session.input
  1. role: "developer"Current page: Compare cameras. The shopper selected the Canon EOS R100 kit ($499) and EOS R50 kit ($749). Both include an 18–45mm lens.
Show full JSONHide JSON
{
  "session": {
    "input": [
      {
        "type": "message",
        "role": "developer",
        "content": [
          {
            "type": "input_text",
            "text": "Current page: Compare cameras. The shopper selected the Canon EOS R100 kit ($499) and EOS R50 kit ($749). Both include an 18–45mm lens."
          }
        ]
      }
    ],
    "model": "gpt-live-1.1",
    "audio": {
      "output": {
        "voice": "marin"
      }
    },
    "delegation": {
      "type": "responses",
      "responses": {
        "model": "gpt-6-luna",
        "instructions": "Answer the question about the supplied screenshot in a single short sentence."
      }
    },
    "instructions": "You are a shopping assistant. When a spoken question refers to a screenshot, delegate it to Responses. Use the backend answer to respond briefly."
  },
  "transport": {
    "type": "webrtc",
    "sdp": "<SDP offer from the browser>"
  }
}
OpenAI

GPT-Live

Try it yourself

Use the prompt below to build your own shopping assistant with Codex. Try the same request with each tool and follow the events to see how GPT-Live and Responses work together.

Build the shopping assistant
@OpenAI Developers, build and run a voice shopping assistant with GPT-Live and built-in Responses delegation. Let me try the same shopping question first with web search, then with a custom tool that searches the store’s catalog. Show the actual events alongside the conversation so I can follow the handoff to Responses, see the tool call, and hear GPT-Live answer when the result comes back. Lesson 5: https://developers.openai.com/api/training/gpt-live/5-built-in-delegation-with-responses.md