Please ensure OpenAI library is version 1.0.0 or higher; otherwise, refer to the older doc OpenAI Adapter(Old).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.At the moment this only deals with output and does not return other information (token counts, stop reasons, etc).
Copy
Ask AI
import openaifrom langchain_community.adapters import openai as lc_openai
for c in lc_openai.chat.completions.create( messages=messages, model="claude-2", temperature=0, stream=True, provider="ChatAnthropic",): print(c["choices"][0]["delta"])