Logging LLM Generations, Agent Runs or Conversation Threads
1
Install the Literal AI package
pip install literalai
npm i @literalai/client
2
Instantiate the Literal AI client
import osfrom literalai import LiteralClient# Not compatible with gunicorn's --preload flagliteralai_client = LiteralClient(api_key=os.getenv("LITERAL_API_KEY")) # This is the default and can be omitted
import { LiteralClient } from '@literalai/client';const literalAiClient = new LiteralClient({apiKey: process.env["LITERAL_API_KEY"]}); // This is the default and can be omitted
3
Get your Literal AI API Key
Go to your project page and click on the Settings tab. You will find your API key in the API Key section.