OpenAI with LangSpend

← Back to Home

Track OpenAI API costs with zero-code attribution

OpenAI Integration

Learn how to track OpenAI API costs with LangSpend. Works with all OpenAI models including GPT-5, GPT-4 and all the other OpenAI models.

Installation

Install required packages

terminal

Basic Setup

Wrap your OpenAI client

index.ts

Chat Completions

GPT-5 Example with Customer & Feature Tracking

💡 Custom Metadata: Use the meta property in customer and feature objects to pass any custom properties for advanced tracking and analytics.

example.tsx