OpenAI large language models. To use, you should have the ``openai`` python package installed, and the environment variable ``OPENAI_API_KEY`` set with your API key. Any parameters that are valid to be passed to the openai.create call can be passed in, even if not explicitly saved
| 731 | since="0.0.10", removal="0.3.0", alternative_import="langchain_openai.OpenAI" |
| 732 | ) |
| 733 | class OpenAI(BaseOpenAI): |
| 734 | """OpenAI large language models. |
| 735 | |
| 736 | To use, you should have the ``openai`` python package installed, and the |
| 737 | environment variable ``OPENAI_API_KEY`` set with your API key. |
| 738 | |
| 739 | Any parameters that are valid to be passed to the openai.create call can be passed |
| 740 | in, even if not explicitly saved on this class. |
| 741 | |
| 742 | Example: |
| 743 | .. code-block:: python |
| 744 | |
| 745 | from langchain_community.llms import OpenAI |
| 746 | openai = OpenAI(model_name="gpt-3.5-turbo-instruct") |
| 747 | """ |
| 748 | |
| 749 | @classmethod |
| 750 | def get_lc_namespace(cls) -> List[str]: |
| 751 | """Get the namespace of the langchain object.""" |
| 752 | return ["langchain", "llms", "openai"] |
| 753 | |
| 754 | @property |
| 755 | def _invocation_params(self) -> Dict[str, Any]: |
| 756 | return {**{"model": self.model_name}, **super()._invocation_params} |
| 757 | |
| 758 | |
| 759 | @deprecated( |
no outgoing calls