text: Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKIntegrationsCallbacksChat modelsDocument loadersDocument transformersLLMsMemoryRetrieversText embedding modelsAleph AlphaAzureOpenAIBedrock EmbeddingsClarifaiCohereDashScopeDeepInfraElasticsearchEmbaasFake EmbeddingsGoogle Cloud Platform Vertex AI PaLMGPT4AllHugging Face HubInstructEmbeddingsJinaLlama-cppLocalAIMiniMaxModelScopeMosaicML embeddingsNLP CloudOpenAISageMaker Endpoint EmbeddingsSelf Hosted EmbeddingsSentence Transformers EmbeddingsSpacy EmbeddingTensorflowHubAgent toolkitsToolsVector storesGrouped by providerIntegrationsText embedding modelsElasticsearchOn this pageElasticsearchWalkthrough of how to generate embeddings using a hosted embedding model in ElasticsearchThe easiest way to instantiate the ElasticsearchEmbeddings class it eitherusing the from_credentials constructor if you are using Elastic Cloudor using the from_es_connection constructor with any Elasticsearch clusterpip -q install elasticsearch langchainimport elasticsearchfrom langchain.embeddings.elasticsearch import ElasticsearchEmbeddings# Define the model IDmodel_id = "your_model_id"Testing with from_credentialsâ€‹This required an Elastic Cloud cloud_id# Instantiate ElasticsearchEmbeddings using credentialsembeddings = ElasticsearchEmbeddings.from_credentials(    model_id,    es_cloud_id="your_cloud_id",    es_user="your_user",    es_password="your_password",)# Create embeddings for multiple documentsdocuments = [    "This is an example document.",    "Another example document to generate embeddings for.",]document_embeddings = embeddings.embed_documents(documents)# Print document embeddingsfor i, embedding in enumerate(document_embeddings):    print(f"Embedding for document {i+1}: {embedding}")# Create an embedding for a single