> ## Documentation Index
> Fetch the complete documentation index at: https://promptlayer-1023-gorgias-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

PromptLayer takes less than 5 minutes to get started.

* Sign up for an account at [www.promptlayer.com](http://www.promptlayer.com)
* Grab an API key from PromptLayer.

It's super easy to add PromptLayer to an existing project. Usually only takes one line.

**Get started with the code below!**

<CodeGroup>
  ```python Python openai >= 1.0.0
  # Make sure to `pip install promptlayer`
  import promptlayer

  # Swap out your 'from openai import OpenAI'
  OpenAI = promptlayer.openai.OpenAI
  client = OpenAI()

  # Do something fun 🚀
  completion = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[
      {"role": "system", "content": "You are an AI."},
      {"role": "user", "content": "Compose a poem please."}
    ],
    pl_tags=["getting-started"]
  )
  ```

  ```python Python openai < 1.0.0
  # Make sure to `pip install promptlayer`
  import promptlayer

  # Swap out your 'import openai'
  openai = promptlayer.openai

  # Do something fun 🚀
  openai.Completion.create(
    engine="gpt-3.5-turbo-instruct", 
    prompt="My name is", 
    pl_tags=["name-guessing", "pipeline-2"]
  )
  ```

  ```js JavaScript
  // Make sure to `npm install promptlayer`
  import { promptlayer } from "promptlayer";

  // Swap out your 'import openai'
  const OpenAI = promptlayer.OpenAI;
  const openai = new OpenAI();

  // Do something fun 🚀
  openai.completions.create({
    model: "gpt-3.5-turbo-instruct"
    prompt: "My name is",
  })
  ```

  ```python Python with LangChain
  # Make sure to `pip install promptlayer`
  import promptlayer
  from langchain.callbacks import PromptLayerCallbackHandler

  # Using OpenAI completions
  from langchain.llms import OpenAI
  llm = OpenAI(
      model_name="gpt-3.5-turbo-instruct",
      callbacks=[PromptLayerCallbackHandler(pl_tags=["langchain"])]
  )
  llm("My name is")

  # Using OpenAI chat
  from langchain.chat_models import ChatOpenAI
  from langchain.schema import (SystemMessage, HumanMessage)
  chat = ChatOpenAI(callbacks=[PromptLayerCallbackHandler(pl_tags=["langchain"])])
  chat_llm([
    SystemMessage(content="You are an AI assistant."),
    HumanMessage(content="What's your name?")
  ])
  ```

  ```js JS/TS with Langchain
  // Install with `npm install langchain`

  // Using OpenAI completions
  const { PromptLayerOpenAI } = require("langchain/llms/openai");
  const llm = new PromptLayerOpenAI({
    temperature: 0.9,
    openAIApiKey: "YOUR-API-KEY", // Replace with your OpenAI API key
    promptLayerApiKey: "YOUR-API-KEY", // Replace with your PromptLayer API key
  });
  llm.call("How do I use PromptLayer with OpenAIChat?").then(console.log);

  // Using OpenAI chat
  const { PromptLayerChatOpenAI } = require("langchain/chat_models/openai");
  const { SystemChatMessage } = require("langchain/schema");
  const chat = new PromptLayerChatOpenAI({
      returnPromptLayerId: true,
      openAIApiKey: "YOUR-API-KEY", // Replace with your OpenAI API key
      promptLayerApiKey: "YOUR-API-KEY", // Replace with your PromptLayer API key
      });
  chat.generate([
    [new SystemChatMessage("You are a helpful AI assistant."),],
  ]).then(console.log);
  ```

  ```txt REST
  curl --location --request POST 'https://api.promptlayer.com/rest/track-request' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "function_name": "openai.Completion.create",
      "kwargs": {"engine": "text-ada-001", "prompt": "My name is"},
      "tags": ["promptlayer-test"],
      "request_response": {...},
      "request_start_time": 1673987077.463504,
      "request_end_time": 1673987077.463504,
      "api_key": "pl_<YOUR API KEY>"
  }'
  ```
</CodeGroup>
