Prompt Buddy logoPrompt Buddy

openai · OpenAI Platform Docs

Streaming API responses | OpenAI API

Explains how to implement real-time token streaming from the OpenAI API to improve perceived latency in user interfaces.

Import to Prompt Buddy

Derived skill

Files assembled from official documentation

Viewing SKILL.md

Streaming API responses | OpenAI API

Explains how to implement real-time token streaming from the OpenAI API to improve perceived latency in user interfaces.

When To Use

Use when you need to implement real-time text updates in a UI to reduce perceived latency during long model generations.

Reference Files

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/streaming-api-responses-openai-workflow-guide.mdA guide explaining how to enable and read streaming responses for chat completions using the OpenAI API.Questions about a guide explaining how to enable and read streaming responses for chat completions using the OpenAI API.
examples/streaming-api-responses-openai-openai-api-nodejs-streaming-response.textA Node.js code example demonstrating how to use the OpenAI client to create and iterate over a streaming API response.Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI client to create and iterate over a streaming API response.
examples/streaming-api-responses-openai-openai-python-streaming-api-response.textA Python code example demonstrating how to use the OpenAI client to create and iterate over a streaming API response.Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI client to create and iterate over a streaming API response.
examples/streaming-api-responses-openai-openai-streaming-api-csharp.textA C# code example demonstrating how to implement asynchronous streaming responses using the OpenAI API.Exact payloads, commands, or snippets shown in A C# code example demonstrating how to implement asynchronous streaming responses using the OpenAI API.
examples/streaming-api-responses-openai-openai-streaming-event-typescript-types.textA TypeScript definition of the various event types used in OpenAI streaming API responses.Exact payloads, commands, or snippets shown in A TypeScript definition of the various event types used in OpenAI streaming API responses.
examples/streaming-api-responses-openai-openai-chat-completions-nodejs-streaming.textA Node.js code example demonstrating how to iterate over a stream of chat completion chunks using the OpenAI SDK.Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to iterate over a stream of chat completion chunks using the OpenAI SDK.
examples/streaming-api-responses-openai-openai-chat-completions-python-streaming.textA Python script demonstrating how to iterate through a stream of chat completion chunks using the OpenAI client.Exact payloads, commands, or snippets shown in A Python script demonstrating how to iterate through a stream of chat completion chunks using the OpenAI client.
examples/streaming-api-responses-openai-openai-streaming-api-response-event-struc.textA text representation of the specific fields and event objects returned during an OpenAI streaming API response.Exact payloads, commands, or snippets shown in A text representation of the specific fields and event objects returned during an OpenAI streaming API response.
examples/streaming-api-responses-openai-openai-streaming-api-response-chunks.textA text representation of sequential content chunks received during an OpenAI API streaming response.Exact payloads, commands, or snippets shown in A text representation of sequential content chunks received during an OpenAI API streaming response.
examples/streaming-api-responses-openai-openai-chat-completions-streaming-nodejs.textA Node.js code example demonstrating how to use the OpenAI client to stream chat completion responses using an async iterator.Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI client to stream chat completion responses using an async...
examples/streaming-api-responses-openai-openai-chat-completions-python-streaming-2.textA Python script demonstrating how to iterate through a stream of chat completion chunks using the OpenAI client.Exact payloads, commands, or snippets shown in A Python script demonstrating how to iterate through a stream of chat completion chunks using the OpenAI client.

What This Skill Covers

  • By default, when you make a request to the OpenAI API, we generate the model’s entire output before sending it back in a single HTTP response. When generatin...
  • Main sections: Enable streaming, Stream a chat completion, Read the responses, Advanced use cases, Moderation risk.

Workflow

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. Do not add behavior or configuration that is not present in the attached source files.

Canonical source: https://developers.openai.com/api/docs/guides/streaming-responses