Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKProvidersAnthropicAWSGoogleMicrosoftOpenAIMoreComponentsLLMsChat modelsDocument loadersDocument transformersText embedding modelsVector storesRetrieversToolsAgents and toolkitsMemoryCallbacksArgillaConfidentContextInfinoLabel StudioLLMonitorPromptLayerSageMaker TrackingStreamlitTrubricsChat loadersComponentsCallbacksContextOn this pageContextContext provides user analytics for LLM powered products and features.With Context, you can start understanding your users and improving their experiences in less than 30 minutes.In this guide we will show you how to integrate with Context.Installation and Setup‚Äã$ pip install context-python --upgradeGetting API Credentials‚ÄãTo get your Context API token:Go to the settings page within your Context account (https://with.context.ai/settings).Generate a new API Token.Store this token somewhere secure.Setup Context‚ÄãTo use the ContextCallbackHandler, import the handler from Langchain and instantiate it with your Context API token.Ensure you have installed the context-python package before using the handler.import osfrom langchain.callbacks import ContextCallbackHandlertoken = os.environ["CONTEXT_API_TOKEN"]context_callback = ContextCallbackHandler(token)Usage‚ÄãUsing the Context callback within a chat model‚ÄãThe Context callback handler can be used to directly record transcripts between users and AI assistants.Example‚Äãimport osfrom langchain.chat_models import ChatOpenAIfrom langchain.schema import (    SystemMessage,    HumanMessage,)from langchain.callbacks import ContextCallbackHandlertoken = os.environ["CONTEXT_API_TOKEN"]chat = ChatOpenAI(    headers={"user_id": "123"}, temperature=0, callbacks=[ContextCallbackHandler(token)])messages = [    SystemMessage(        content="You are a helpful assistant that translates English to French."    ),    HumanMessage(content="I love
Context - User Analytics for LLM Powered Products
Context - User Analytics for LLM Powered Products ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKProvidersAnthropicAWSGoogleMicrosoftOpenAIMoreComponentsLLMsChat modelsDocument loadersDocument transformersText embedding modelsVector storesRetrieversToolsAgents and toolkitsMemoryCallbacksArgillaConfidentContextInfinoLabel StudioLLMonitorPromptLayerSageMaker TrackingStreamlitTrubricsChat loadersComponentsCallbacksContextOn this pageContextContext provides user analytics for LLM powered products and features.With Context, you can start understanding your users and improving their experiences in less than 30 minutes.In this guide we will show you how to integrate with Context.Installation and Setup‚Äã$ pip install context-python --upgradeGetting API Credentials‚ÄãTo get your Context API token:Go to the settings page within your Context account (https://with.context.ai/settings).Generate a new API Token.Store this token somewhere secure.Setup Context‚ÄãTo use the ContextCallbackHandler, import the handler from Langchain and instantiate it with your Context API token.Ensure you have installed the context-python package before using the handler.import osfrom langchain.callbacks import ContextCallbackHandlertoken = os.environ["CONTEXT_API_TOKEN"]context_callback = ContextCallbackHandler(token)Usage‚ÄãUsing the Context callback within a chat model‚ÄãThe Context callback handler can be used to directly record transcripts between users and AI assistants.Example‚Äãimport osfrom langchain.chat_models import ChatOpenAIfrom langchain.schema import (    SystemMessage,    HumanMessage,)from langchain.callbacks import ContextCallbackHandlertoken = os.environ["CONTEXT_API_TOKEN"]chat = ChatOpenAI(    headers={"user_id": "123"}, temperature=0, callbacks=[ContextCallbackHandler(token)])messages = [    SystemMessage(        content="You are a helpful assistant that translates English to French."    ),    HumanMessage(content="I love