Expand description
OpenAI Harmony format parsing for GPT-OSS models.
The Harmony format uses channels to separate different types of content:
analysis: Chain-of-thought reasoning (internal, not for end users)commentary: Tool call preambles and explanationsfinal: User-facing response content
Tool calls in Harmony are indicated by the recipient field being set to:
functions.tool_namefor user-defined toolsbrowser.search,browser.open,browser.findfor browser toolpythonfor python tool
This module provides incremental parsing of Harmony-formatted token streams.
Structs§
- Harmony
Accumulated - Accumulated content for each channel
- Harmony
Context - Context for tracking Harmony parsing state within a sequence.
- Harmony
Delta - Incremental delta from Harmony parsing
- Harmony
Tool Call - A tool call parsed from Harmony format
Enums§
- Harmony
Channel - Channel types in Harmony format
Functions§
- is_
harmony_ encoding_ ready - Check if the Harmony encoding has been initialized.
- is_
harmony_ template - Check if a chat template uses Harmony format by looking for Harmony markers.
- prewarm_
harmony_ encoding - Pre-initialize the Harmony encoding. This MUST be called from a non-async context (e.g., during pipeline loading) before any async code runs. The openai-harmony crate uses reqwest::blocking which creates its own tokio runtime, so it cannot be called from within an existing async context.