Skip to main content
`Ctrl`+`K`

# OpenAI

Let’s load the OpenAI Embedding class.

    from langchain.embeddings import OpenAIEmbeddings

    embeddings = OpenAIEmbeddings()

    text = "This is a test document."

    query_result = embeddings.embed_query(text)

    doc_result = embeddings.embed_documents([text])

Let’s load the OpenAI Embedding class with first generation models (e.g. text-search-ada-doc-001/text-search-ada-query-001). Note: These are not recommended models - see here

    from langchain.embeddings.openai import OpenAIEmbeddings

    embeddings = OpenAIEmbeddings(model_name="ada")

    text = "This is a test document."

    query_result = embeddings.embed_query(text)

    doc_result = embeddings.embed_documents([text])