Skip to content

streaming example with openai agents sdk#1055

Merged
deathbyknowledge merged 1 commit intomainfrom
streaming-example-openai-sdk
Mar 4, 2026
Merged

streaming example with openai agents sdk#1055
deathbyknowledge merged 1 commit intomainfrom
streaming-example-openai-sdk

Conversation

@deathbyknowledge
Copy link
Member

@deathbyknowledge deathbyknowledge commented Mar 3, 2026

This PR adds a streaming chat example using openai/agents, which closes #481 and #530.

It uses the Agent class and the native @callable({ streaming: true }) decorator without the AI SDK or any other dependency.

The example is fairly straightforward streaming chat with a single getWeather tool.

For reviewers: most files are just boilerplate so you'll want to take a look at:

  • openai-sdk/streaming-chat/src/client.tsx
  • openai-sdk/streaming-chat/src/server.ts

@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: 63dd2d1

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 3, 2026

Open in StackBlitz

npm i https://pkg.pr.new/agents@1055
npm i https://pkg.pr.new/@cloudflare/ai-chat@1055
npm i https://pkg.pr.new/@cloudflare/codemode@1055
npm i https://pkg.pr.new/hono-agents@1055

commit: 64b0ce2

@deathbyknowledge deathbyknowledge force-pushed the streaming-example-openai-sdk branch from bf3041e to 63dd2d1 Compare March 4, 2026 11:22
@deathbyknowledge deathbyknowledge marked this pull request as ready for review March 4, 2026 11:44
Comment on lines +49 to +50
@callable({ streaming: true })
async chat(stream: StreamingResponse, userMessage: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL you can do this so easily.

@deathbyknowledge deathbyknowledge merged commit c8cf671 into main Mar 4, 2026
4 checks passed
@deathbyknowledge deathbyknowledge deleted the streaming-example-openai-sdk branch March 4, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming with OpenAI Agents.

2 participants