Skip to content

[ResponsesAPI] Implement streaming mode #1582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 2, 2025

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jul 1, 2025

Built on top of #1576.

This PR adds support for streaming mode to the Responses API.

Tested it using the openai-responses-starter-app:

Screencast.from.02-07-2025.07.43.52.webm
pnpm run example streaming
{
  type: 'response.created',
  response: {
    object: 'response',
    id: 'resp_861131785bfb75f24f944aa7cbc4767b194a2ea320cff258',
    status: 'in_progress',
    error: null,
    instructions: null,
    model: 'Qwen/Qwen2.5-VL-7B-Instruct',
    temperature: 1,
    top_p: 1,
    created_at: 1751383702199,
    output: []
  },
  sequence_number: 0
}
{
  type: 'response.in_progress',
  response: {
    object: 'response',
    id: 'resp_861131785bfb75f24f944aa7cbc4767b194a2ea320cff258',
    status: 'in_progress',
    error: null,
    instructions: null,
    model: 'Qwen/Qwen2.5-VL-7B-Instruct',
    temperature: 1,
    top_p: 1,
    created_at: 1751383702199,
    output: []
  },
  sequence_number: 1
}
{
  type: 'response.output_item.added',
  output_index: 0,
  item: {
    id: 'msg_def4b731a2654f7eab4fb2efdff217079da37154709c0f0b',
    type: 'message',
    role: 'assistant',
    status: 'in_progress',
    content: []
  },
  sequence_number: 2
}
{
  type: 'response.content_part.added',
  item_id: 'msg_def4b731a2654f7eab4fb2efdff217079da37154709c0f0b',
  output_index: 0,
  content_index: 0,
  part: { type: 'output_text', text: '', annotations: [] },
  sequence_number: 3
}
{
  type: 'response.output_text.delta',
  item_id: 'msg_def4b731a2654f7eab4fb2efdff217079da37154709c0f0b',
  output_index: 0,
  content_index: 0,
  delta: 'Double',
  sequence_number: 4
}
{
  type: 'response.output_text.delta',
  item_id: 'msg_def4b731a2654f7eab4fb2efdff217079da37154709c0f0b',
  output_index: 0,
  content_index: 0,
  delta: ' bubble',
  sequence_number: 5
}

...

{
  type: 'response.output_text.delta',
  item_id: 'msg_def4b731a2654f7eab4fb2efdff217079da37154709c0f0b',
  output_index: 0,
  content_index: 0,
  delta: '!',
  sequence_number: 43
}
{
  type: 'response.output_text.done',
  item_id: 'msg_def4b731a2654f7eab4fb2efdff217079da37154709c0f0b',
  output_index: 0,
  content_index: 0,
  text: 'Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath!',
  sequence_number: 44
}
{
  type: 'response.content_part.done',
  item_id: 'msg_def4b731a2654f7eab4fb2efdff217079da37154709c0f0b',
  output_index: 0,
  content_index: 0,
  part: {
    type: 'output_text',
    text: 'Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath! Double bubble bath!',
    annotations: []
  },
  sequence_number: 45
}
{
  type: 'response.output_item.done',
  output_index: 0,
  item: {
    id: 'msg_def4b731a2654f7eab4fb2efdff217079da37154709c0f0b',
    type: 'message',
    role: 'assistant',
    status: 'completed',
    content: [ [Object] ]
  },
  sequence_number: 46
}
{
  type: 'response.completed',
  response: {
    object: 'response',
    id: 'resp_861131785bfb75f24f944aa7cbc4767b194a2ea320cff258',
    status: 'completed',
    error: null,
    instructions: null,
    model: 'Qwen/Qwen2.5-VL-7B-Instruct',
    temperature: 1,
    top_p: 1,
    created_at: 1751383702199,
    output: [ [Object] ]
  },
  sequence_number: 47
}

@Wauplin
Copy link
Contributor Author

Wauplin commented Jul 2, 2025

(merging so that I can continue working on new features)

@Wauplin Wauplin merged commit e47b3f9 into responses-server Jul 2, 2025
5 checks passed
@Wauplin Wauplin deleted the implement-streaming-mode branch July 2, 2025 08:09
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.

1 participant