Toggle Menu
Prev Up Next

# `langchain_community.agent_toolkits.openapi.planner`.create_openapi_agent

langchain_community.agent_toolkits.openapi.planner.create_openapi_agent(api_spec: ReducedOpenAPISpec, requests_wrapper: TextRequestsWrapper, llm: BaseLanguageModel, shared_memory: Optional[Any] = None, callback_manager: Optional[BaseCallbackManager] = None, verbose: bool = True, agent_executor_kwargs: Optional[Dict[str, Any]] = None, allow_dangerous_requests: bool = False, **kwargs: Any) → Any

  Construct an OpenAI API planner and controller for a given spec.

  Inject credentials via requests_wrapper.

  We use a top-level “orchestrator” agent to invoke the planner and controller, rather than a top-level planner that invokes a controller with its plan. This is to keep the planner simple.

  You need to set allow_dangerous_requests to True to use Agent with BaseRequestsTool. Requests can be dangerous and can lead to security vulnerabilities. For example, users can ask a server to make a request to an internal server. It’s recommended to use requests through a proxy server and avoid accepting inputs from untrusted sources without proper sandboxing. Please see: https://python.langchain.com/docs/security for further security information.

  Parameters

    - api_spec (ReducedOpenAPISpec) –

    - requests_wrapper (TextRequestsWrapper) –

    - llm (BaseLanguageModel) –

    - shared_memory (Optional[Any]) –

    - callback_manager (Optional[BaseCallbackManager]) –

    - verbose (bool) –

    - agent_executor_kwargs (Optional[Dict[str, Any]]) –

    - allow_dangerous_requests (bool) –

    - kwargs (Any) –

  Return type

    Any

# Examples using create_openapi_agent

- NOTE: In this example. We must set `allow_dangerous_request=True` to enable the OpenAPI Agent to automatically use the Request Tool.