Class HostedTool

java.lang.Object
ai.acolite.agentsdk.core.HostedTool
All Implemented Interfaces:
Tool<Object>

public class HostedTool extends Object implements Tool<Object>
HostedTool

Represents tools that execute on OpenAI's hosted infrastructure rather than in your application. These tools are provided and maintained by OpenAI.

Currently supported hosted tools:

  • web_search - Search the web for current information
  • image_generation - Generate images using DALL-E

Note: Other OpenAI hosted tools like file_search, code_interpreter, and computer_use are not yet supported by this SDK. Attempting to use them will throw an UnsupportedOperationException.

Unlike FunctionTool, hosted tools execute remotely on OpenAI's servers. You configure them but do not implement their execution logic.

Example usage:


 // Web search
 Agent<Object, TextOutput> agent = Agent.builder()
     .instructions("You can search the web for current information.")
     .tools(List.of(HostedTool.webSearch()))
     .build();

 // Image generation
 Agent<Object, TextOutput> agent = Agent.builder()
     .instructions("You can generate images using DALL-E.")
     .tools(List.of(HostedTool.imageGeneration()))
     .build();

 // Multiple hosted tools
 Agent<Object, TextOutput> agent = Agent.builder()
     .tools(List.of(
         HostedTool.webSearch(),
         HostedTool.imageGeneration()
     ))
     .build();
 

Source: openai-agents-js/tool.ts

See Also:
  • Constructor Details

    • HostedTool

      public HostedTool()
  • Method Details

    • webSearch

      public static HostedTool webSearch()
      Create a web search hosted tool.
      Returns:
      HostedTool configured for web search
    • fileSearch

      @Deprecated public static HostedTool fileSearch(String vectorStoreId)
      Deprecated.
      file_search is not yet supported by this SDK
      Create a file search hosted tool.
      Parameters:
      vectorStoreId - OpenAI vector store ID to search
      Returns:
      HostedTool configured for file search
      Throws:
      UnsupportedOperationException - file_search is not yet supported by this SDK
    • codeInterpreter

      @Deprecated public static HostedTool codeInterpreter()
      Deprecated.
      code_interpreter is not yet supported by this SDK
      Create a code interpreter hosted tool.
      Returns:
      HostedTool configured for code interpreter
      Throws:
      UnsupportedOperationException - code_interpreter is not yet supported by this SDK
    • imageGeneration

      public static HostedTool imageGeneration()
      Create an image generation hosted tool.
      Returns:
      HostedTool configured for image generation