LangChain.Providers.OpenAI (langchainex v0.2.3)

OpenAI results return a body that will contain: 'usage': {'prompt_tokens': 56, 'completion_tokens': 31, 'total_tokens': 87}

OpenAI Pricing Model Prompt Completion gpt-4 8K context $0.03 / 1K tokens $0.06 / 1K tokens 32K context $0.06 / 1K tokens $0.12 / 1K tokens

gpt-3.5-turbo $0.002 / 1K tokens

instructGPT (only models you can fine tune) Ada $0.0004 / 1K tokens Babbage $0.0005 / 1K tokens Curie $0.0020 / 1K tokens Davinci $0.0200 / 1K tokens Fine-tuning: Ada $0.0004 / 1K tokens $0.0016 / 1K tokens Babbage $0.0006 / 1K tokens $0.0024 / 1K tokens Curie $0.0030 / 1K tokens $0.0120 / 1K tokens Davinci $0.0300 / 1K tokens $0.1200 / 1K tokens

embeddings Ada $0.0004 / 1K tokens

Link to this section Summary

Functions

Used to report the price of a response from OpenAI Needs to implement callbacks to a master pricing tracker

Link to this section Functions

Link to this function

get_pricing_structure(model_name)

Link to this function

report_price(model, response)

Used to report the price of a response from OpenAI Needs to implement callbacks to a master pricing tracker