04. Check token usage
Check token usage
# API KEY A configuration file for managing environment variables
from dotenv import load_dotenv
# API KEY load information
load_dotenv()True# LangSmith set up tracking. https://smith.langchain.com
# !pip install langchain-teddynote
from langchain_teddynote import logging
# Enter a project name.
logging.langsmith("CH04-Models") Start tracking LangSmith.
[Project name]
CH04-Models Describes how to track the use of tokens for specific calls.
This feature is currently only implemented in the OpenAI API.
First, let's look at a very simple example of tracking the token usage for a single Chat model call.
with get_openai_callback() All token usage/rates running in syntax are tracked.
Last updated