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.
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 grant token doesn't include the required scope, create_grantex_tool raises a PermissionError immediately — the tool is never created.
API reference
create_grantex_tool()
Creates an OpenAI Agents SDK FunctionTool with offline scope enforcement.
| 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 |
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.1.0openai-agents >= 0.0.3(peer dependency)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grantex_openai_agents-0.1.0.tar.gz.
File metadata
- Download URL: grantex_openai_agents-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9ba81024b472495ba88fe4a57e513f745e6ed80ae0be3f81dcbd2028fbf44d0
|
|
| MD5 |
e08c5a8c4bd5c60b859a7b402c0e0ae7
|
|
| BLAKE2b-256 |
544a7c5938298e7ff8276d225168cae0051d1a15a2b643d4d8be7282c7963cd4
|
File details
Details for the file grantex_openai_agents-0.1.0-py3-none-any.whl.
File metadata
- Download URL: grantex_openai_agents-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fa1b2b9d500c6e1540c8e3a2f4927bbc2c5621838d7a666a6762dbae5752eae
|
|
| MD5 |
17dc0ca55987cf382e1f558d1bc0cd55
|
|
| BLAKE2b-256 |
a6d86287e947689e86162ded7dd317ee9cfecbbbca6d05b401542306d728d6e8
|