Skip to main content
This will help you get started with Contextual AI’s Grounded Language Model chat models. To learn more about Contextual AI, please visit our documentation. This integration requires the contextual-client Python SDK. Learn more about it here.

Overview

This integration invokes Contextual AI’s Grounded Language Model.

Integration details

Model features

Setup

To access Contextual models you’ll need to create a Contextual AI account, get an API key, and install the langchain-contextual integration package.

Credentials

Head to app.contextual.ai to sign up to Contextual and generate an API key. Once you’ve done this set the CONTEXTUAL_AI_API_KEY environment variable:
If you want to get automated tracing of your model calls you can also set your LangSmith API key by uncommenting below:

Installation

The LangChain Contextual integration lives in the langchain-contextual package:

Instantiation

Now we can instantiate our model object and generate chat completions. The chat client can be instantiated with these following additional settings:

Invocation

The Contextual Grounded Language Model accepts additional kwargs when calling the ChatContextual.invoke method. These additional inputs are:

Chaining

We can chain the Contextual Model with output parsers.

API reference

For detailed documentation of all ChatContextual features and configurations head to the Github page: github.com/ContextualAI//langchain-contextual