Skip to main content

Harmony

Response format library for the gpt-oss open-weight model series (fork of openai-harmony)


The [gpt-oss models][gpt-oss] were trained on the [harmony response format][harmony-format] for defining conversation structures, generating reasoning output and structuring function calls. If you are not using gpt-oss directly but through an API or a provider like HuggingFace, Ollama, or vLLM, you will not have to be concerned about this as your inference solution will handle the formatting. If you are building your own inference solution, this guide will walk you through the prompt format. The format is designed to mimic the OpenAI Responses API, so if you have used that API before, this format should hopefully feel familiar to you. gpt-oss should not be used without using the harmony format as it will not work correctly.

The format enables the model to output to multiple different channels for chain of thought, and tool calling preambles along with regular responses. It also enables specifying various tool namespaces, and structured outputs along with a clear instruction hierarchy. [Check out the guide][harmony-format] to learn more about the format itself.

<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.
Knowledge cutoff: 2024-06
Current date: 2025-06-28

Reasoning: high

# Valid channels: analysis, commentary, final. Channel must be included for every message.
Calls to these tools must go to the commentary channel: 'functions'.<|end|>

<|start|>developer<|message|># Instructions

Always respond in riddles

# Tools

## functions

namespace functions {

// Gets the location of the user.
type get_location = () => any;

// Gets the current weather in the provided location.
type get_current_weather = (_: {
// The city and state, e.g. San Francisco, CA
location: string,
format?: "celsius" | "fahrenheit", // default: celsius
}) => any;

} // namespace functions<|end|><|start|>user<|message|>What is the weather like in SF?<|end|><|start|>assistant

We recommend using this library when working with models that use the [harmony response format][harmony-format]

  • Consistent formatting – shared implementation for rendering and parsing keeps token-sequences loss-free.
  • Blazing fast – heavy lifting happens in Rust.
  • First-class Python support – install with pip, typed stubs included, 100 % test parity with the Rust suite.

Using Harmony

Python

Check out the full documentation

Installation

Install the package from PyPI by running

pip install oss-harmony
# or if you are using uv
uv pip install oss-harmony

Example

from openai_harmony import (
    load_harmony_encoding,
    HarmonyEncodingName,
    Role,
    Message,
    Conversation,
    DeveloperContent,
    SystemContent,
)
enc = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
convo = Conversation.from_messages([
    Message.from_role_and_content(
        Role.SYSTEM,
        SystemContent.new(),
    ),
    Message.from_role_and_content(
        Role.DEVELOPER,
        DeveloperContent.new().with_instructions("Talk like a pirate!")
    ),
    Message.from_role_and_content(Role.USER, "Arrr, how be you?"),
])
tokens = enc.render_conversation_for_completion(convo, Role.ASSISTANT)
print(tokens)
# Later, after the model responded …
parsed = enc.parse_messages_from_completion_tokens(tokens, role=Role.ASSISTANT)
print(parsed)

Rust

Check out the full documentation

Installation

Add the dependency to your Cargo.toml

[dependencies]
oss-harmony = { git = "https://github.com/oss-harmony/harmony" }

Example

use openai_harmony::chat::{Message, Role, Conversation};
use openai_harmony::{HarmonyEncodingName, load_harmony_encoding};

fn main() -> anyhow::Result<()> {
    let enc = load_harmony_encoding(HarmonyEncodingName::HarmonyGptOss)?;
    let convo =
        Conversation::from_messages([Message::from_role_and_content(Role::User, "Hello there!")]);
    let tokens = enc.render_conversation_for_completion(&convo, Role::Assistant, None)?;
    println!("{:?}", tokens);
    Ok(())
}

Contributing

See CONTRIBUTING.md

Metadata

Release files for oss-harmony 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oss-harmony 0.0.11
File Size Uploaded Provenance
oss_harmony-0.0.11.tar.gz 2.2 MB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for oss-harmony 0.0.11
File
oss_harmony-0.0.11-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
oss_harmony-0.0.11-cp38-abi3-win32.whl CPython 3.8 abi3 Windows x86-32 Details
oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_x86_64.whl CPython 3.8 abi3 Linux musl 1.2+ x86-64 Details
oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_i686.whl CPython 3.8 abi3 Linux musl 1.2+ x86-32 Details
oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_armv7l.whl CPython 3.8 abi3 Linux musl 1.2+ ARMv7l Details
oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_aarch64.whl CPython 3.8 abi3 Linux musl 1.2+ ARM64 Details
oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl CPython 3.8 abi3 Linux glibc 2.17+ PowerPC 64-le Details
oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.8 abi3 Linux glibc 2.17+ ARMv7l Details
oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
oss_harmony-0.0.11-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl CPython 3.8 abi3 Linux glibc 2.5+ x86-32 Details
oss_harmony-0.0.11-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details

Total release size: 44.8 MB

Release files / oss_harmony-0.0.11.tar.gz

