Skip to main content

PromptLayer

PromptLayer is a platform for prompt engineering. It also helps with the LLM observability to visualize requests, version prompts, and track usage.

While PromptLayer does have LLMs that integrate directly with LangChain (e.g. PromptLayerOpenAI), using a callback is the recommended way to integrate PromptLayer with LangChain.

Installation and Setupโ€‹

To work with PromptLayer, we have to:

  • Create a PromptLayer account
  • Create an api token and set it as an environment variable (PROMPTLAYER_API_KEY)

Install a Python package:

pip install promptlayer

Callbackโ€‹

See a usage example.

import promptlayer  # Don't forget this import!
from langchain.callbacks import PromptLayerCallbackHandler

LLMโ€‹

See a usage example.

from langchain_community.llms import PromptLayerOpenAI
API Reference:PromptLayerOpenAI

Chat Modelsโ€‹

See a usage example.

from langchain_community.chat_models import PromptLayerChatOpenAI
API Reference:PromptLayerChatOpenAI

Was this page helpful?