include_usage key in the body of your request or use the Helicone header.
Method 1: Request Body
Method 2: Helicone Header
You can also enable stream usage by adding thehelicone-stream-usage header to your request:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Learn how to accurately calculate costs when using streaming features.
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
},
});
helicone-stream-usage header to your request:
client = OpenAI(
# ...
headers={
"helicone-stream-usage": "true"
}
)
client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}],
stream=True
)
const openai = new OpenAI({
// ...
headers: {
"helicone-stream-usage": "true",
},
});
openai.chat.completions.create({
messages: [{ role: "user", content: "Hello!" }],
model: "gpt-4",
stream: true,
});
Was this page helpful?