LangChain ↗ is the most popular framework for building AI applications powered by large language models (LLMs).
LangChain publishes multiple Python packages. The following are provided by the Workers runtime:
langchain↗ (version0.1.8)langchain-core↗ (version0.1.25)langchain-openai↗ (version0.0.6)
Clone thecloudflare/python-workers-examples repository and run the LangChain example:
gitclonehttps://github.com/cloudflare/python-workers-examplescd04-langchainuvrunpywranglerdevfrom workersimport WorkerEntrypoint, Responsefrom langchain_core.promptsimport PromptTemplatefrom langchain_openaiimport OpenAIclassDefault(WorkerEntrypoint):asyncdeffetch(self,request):prompt= PromptTemplate.from_template("Complete the following sentence: I am a{profession} and ")llm=OpenAI(api_key=self.env.API_KEY)chain= prompt| llmres=await chain.ainvoke({"profession":"electrician"})returnResponse(res.split(".")[0].strip())- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark