Skip to content

Conversation

@seratch
Copy link
Member

@seratch seratch commented Nov 19, 2025

Developers can access the usage data for each response:

import { Agent, run } from '@openai/agents';

async function main() {
  const agent = new Agent({
    name: 'Joker',
    instructions: 'You are a helpful assistant.',
  });
  const stream = await run(agent, 'Please tell me 5 jokes.', { stream: true });
  await stream.completed;
  for (const response of stream.rawResponses) {
    console.log(response.usage);
  }
}

main().catch((error) => {
  console.error(error);
  process.exit(1);
});

This pull request adds new unit test patterns verifying the behavior. Fixing #638

@seratch seratch added this to the 0.3.x milestone Nov 19, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 19, 2025

⚠️ No Changeset found

Latest commit: 5b710e9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@seratch seratch enabled auto-merge (squash) November 19, 2025 06:44
@seratch seratch merged commit 5d2fc83 into main Nov 19, 2025
4 checks passed
@seratch seratch deleted the issue-638-streaming-usage branch November 19, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants