04. Check token usage

Check token usage

Copy

# API KEY A configuration file for managing environment variables
from dotenv import load_dotenv

# API KEY load information
load_dotenv()

Copy

True

Copy

# 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")

Copy

 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.

Copy

with get_openai_callback() All token usage/rates running in syntax are tracked.

Copy

Copy

Copy

Copy

Last updated