Download URL oss_harmony-0.0.11.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
ccad467b71d61490df1f2204b7a064990833338615ac135536c5b3a8e2d03a15
BLAKE2b-256 checksum
How to use checksums
4388ca56e5b17df4763bbb552c7be3abe432b51db3c51f6327a3848b88ad7c08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-win_amd64.whl

Download URL oss_harmony-0.0.11-cp38-abi3-win_amd64.whl
Size 3.3 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
4db175b6f6264cd60ceb692c0e686937e072ca6ea1239d0d4cace2cfb50f4974
BLAKE2b-256 checksum
How to use checksums
c8c9eedd8d02be8bbaa586f8a323de2fc976e6053582411020b7be1f7c7e1734
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-win32.whl

Download URL oss_harmony-0.0.11-cp38-abi3-win32.whl
Size 3.1 MB
Tags CPython 3.8 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
fd91609eef825f342ae7ac990651cfebcf28aac6b6ad1186bf37c5b593cdf950
BLAKE2b-256 checksum
How to use checksums
03332917125287b46255cfc6d7e0bc4bc5e5c90f7ad4e02d3922c2f0f95b696b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_x86_64.whl

Download URL oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_x86_64.whl
Size 3.8 MB
Tags CPython 3.8 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
0d1545203973abb3002dcc6c5cffd14ca4a376b655c14ce190c78eb6aaf5f6fd
BLAKE2b-256 checksum
How to use checksums
489aad24d20ea1e8b3167744f5d357d48a116086258ca58540986a0896781864
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_i686.whl

Download URL oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_i686.whl
Size 3.8 MB
Tags CPython 3.8 Linux musl 1.2+ x86-32 abi3
SHA-256 checksum
How to use checksums
5c7b0cea27e1e4e9fc485bf8039a119d6732718cce6b067d1f7de9e637572348
BLAKE2b-256 checksum
How to use checksums
0d7dd71b3ee5abfbf9130eea646b9589e8f00a039514cdca2ab6dbffa22f8351
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_armv7l.whl

Download URL oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_armv7l.whl
Size 3.7 MB
Tags CPython 3.8 Linux musl 1.2+ ARMv7l abi3
SHA-256 checksum
How to use checksums
952218411c219dc7ca8ee56eb86271d015d0c347896b2009906096422d7a94cf
BLAKE2b-256 checksum
How to use checksums
94a8fb8cad33079ee848514ea70688005ef7b6c32ccee788cc18fcb04e24fa74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_aarch64.whl

Download URL oss_harmony-0.0.11-cp38-abi3-musllinux_1_2_aarch64.whl
Size 3.7 MB
Tags CPython 3.8 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
036505bfb39c6b50edcf717349518d269bb375207f7f8e95f517e938b8f2e0c8
BLAKE2b-256 checksum
How to use checksums
4bc9720aed1527d87f82e07a7f35c3c81c6d9198a8d1223bdbd298b3c66a72db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.6 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d877c6b526cdbdf55068bae8f05c60398e929c9e296c7f69a1d533339708be80
BLAKE2b-256 checksum
How to use checksums
8968001d7429a692b2db0c03bd49b756f834716b64afc0bbbece96824e8f0af8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 3.7 MB
Tags CPython 3.8 Linux glibc 2.17+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
f215934b05f3a7658e0cf30cf92bc25f4aed125a693529c53dd97325ecfbf7ef
BLAKE2b-256 checksum
How to use checksums
8bf7f802d7aba027cd4e1c0ff5509c645de8d70fa674b31d80cdf8fec63ac844
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 3.4 MB
Tags CPython 3.8 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
2221f2790411cfd5d0e517769dc2662b15b2711e44728291961506a367ffc3d1
BLAKE2b-256 checksum
How to use checksums
dec3502b7ba6f36645117b58859b250355cba34d7107ec104ea40087b752977b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL oss_harmony-0.0.11-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.5 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
f1f74ef7f8be32fa1dcfe1644839af5f0873acce78b5668c2aa39f26d83218ff
BLAKE2b-256 checksum
How to use checksums
fde90b33d4c592e1422c9faeaf1cfe10731328ecf3504e900dc7921109affd55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl

Download URL oss_harmony-0.0.11-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Size 3.6 MB
Tags CPython 3.8 Linux glibc 2.5+ x86-32 abi3
SHA-256 checksum
How to use checksums
e451e5dc28b0d883f33aa17a77c923afcab5d26ef3b95d7593b68a07e399706e
BLAKE2b-256 checksum
How to use checksums
3b5dedf954b0aace872ec137a9ef7b92c29120bd16a4277fd11c5b83e7d1ed16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Release files / oss_harmony-0.0.11-cp38-abi3-macosx_11_0_arm64.whl

Download URL oss_harmony-0.0.11-cp38-abi3-macosx_11_0_arm64.whl
Size 3.3 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
83ca71b85be6e2f8e93527673cd2eff4da9180608ee5d4197bd4f01afc4fa6be
BLAKE2b-256 checksum
How to use checksums
8b4c400a7e375943ff06447c8cd3920819d2e37c808d0cfea3296b159e961610
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.13.3

Security for oss-harmony 0.0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page