Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesAdaptersOpenAI AdapterDebuggingDeploymentEvaluationFallbacksLangSmithRun LLMs locallyModel comparisonPrivacyPydantic compatibilitySafetyMoreGuidesAdaptersOpenAI AdapterOn this pageOpenAI AdapterA lot of people get started with OpenAI but want to explore other models. LangChain's integrations with many model providers make this easy to do so. While LangChain has it's own message and model APIs, we've also made it as easy as possible to explore other models by exposing an adapter to adapt LangChain models to the OpenAI api.At the moment this only deals with output and does not return other information (token counts, stop reasons, etc).import openaifrom langchain.adapters import openai as lc_openaiChatCompletion.create‚Äãmessages = [{"role": "user", "content": "hi"}]Original OpenAI callresult = openai.ChatCompletion.create(    messages=messages,     model="gpt-3.5-turbo",     temperature=0)result["choices"][0]['message'].to_dict_recursive()    {'role': 'assistant', 'content': 'Hello! How can I assist you today?'}LangChain OpenAI wrapper calllc_result = lc_openai.ChatCompletion.create(    messages=messages,     model="gpt-3.5-turbo",     temperature=0)lc_result["choices"][0]['message']    {'role': 'assistant', 'content': 'Hello! How can I assist you today?'}Swapping out model providerslc_result = lc_openai.ChatCompletion.create(    messages=messages,     model="claude-2",     temperature=0,     provider="ChatAnthropic")lc_result["choices"][0]['message']    {'role': 'assistant', 'content': ' Hello!'}ChatCompletion.stream‚ÄãOriginal OpenAI callfor c in openai.ChatCompletion.create(    messages = messages,    model="gpt-3.5-turbo",
A lot of people get started with OpenAI but want to explore other models. LangChain's integrations with many model providers make this easy to do so. While LangChain has it's own message and model APIs, we've also made it as easy as possible to explore other models by exposing an adapter to adapt LangChain models to the OpenAI api.
A lot of people get started with OpenAI but want to explore other models. LangChain's integrations with many model providers make this easy to do so. While LangChain has it's own message and model APIs, we've also made it as easy as possible to explore other models by exposing an adapter to adapt LangChain models to the OpenAI api. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsMemoryAgentsCallbacksModulesSecurityGuidesAdaptersOpenAI AdapterDebuggingDeploymentEvaluationFallbacksLangSmithRun LLMs locallyModel comparisonPrivacyPydantic compatibilitySafetyMoreGuidesAdaptersOpenAI AdapterOn this pageOpenAI AdapterA lot of people get started with OpenAI but want to explore other models. LangChain's integrations with many model providers make this easy to do so. While LangChain has it's own message and model APIs, we've also made it as easy as possible to explore other models by exposing an adapter to adapt LangChain models to the OpenAI api.At the moment this only deals with output and does not return other information (token counts, stop reasons, etc).import openaifrom langchain.adapters import openai as lc_openaiChatCompletion.create‚Äãmessages = [{"role": "user", "content": "hi"}]Original OpenAI callresult = openai.ChatCompletion.create(    messages=messages,     model="gpt-3.5-turbo",     temperature=0)result["choices"][0]['message'].to_dict_recursive()    {'role': 'assistant', 'content': 'Hello! How can I assist you today?'}LangChain OpenAI wrapper calllc_result = lc_openai.ChatCompletion.create(    messages=messages,     model="gpt-3.5-turbo",     temperature=0)lc_result["choices"][0]['message']    {'role': 'assistant', 'content': 'Hello! How can I assist you today?'}Swapping out model providerslc_result = lc_openai.ChatCompletion.create(    messages=messages,     model="claude-2",     temperature=0,     provider="ChatAnthropic")lc_result["choices"][0]['message']    {'role': 'assistant', 'content': ' Hello!'}ChatCompletion.stream‚ÄãOriginal OpenAI callfor c in openai.ChatCompletion.create(    messages = messages,    model="gpt-3.5-turbo",