Skip to main content
Open In ColabOpen on GitHub

OpenWebUIAI

This notebook provides a quick overview for getting started with Open WebUI. You can find how to use it in OpenWebUI.

Overviewโ€‹

Integration detailsโ€‹

ClassPackageLocalSerializableJS supportPackage downloadsPackage latest
langchain-openwebuilangchain_communityโŒโœ…โœ…0PyPI - Version

Model featuresโ€‹

Tool callingStructured outputJSON modeImage inputAudio inputVideo inputToken-level streamingNative asyncToken usageLogprobs
โœ…โœ…โœ…โŒโŒโŒโœ…โŒโœ…โœ…

Setupโ€‹

To access OpenWebUI models you'll need to create an Open WebUI account, get an API key.

Credentialsโ€‹

Head to https://docs.openwebui.com/ to sign up for Open WebUI and generate an API key. Once you've done this set the OPENWEBUI_API_KEY environment variable:

Installationโ€‹

Install langchain-openwebui via pypi

pip install langchain-openwebui
Collecting langchain-openwebui
Obtaining dependency information for langchain-openwebui from https://files.pythonhosted.org/packages/92/4a/cdd276af319497ee0baf44ff1faeddf291c8e37c8759afd13e0ca027b4da/langchain_openwebui-0.0.1-py3-none-any.whl.metadata
Downloading langchain_openwebui-0.0.1-py3-none-any.whl.metadata (10 kB)
Downloading langchain_openwebui-0.0.1-py3-none-any.whl (5.4 kB)
DEPRECATION: textract 1.6.5 has a non-standard dependency specifier extract-msg<=0.29.*. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of textract or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063
Installing collected packages: langchain-openwebui
Successfully installed langchain-openwebui-0.0.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
WARNING: There was an error checking the latest version of pip.
Note: you may need to restart the kernel to use updated packages.

Instantiationโ€‹

import os


openwebui_api_key = os.environ["OPENWEBUI_API_KEY"]
openwebui_api_base = os.environ["OPENWEBUI_API_BASE"]
from langchain_community.chat_models import OpenWebUIAI


llm = OpenWebUIAI(
temperature=0.1,
api_key=openwebui_api_key,
api_base=openwebui_api_base,
model="gemini-2.0-pro-exp-02-05",
)
API Reference:OpenWebUIAI

Invocationโ€‹

from langchain_core.messages import HumanMessage


response = llm.invoke(input=[HumanMessage(content="Hello")])
response
API Reference:HumanMessage

Chainingโ€‹

from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough


prompt = ChatPromptTemplate.from_template(
"""please answer the question below: {question}"""
)
retriever_chain = {"question": RunnablePassthrough()} | prompt | llm | StrOutputParser()
AIMessage(content=' Ich liebe Programmieren.\n\n', additional_kwargs={}, response_metadata={}, id='run-ffc4ace1-b73a-4fb3-ad0f-57e60a0f9b8d-0')

API referenceโ€‹

https://docs.openwebui.com/getting-started/api-endpoints


Was this page helpful?