Toggle Menu
Prev Up Next

# `langchain.chains.openai_functions.openapi`.get_openapi_chain

langchain.chains.openai_functions.openapi.get_openapi_chain(spec: Union[OpenAPISpec, str], llm: Optional[BaseLanguageModel] = None, prompt: Optional[BasePromptTemplate] = None, request_chain: Optional[Chain] = None, llm_chain_kwargs: Optional[Dict] = None, verbose: bool = False, headers: Optional[Dict] = None, params: Optional[Dict] = None, **kwargs: Any) → SequentialChain

  Create a chain for querying an API from a OpenAPI spec.

  Parameters

    - spec (Union[OpenAPISpec, str]) – OpenAPISpec or url/file/text string corresponding to one.

    - llm (Optional[BaseLanguageModel]) – language model, should be an OpenAI function-calling model, e.g. ChatOpenAI(model=”gpt-3.5-turbo-0613”).

    - prompt (Optional[BasePromptTemplate]) – Main prompt template to use.

    - request_chain (Optional[Chain]) – Chain for taking the functions output and executing the request.

    - llm_chain_kwargs (Optional[Dict]) –

    - verbose (bool) –

    - headers (Optional[Dict]) –

    - params (Optional[Dict]) –

    - kwargs (Any) –

  Return type

    SequentialChain

# Examples using get_openapi_chain

- Set env var OPENAI_API_KEY or load from a .env file: