{"id":9065,"library":"langchain-sambanova","title":"SambaNova LangChain Integration","description":"An integration package connecting SambaNova and LangChain, enabling developers to leverage SambaNova's large language models. It provides chat models (`ChatSambaNova`) and embedding models (`SambaNovaEmbeddings`) for seamless interaction with SambaCloud and SambaStack. The current version is 1.1.0, with a regular release cadence that incorporates new features and ensures compatibility with LangChain updates.","status":"active","version":"1.1.0","language":"en","source_language":"en","source_url":"https://github.com/sambanova/langchain-sambanova","tags":["LangChain","LLM","SambaNova","AI","Embeddings","Chat","Cloud"],"install":[{"cmd":"pip install langchain-sambanova","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core components of LangChain are required for integration classes and proper serialization handling.","package":"langchain-core","optional":false},{"reason":"The umbrella package for the LangChain framework, providing essential utilities and abstractions for building LLM applications.","package":"langchain","optional":false},{"reason":"The underlying official SambaNova Python SDK that the LangChain integration package builds upon.","package":"sambanova","optional":false}],"imports":[{"note":"Primary class for interacting with SambaNova chat models.","symbol":"ChatSambaNova","correct":"from langchain_sambanova import ChatSambaNova"},{"note":"Primary class for interacting with SambaNova embedding models.","symbol":"SambaNovaEmbeddings","correct":"from langchain_sambanova import SambaNovaEmbeddings"},{"note":"While 'SambaStudio' exists in `langchain_community`, the dedicated `langchain-sambanova` package provides `ChatSambaNova` and `SambaNovaEmbeddings` as the current and recommended interfaces for SambaNova models. The `langchain_community.llms.SambaStudio` is part of an older or broader integration.","wrong":"from langchain_sambanova import SambaStudio","symbol":"SambaStudio","correct":"from langchain_community.llms import SambaStudio"}],"quickstart":{"code":"import os\nfrom langchain_sambanova import ChatSambaNova\nfrom langchain_core.messages import HumanMessage\n\n# Ensure SAMBANOVA_API_KEY is set as an environment variable\n# For SambaStack, SAMBANOVA_API_BASE might also be required.\nos.environ['SAMBANOVA_API_KEY'] = os.environ.get('SAMBANOVA_API_KEY', 'your_sambanova_api_key_here')\n\n# Initialize the SambaNova Chat model\nllm = ChatSambaNova(\n    model=\"Meta-Llama-3.3-70B-Instruct\",  # Replace with your desired model\n    max_tokens=1024,\n    temperature=0.7,\n    top_p=0.01,\n)\n\n# Invoke the model with a message\nmessages = [\n    (\"system\", \"You are a helpful assistant that translates English to French.\"),\n    (\"human\", \"I love programming.\"),\n]\n\nresponse = llm.invoke(messages)\nprint(response.content)\n\n# Example for embeddings\nfrom langchain_sambanova import SambaNovaEmbeddings\n\nembeddings = SambaNovaEmbeddings(model=\"E5-Mistral-7B-Instruct\") # Replace with your desired embedding model\n\nquery_embedding = embeddings.embed_query(\"What is the meaning of life?\")\nprint(f\"Embedding snippet: {str(query_embedding)[:50]}...\")","lang":"python","description":"This quickstart demonstrates how to set up and use the `ChatSambaNova` model for chat completions and `SambaNovaEmbeddings` for text embeddings. It requires setting `SAMBANOVA_API_KEY` (and optionally `SAMBANOVA_API_BASE` for SambaStack) as environment variables."},"warnings":[{"fix":"Upgrade to `langchain-sambanova>=1.1.0` and `langchain-core>=1.2.0`. Review any custom serialization logic or message parsing that interacts with `AIMessage` content.","message":"Version 1.1.0 includes fixes related to 'langchain-core 1.2+ security restrictions' and handling of 'AIMessage content_blocks format'. Older code relying on previous serialization behavior or specific AIMessage structures with `langchain-core < 1.2` might break or behave unexpectedly.","severity":"breaking","affected_versions":"<1.1.0"},{"fix":"Ensure `export SAMBANOVA_API_KEY=\"your-key-here\"` is run in your environment. For SambaStack, also set `export SAMBANOVA_API_BASE=\"your-base-url-here\"`.","message":"Authentication requires setting environment variables `SAMBANOVA_API_KEY` and, for SambaStack users, `SAMBANOVA_API_BASE`. Failing to set these will result in authentication errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the official SambaNova LangChain documentation and the library's GitHub README for any migration guides or updated API signatures when upgrading to version 1.0.0 or higher.","message":"The jump from `v0.2.0` to `v1.0.0` often indicates significant changes and potential API breakage, even if not explicitly detailed in the changelog as 'breaking'. Users upgrading across this major version boundary should expect refactorings.","severity":"breaking","affected_versions":"Upgrading from <1.0.0 to >=1.0.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install langchain-sambanova` to install the package. Ensure your environment is activated if using virtual environments.","cause":"The `langchain-sambanova` package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'langchain_sambanova'"},{"fix":"Set the environment variable: `export SAMBANOVA_API_KEY=\"your_api_key_here\"` (replace with your actual API key from cloud.sambanova.ai). For SambaStack, also set `SAMBANOVA_API_BASE`.","cause":"The `SAMBANOVA_API_KEY` environment variable, which is required for authenticating with SambaNova services, has not been set.","error":"ValueError: Did not find sensibility_api_key, please add an environment variable SAMBANOVA_API_KEY"},{"fix":"Upgrade both `langchain-sambanova` and `langchain-core` to their latest versions: `pip install -U langchain-sambanova langchain-core`.","cause":"An older version of `langchain-core` or `langchain-sambanova` is being used which does not correctly handle the `AIMessage` content block format, a common issue fixed in `langchain-sambanova` v1.1.0.","error":"Failed to serialize object: The `content_blocks` field for `AIMessage` is not supported with this `langchain-core` version."}]}