Learn how to accurately calculate costs when using streaming features.
To accurately calculate costs when using streaming features, you can either include a include_usage key in the body of your request or use the Helicone header.
client.chat.completions.create( model="gpt-4o", max_tokens=100, messages=[ {"role": "system", "content": "You are a great storyteller."}, {"role": "user", "content": "Once upon a time in a galaxy far, far away..."} ], stream=True, stream_options={ "include_usage": True # set to true })
openai.chat.completions.create({ messages: [ { role: "user", content: "Generate an abstract for a course on space.", }, ], model: "gpt-4", stream = true, stream_options: { include_usage: true, // set to true },});