Skip to main content

Developer Setup

This guide will continue from the hub quickstart, using the Python or TypeScript SDK to interact with the hub instead of the Playground UI.

This guide assumes you've gone through the Hub Quick Start including login-required steps.

If you don't yet have an account, you'll only be able to pull public objects.

1. Install/upgrade packages​

Note: You likely need to upgrade even if they're already installed!

pip install -U langchain langchainhub langchain-openai

2. Configuring environment variables​

Get an API key for your Personal organization if you have not yet. The hub will not work with your non-personal organization's api key!

export LANGCHAIN_HUB_API_KEY="ls_..."

If you already have LANGCHAIN_API_KEY set to a personal organization’s api key from LangSmith, you can skip this.

3. Pull an object from the hub and use it​

from langchain import hub

# pull a chat prompt
prompt = hub.pull("efriis/my-first-prompt")

# create a model to use it with
from langchain_openai import ChatOpenAI
model = ChatOpenAI()

# use it in a runnable
runnable = prompt | model
response = runnable.invoke({
"profession": "biologist",
"question": "What is special about parrots?",
})

print(response)

4. Push a prompt to your personal organization​

For this step, you'll need the handle for your account!

from langchain import hub
from langchain.prompts.chat import ChatPromptTemplate

prompt = ChatPromptTemplate.from_template("tell me a joke about {topic}")

hub.push("topic-joke-generator", prompt, new_repo_is_public=False)

Was this page helpful?


You can leave detailed feedback on GitHub.