Skip to main content

An integration package connecting Amazon Nova and LangChain

Project description

langchain-amazon-nova

Official LangChain integration for Amazon Nova models.

Amazon Nova is a family of state-of-the-art foundation models from Amazon that includes text, multimodal, and image generation capabilities. This integration provides access to Nova models through LangChain's standardized chat model interface.

Installation

pip install -U langchain-amazon-nova

Or using uv:

uv add langchain-amazon-nova

Quick Start

from langchain_amazon_nova import ChatAmazonNova

# Initialize the model
model = ChatAmazonNova(
    model="nova-pro-v1",
    temperature=0.7,
)

# Use it like any LangChain chat model
response = model.invoke("What is the capital of France?")
print(response.content)

Environment Setup

Set your Nova API credentials:

export NOVA_API_KEY="your-api-key"
export NOVA_BASE_URL="https://api.nova.amazon.com/v1"

Documentation

For detailed API documentation and additional parameters, see: https://nova.amazon.com/dev/documentation

Supported Models

Amazon Nova offers several model variants:

  • nova-micro-v1: Fast, efficient text model (128K context)
  • nova-lite-v1: Lightweight multimodal model (300K context)
  • nova-pro-v1: Balanced multimodal model (300K context)
  • nova-premier-v1: Most capable multimodal model (300K context)

Features

  • Text Generation: All models support text completion
  • Streaming: Token-by-token streaming responses
  • Async Support: Native async/await support
  • Tool Calling: Function calling capabilities (most models)
  • Multimodal Input: Image and video understanding (lite, pro, premier)

Example Usage

Basic Chat

from langchain_amazon_nova import ChatAmazonNova

model = ChatAmazonNova(model="nova-pro-v1")
messages = [
    ("system", "You are a helpful assistant."),
    ("human", "Explain quantum computing in simple terms."),
]
response = model.invoke(messages)
print(response.content)

Streaming

for chunk in model.stream(messages):
    print(chunk.content, end="", flush=True)

Tool Calling

from pydantic import BaseModel, Field

class GetWeather(BaseModel):
    '''Get weather for a location.'''
    location: str = Field(description="City name")

model_with_tools = model.bind_tools([GetWeather])
response = model_with_tools.invoke("What's the weather in Tokyo?")
print(response.tool_calls)

Async

import asyncio

async def main():
    response = await model.ainvoke(messages)
    print(response.content)

asyncio.run(main())

📖 Documentation

📕 Releases & Versioning

See our Releases and Versioning policies.

💁 Contributing

As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.

For detailed information on how to contribute, see the Contributing Guide.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_amazon_nova-1.0.0.tar.gz (87.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_amazon_nova-1.0.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file langchain_amazon_nova-1.0.0.tar.gz.

File metadata

  • Download URL: langchain_amazon_nova-1.0.0.tar.gz
  • Upload date:
  • Size: 87.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_amazon_nova-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4544a5e9ba34ed40a8a3db0a9ff7d3587fd44475236d3996b52aedbdbe58236d
MD5 5a991fdf501ed13f629e8ec026448205
BLAKE2b-256 da71fc7b38e577e639b0a078cb9dc9f01a820a608c0cc548e58c89860d7d9ba3

See more details on using hashes here.

File details

Details for the file langchain_amazon_nova-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_amazon_nova-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71970e3b1ba2298bda7493fcbb005e71b34462ea0ac4e0c1c56e94969c92a9e9
MD5 ff38618d2b0908fe8f9db6bd8b618509
BLAKE2b-256 c2741ee7382362d7fe7ee1935f68105fd8c54e9cf4d54b7203a379255e30e0b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page