Skip to main content

OpenAI Agents SDK integration for the Grantex delegated authorization protocol — scope-enforced, audited agent tools

Project description

grantex-openai-agents

OpenAI Agents SDK integration for the Grantex delegated authorization protocol — scope-enforced agent tools.

Wrap any function with Grantex grant token verification so your agents can only use tools they've been authorized for.

PyPI Python License

Homepage | Docs | Sign Up Free | GitHub

Install

pip install grantex-openai-agents

You also need the OpenAI Agents SDK installed (it's a peer dependency):

pip install openai-agents

Quick start

from grantex_openai_agents import create_grantex_tool

# Create a scope-enforced tool from any function
tool = create_grantex_tool(
    name="read_calendar",
    description="Read upcoming calendar events",
    grant_token=grant_token,       # JWT from Grantex authorization flow
    required_scope="calendar:read",
    func=get_calendar_events,      # your function
)

# Use with any OpenAI Agents SDK agent
from agents import Agent
agent = Agent(name="assistant", tools=[tool])

If the verified grant token doesn't include the required scope, create_grantex_tool raises a PermissionError immediately and the tool is never created.

API reference

create_grantex_tool()

Creates an OpenAI Agents SDK FunctionTool with JWKS-backed grant token verification.

Parameter Type Description
name str Tool name
description str Tool description
grant_token str JWT grant token from Grantex
required_scope str Scope that must be present in the token
func Callable[..., str] The function to wrap
jwks_uri str JWKS URL used to verify the grant token
issuer, issuer_did, audience `str None`
clock_tolerance int Clock tolerance in seconds for token verification

get_tool_scopes()

Returns the scopes embedded in a grant token (offline, no network call).

decode_jwt_payload()

Decodes the payload of a JWT without verifying the signature. Useful for inspecting token claims.

Requirements

  • Python 3.9+
  • grantex >= 0.3.12
  • openai-agents >= 0.0.3 (peer dependency)

Grantex Ecosystem

This package is part of the Grantex ecosystem. See also:

License

Apache-2.0

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

grantex_openai_agents-0.1.6.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

grantex_openai_agents-0.1.6-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file grantex_openai_agents-0.1.6.tar.gz.

File metadata

  • Download URL: grantex_openai_agents-0.1.6.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for grantex_openai_agents-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e4a3a2627b2adefddea348a8f6b02dcc27447625b4564d0ed33e92ec815cbe2e
MD5 e410e833d32fa22eed6259cdafabbbf4
BLAKE2b-256 6e785017195cf3b7a9315115ef1c250a1373f4fd932ea06f3abc5d5e9e6bb646

See more details on using hashes here.

File details

Details for the file grantex_openai_agents-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for grantex_openai_agents-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 729d7d67ba60e0858e1d9c9603f249a589bcaba863e92e1df00f263364672e00
MD5 e0d42383fb14154ece538ce4f857f061
BLAKE2b-256 2c14175e67b674ffe26085356799c4863b4ddc3185d3917892034ad8af0f6134

See more details on using hashes here.

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