All posts

PAM in the OpenAI Agents SDK, Explained

Embedding a privileged API key directly in an OpenAI agent prompt defeats pam principles, exposing the organization to data‑leak incidents that can cost both reputation and remediation dollars. Teams building with the OpenAI Agents SDK often treat the SDK like a simple library: they paste the OpenAI secret into the code, grant the agent unrestricted access to the model, and forget to log who asked what. The result is a shared credential that lives in source control, a broad standing permission

Free White Paper

Just-in-Time Access + OpenAI API Security: The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

Embedding a privileged API key directly in an OpenAI agent prompt defeats pam principles, exposing the organization to data‑leak incidents that can cost both reputation and remediation dollars.

Teams building with the OpenAI Agents SDK often treat the SDK like a simple library: they paste the OpenAI secret into the code, grant the agent unrestricted access to the model, and forget to log who asked what. The result is a shared credential that lives in source control, a broad standing permission that any compromised process can reuse, and no reliable way to answer the question “who generated this output?”. In practice, the agent talks directly to the OpenAI endpoint, bypasses any review step, and provides no built‑in mechanism for detailed interaction logging.

pam, which stands for privileged access management, asks for three things: a non‑human identity that can be scoped, a gate that enforces least‑privilege at the moment of request, and an audit trail that survives the session. The OpenAI Agents SDK can adopt a non‑human identity via service accounts or OIDC tokens, but the request still travels straight to the OpenAI API. Without an intervening control plane, the request is not inspected, not approved, and not recorded. The gap remains: the agent reaches the model directly, with no inline masking of sensitive response fields, no just‑in‑time approval, and no way to block dangerous prompts.

pam and the OpenAI Agents SDK: why a gateway matters

Enter hoop.dev. It is a Layer 7 gateway that sits between any identity – including service accounts used by the OpenAI Agents SDK – and the target endpoint. The gateway becomes the only place where enforcement can happen. By positioning hoop.dev in the data path, every API call must pass through a policy engine that can apply the three pillars of pam.

Setup – identity and least‑privilege grants

First, the SDK authenticates to hoop.dev using an OIDC token or a SAML assertion. The token represents a service account that has been granted only the scopes required for the specific model or feature set. hoop.dev verifies the token, extracts group membership, and decides whether the request is allowed to proceed. This step decides who is making the call, but it does not enforce the fine‑grained controls that pam demands.

The data path – hoop.dev as the enforcement boundary

Once the identity is confirmed, the request enters the gateway. hoop.dev inspects the HTTP payload, the JSON body that carries the prompt, and applies policy rules before the request reaches OpenAI. Because hoop.dev sits on the wire, it can block disallowed commands, route risky prompts to a human approver, and mask response fields that contain personally identifiable information. The gateway is the only place where these controls can be guaranteed, because the agent never talks directly to the OpenAI service.

Continue reading? Get the full guide.

Just-in-Time Access + OpenAI API Security: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

Enforcement outcomes – audit, masking, just‑in‑time approval

  • hoop.dev records each session, preserving a replayable log that shows the exact prompt, the response, and the identity that issued it.
  • hoop.dev masks sensitive data in real time, ensuring that downstream logs or downstream consumers never see raw PII.
  • hoop.dev can require a just‑in‑time approval workflow for high‑risk prompts, pausing the request until a designated reviewer signs off.
  • hoop.dev blocks commands that match a deny list, preventing the agent from executing dangerous operations such as data exfiltration attempts.

All of these outcomes exist only because hoop.dev occupies the data path. If the gateway were removed, the same identity and token would still be able to call OpenAI, but none of the pam controls would be applied.

Practical steps to adopt pam with the OpenAI Agents SDK

  1. Define a service account in your identity provider that has the minimal scopes needed for the model you intend to use.
  2. Configure the OpenAI Agents SDK to obtain an OIDC token for that service account instead of embedding a static API key.
  3. Deploy hoop.dev using the getting‑started guide. The deployment includes a network‑resident agent that will proxy calls to the OpenAI endpoint.
  4. Create a policy bundle in hoop.dev that specifies which prompts require approval, which response fields must be masked, and which commands are outright denied.
  5. Update your SDK client to point at the hoop.dev endpoint. From the SDK’s perspective this is just another HTTP URL; the gateway handles the rest.

After these steps, every interaction the agent has with OpenAI is subject to pam controls, and hoop.dev provides a tamper‑evident audit trail without requiring changes to your application code.

FAQ

Does hoop.dev replace the OpenAI SDK?

No. hoop.dev is a proxy that the SDK talks to. The SDK continues to format requests and parse responses; hoop.dev only adds enforcement in between.

How are tokens rotated?

The gateway relies on the identity provider’s OIDC flow. When a token expires, the SDK automatically obtains a fresh token, and hoop.dev validates it on each request.

Will the extra hop add noticeable latency?

Because hoop.dev operates at the protocol layer and runs close to the target network, the added round‑trip is typically measured in low‑single‑digit milliseconds, which is negligible for most LLM workloads.

By treating the OpenAI Agents SDK as a privileged client and inserting hoop.dev as the sole enforcement point, organizations can finally apply true pam to LLM interactions – gaining least‑privilege access, real‑time masking, approval workflows, and a complete audit record.

Explore the hoop.dev source code on GitHub to see how the gateway is built and how you can contribute.

Open source

Save the open-source gateway for agent data access

Hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.

Star and save the repo →More posts