Skip to content

Variable: tools

@providerprotocol/ai


@providerprotocol/ai / openai / tools

const tools: object

Defined in: src/providers/openai/types.ts:1558

Namespace object containing all tool helper constructors.

Provides a convenient way to create built-in tool configurations for the Responses API.

codeInterpreter: (options?) => OpenAICodeInterpreterTool = codeInterpreterTool

Creates a code interpreter tool configuration

Creates a code interpreter tool configuration for the Responses API.

The code interpreter tool allows the model to write and execute Python code in a sandboxed environment.

Optional container configuration

string | OpenAICodeInterpreterContainer

OpenAICodeInterpreterTool

A code interpreter tool configuration object

// Default configuration
const interpreter = codeInterpreterTool();
// With custom container settings
const customInterpreter = codeInterpreterTool({
container: {
type: 'auto',
memory_limit: '4g',
file_ids: ['file_abc123']
}
});

computer: (options) => OpenAIComputerTool = computerTool

Creates a computer tool configuration

Creates a computer tool configuration for the Responses API.

The computer tool enables the model to interact with computer interfaces through mouse and keyboard actions.

Display configuration and environment settings

number

number

OpenAIComputerEnvironment

OpenAIComputerTool

A computer tool configuration object

const computer = computerTool({
display_width: 1920,
display_height: 1080,
environment: { type: 'browser' }
});

fileSearch: (options) => OpenAIFileSearchTool = fileSearchTool

Creates a file search tool configuration

Creates a file search tool configuration for the Responses API.

The file search tool enables the model to search through files in vector stores.

Configuration including vector store IDs and search options

Record<string, unknown>

number

{ ranker?: "auto" | "default_2024_08_21"; score_threshold?: number; }

"auto" | "default_2024_08_21"

number

string[]

OpenAIFileSearchTool

A file search tool configuration object

const fileSearch = fileSearchTool({
vector_store_ids: ['vs_abc123'],
max_num_results: 10
});

imageGeneration: (options?) => OpenAIImageGenerationTool = imageGenerationTool

Creates an image generation tool configuration

Creates an image generation tool configuration for the Responses API.

The image generation tool allows the model to generate images based on prompts.

Optional image generation settings

"auto" | "transparent" | "opaque"

string

"jpeg" | "png" | "webp"

number

"auto" | "low" | "medium" | "high"

"auto" | "1024x1024" | "1024x1536" | "1536x1024"

OpenAIImageGenerationTool

An image generation tool configuration object

// Default configuration
const imageGen = imageGenerationTool();
// With custom settings
const customImageGen = imageGenerationTool({
quality: 'high',
size: '1024x1024',
background: 'transparent'
});

mcp: (options) => OpenAIMcpTool = mcpTool

Creates an MCP tool configuration

Creates an MCP (Model Context Protocol) tool configuration for the Responses API.

The MCP tool enables connections to external MCP servers, allowing the model to use tools and resources provided by those servers.

MCP server configuration

string[] | { type: "all"; }

Record<string, string>

string

"always" | "never" | { tools: string[]; type: "except"; }

string

OpenAIMcpTool

An MCP tool configuration object

const mcp = mcpTool({
url: 'https://mcp-server.example.com',
name: 'my-mcp-server',
allowed_tools: ['tool1', 'tool2']
});

webSearch: (options?) => OpenAIWebSearchTool = webSearchTool

Creates a web search tool configuration

Creates a web search tool configuration for the Responses API.

The web search tool enables the model to search the web for up-to-date information.

Optional configuration for search behavior and user location

"low" | "medium" | "high"

OpenAIWebSearchUserLocation | null

OpenAIWebSearchTool

A web search tool configuration object

// Basic web search
const search = webSearchTool();
// With configuration
const searchWithLocation = webSearchTool({
search_context_size: 'high',
user_location: {
type: 'approximate',
city: 'San Francisco',
country: 'US'
}
});
import { tools } from './types';
const params = {
tools: [
tools.webSearch(),
tools.imageGeneration({ quality: 'high' }),
tools.codeInterpreter()
]
};