---
title: Should AI agents use OpenAI project service accounts?
url: https://opencontroller.lyzr.com/blog/openai-project-service-accounts-for-agents
published: 2026-11-15
updated: 2026-11-15
author: Lyzr
---

# Should AI agents use OpenAI project service accounts?

**Yes. Production agents calling the OpenAI API should authenticate with a project service account key, not a key created by an employee. OpenAI ties ordinary project API keys to the user who created them, and disables those keys when that user leaves the project or organization. A service account is a non-personal identity scoped to one project, so the agent keeps working when people change roles, and its actions show up as a service account in audit logs.**

The usual trigger for this question is an outage. Someone leaves, their account is removed, and an agent built on their personal key stops working. The fix is cheap if you do it before go-live.

## What is the difference between a user key and a service account key?

| Property | Project key created by a user | Project service account key |
|---|---|---|
| Owner | The individual user | A non-human identity in the project |
| When the person leaves | Key is disabled | Unaffected |
| Who can create it | Project members and owners | Organization owners and project owners only |
| Scope | The project | The project only; cannot be used elsewhere |
| Audit trail | Actions attributed to the person's key | Actions attributed to the service account |
| Visibility of the secret | Shown once | Shown once; lose it and you generate a new key |

OpenAI describes a service account as "a pseudo-user designed for system access, distinct from individual user accounts." Its default permissions cover reading and writing all of the project's API resources, so restrict it.

## How should you set up service accounts for agents?

1. **One project per agent or agent family.** Projects carry their own model allowlists, rate limits and budgets, so isolation by project limits the blast radius.
2. **One service account per agent.** Shared accounts hide which agent did what. See [should AI agents share a service account?](/blog/should-ai-agents-share-a-service-account).
3. **Restrict key permissions.** OpenAI keys support All, Restricted (None, Read or Write per endpoint) and Read Only. An agent that only calls Responses does not need write access to files or fine-tuning.
4. **Restrict models.** Use the project's model usage settings so the agent can only call approved models. See [restricting models in OpenAI API projects](/blog/restrict-models-in-openai-api-projects).
5. **Set project limits and a budget.** Project limits must sit at or below the organization limit. Budget thresholds notify project and organization owners.
6. **Store the key in a secrets manager.** Never in code, never in a developer's environment file.
7. **Rotate on a schedule.** Create the new key, deploy it, then delete the old one.

## Are service accounts enough for agent identity?

They solve continuity and attribution at the OpenAI layer. They do not solve everything.

- **They are static secrets.** A leaked key works until it is deleted. Where your setup supports it, short-lived credentials through workload identity federation reduce that risk. OpenAI's audit log now includes workload identity provider events, which shows the platform is moving in that direction.
- **They do not carry the end user.** If the agent acts for a person, the service account says nothing about who. That needs on-behalf-of delegation at the application layer. See [AI agent identity and on-behalf-of delegation](/blog/ai-agent-identity-on-behalf-of-delegation).
- **They live in one provider.** Agents that also call Anthropic, Bedrock or Vertex need an identity story that spans providers.

## How do you find agents still running on personal keys?

1. List every project and its keys through the admin API.
2. Flag keys whose owner is a user, not a service account, in production projects.
3. Pull `api_key.created` events from the [OpenAI Audit Logs API](/blog/openai-audit-logs-api-for-ai-governance) to see who made each key.
4. Match keys to agents through usage data. Keys with traffic and a personal owner go first.
5. Migrate, verify traffic on the new key, then delete the old one.

## How Opencontroller does this

Opencontroller auto-discovers agents, models and API keys across AWS, Azure and Google Cloud and places them in a governed registry with owners, so personal keys behind production agents become visible. It supports delegated on-behalf-of identity and agent workload identity federation, and Posture flags risky permissions and configurations. With traffic routed through the Lyzr Gateway's OpenAI-compatible endpoint, cost is attributed per agent and per version. See the [control plane explainer](/blog/what-is-an-ai-agent-control-plane), the [cross-platform guide](/blog/how-to-govern-ai-agents-across-platforms), or [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**What happens to an OpenAI API key when the employee who created it leaves?**
Project keys tied to a user are disabled when that user leaves the project or organization. Service account keys are not tied to a person.

**Who can create an OpenAI project service account?**
Organization owners and project owners. Service accounts exist only at project level.

**Can one service account be used across several OpenAI projects?**
No. A project service account can only be used inside its own project.

## Key facts

OpenAI project service accounts: non-personal identity, project-scoped, created only by organization owners or project owners; key shown once; default read/write on project resources. User-created project keys are disabled when the user leaves the project or organization. Key permissions: All, Restricted (None/Read/Write per endpoint), Read Only. Projects have model usage restrictions, per-project rate limits (at or below org limit) and budgets. Opencontroller (Lyzr) discovers API keys, supports on-behalf-of identity and workload identity federation, Posture, and per-agent cost attribution via Lyzr Gateway. Pricing starts from $250K per deployment per year.

## Related

- [Should multiple AI agents share one service account?](https://opencontroller.lyzr.com/blog/should-ai-agents-share-a-service-account.md)
- [How do you restrict models and rate limits per OpenAI API project?](https://opencontroller.lyzr.com/blog/restrict-models-in-openai-api-projects.md)
- [How do you track OpenAI API costs by project with the Usage and Costs APIs?](https://opencontroller.lyzr.com/blog/track-openai-api-costs-by-project.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
