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.1.tar.gz (91.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.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_amazon_nova-1.0.1.tar.gz
  • Upload date:
  • Size: 91.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.1.tar.gz
Algorithm Hash digest
SHA256 a283bfadbae8f688c33bb841493f312167561f16f303e307f4d87a1813c5f54c
MD5 5fed0dd9777bfa10b2e16c453865a1a6
BLAKE2b-256 f61ae1a6a7d196bbaffc4e62ba25228973aa6a9ff07ed132731c576527641589

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_amazon_nova-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e9e5dbcb5e748bc056519b6a331c89ebb764d7ea37f09886144b61727e99f0e
MD5 25090f93ecb9d6f2e32381d0f0ea1f25
BLAKE2b-256 42f934ef5ec38eb1520b890fa382e418a8937d0198e3612e0e2b997594736ac2

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