OpenAI GPT OSS

View as Markdown

OpenAI’s open-weight GPT OSS models (gpt-oss-120b and gpt-oss-20b) support a browser tool for real-time web access. You.com is the default backend for this browser tool — providing search, page retrieval, and content extraction via the Search API.

When a GPT OSS model needs to search the web, open a page, or find content, it calls You.com under the hood.


Getting Started

Install the package

$pip install gpt-oss

Set your API key

$export YDC_API_KEY=your_api_key

Get your API key at you.com/platform/api-keys.


Usage

Set up the browser tool with YouComBackend

YouComBackend connects GPT OSS’s browser tool to You.com’s Search API. The model uses three methods: search to find pages, open to load a URL, and find to locate content within a page.

1import datetime
2from gpt_oss.tools.simple_browser import SimpleBrowserTool
3from gpt_oss.tools.simple_browser.backend import YouComBackend
4from openai_harmony import (
5 SystemContent,
6 Message,
7 Conversation,
8 Role,
9 load_harmony_encoding,
10 HarmonyEncodingName,
11)
12
13encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
14
15backend = YouComBackend(source="web")
16browser_tool = SimpleBrowserTool(backend=backend)
17
18system_content = (
19 SystemContent.new()
20 .with_conversation_start_date(datetime.datetime.now().strftime("%Y-%m-%d"))
21 .with_tools(browser_tool.tool_config)
22)
23
24system_message = Message.from_role_and_content(Role.SYSTEM, system_content)
25user_message = Message.from_role_and_content(
26 Role.USER, "What's the latest news on AI regulation?"
27)
28
29conversation = Conversation.from_messages([system_message, user_message])
30token_ids = encoding.render_conversation_for_completion(conversation, Role.ASSISTANT)
31
32# Run inference with your chosen backend (triton, vLLM, etc.)
33output_tokens = your_inference_engine(token_ids)
34
35# Parse the model's response
36messages = encoding.parse_messages_from_completion_tokens(output_tokens, Role.ASSISTANT)
37last_message = messages[-1]
38
39# If the model invokes the browser tool, process the call and re-run inference
40if last_message.recipient.startswith("browser"):
41 response_messages = await browser_tool.process(last_message)
42 messages.extend(response_messages)

How the browser tool works

The model interacts with the browser via three callable actions:

ActionDescription
searchSearches for a query using You.com Search API
openOpens a specific URL and returns a scrollable window of content
findLooks for specific text on the currently open page

The tool uses a scrollable content window to manage context length — the model can fetch an initial set of lines from a page, then scroll forward to load more. This keeps token usage under control while still giving the model access to full page content.

Requests are cached per session, so the model can revisit different sections of a page without triggering another fetch. For this reason, create a new SimpleBrowserTool instance for each request.

The model also uses citations from the browser tool in its answers, linking back to the sources it consulted.


Resources