Skip to main content

MOSS cryptographic signing integration for OpenAI

Project description

moss-openai

MOSS signing integration for OpenAI SDK. Unsigned output is broken output.

PyPI

Installation

pip install moss-openai

Quick Start

Sign tool calls, completions, and messages from OpenAI:

from openai import OpenAI
from moss_openai import sign_tool_call, sign_completion, sign_message

client = OpenAI()

# Get a completion with tool calls
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "What's the weather?"}],
    tools=[{"type": "function", "function": {"name": "get_weather", ...}}]
)

# Sign the completion
result = sign_completion(response, agent_id="weather-bot")
print(f"Signed: {result.signature[:20]}...")

# Sign individual tool calls
for choice in response.choices:
    if choice.message.tool_calls:
        for tool_call in choice.message.tool_calls:
            result = sign_tool_call(tool_call, agent_id="weather-bot")

Enterprise Mode

Set MOSS_API_KEY for automatic policy evaluation:

import os
os.environ["MOSS_API_KEY"] = "your-api-key"

from moss_openai import sign_tool_call, enterprise_enabled

print(f"Enterprise: {enterprise_enabled()}")  # True

result = sign_tool_call(
    tool_call,
    agent_id="finance-bot",
    context={"user_id": "u123"}
)

if result.blocked:
    print(f"Blocked by policy: {result.policy.reason}")

Verification

from moss_openai import verify_envelope

verify_result = verify_envelope(result.envelope)
if verify_result.valid:
    print(f"Signed by: {verify_result.subject}")

All Functions

Function Description
sign_tool_call() Sign a tool call
sign_tool_call_async() Async version
sign_completion() Sign a ChatCompletion
sign_completion_async() Async version
sign_message() Sign a message
sign_message_async() Async version
sign_function_call() Sign legacy function call
sign_function_call_async() Async version
verify_envelope() Verify a signed envelope

Enterprise Features

Feature Free Enterprise
Local signing
Offline verification
Policy evaluation -
Evidence retention -
Audit exports -

Links

License

This package is licensed under the Business Source License 1.1.

  • Free for evaluation, testing, and development
  • Free for non-production use
  • Production use requires a MOSS subscription
  • Converts to Apache 2.0 on January 25, 2030

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moss_openai-1.0.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moss_openai-1.0.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file moss_openai-1.0.0.tar.gz.

File metadata

  • Download URL: moss_openai-1.0.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for moss_openai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 249d40b3f01f0a65aa9058d8c3e9cf15ae36c4cecb863d989527f8016ff307dd
MD5 58468e9aa7991c2b522540d17b576c7f
BLAKE2b-256 0e55fef42d3fa483b79c4be3be278409e0c74a79d79c1831868ef16880025a46

See more details on using hashes here.

Provenance

The following attestation bundles were made for moss_openai-1.0.0.tar.gz:

Publisher: publish.yml on mosscomputing/moss-openai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file moss_openai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: moss_openai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for moss_openai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa8f248cf94a9496e9dd118f3009d8be489a2add52eef3985268a2d938ff90b6
MD5 fc13ee87c67f90c776698e7dcbdb670e
BLAKE2b-256 f549bcc9972dafcc062c7c9e9644cd87b48fde832dfc0ae523434acec05a5b79

See more details on using hashes here.

Provenance

The following attestation bundles were made for moss_openai-1.0.0-py3-none-any.whl:

Publisher: publish.yml on mosscomputing/moss-openai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page