OpenAI Enterprise admin controls
Quick answer
OpenAI Enterprise admin controls allow centralized management of user roles, API keys, and security policies via the OpenAI Enterprise dashboard and API. Admins can assign roles, monitor usage, and enforce organization-wide settings securely.
PREREQUISITES
Python 3.8+OpenAI Enterprise account with admin privilegesAPI key with admin scopepip install openai>=1.0
Setup
To start managing OpenAI Enterprise admin controls, ensure you have an Enterprise account with admin privileges. Install the official openai Python package to interact with the API for administrative tasks.
Set your environment variable for the API key securely:
export OPENAI_API_KEY='your_enterprise_admin_api_key'(Linux/macOS)setx OPENAI_API_KEY "your_enterprise_admin_api_key"(Windows)
Install the OpenAI Python SDK:
pip install openai>=1.0 output
Collecting openai Downloading openai-1.x.x-py3-none-any.whl Installing collected packages: openai Successfully installed openai-1.x.x
Step by step
Use the OpenAI Enterprise admin API to list users, assign roles, and manage API keys. Below is a Python example to fetch organization users and update a user's role.
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
# List all users in the organization
users_response = client.organization_users.list()
print("Organization users:")
for user in users_response.data:
print(f"- {user.email} (Role: {user.role})")
# Update a user's role (example user_id and role)
user_id = users_response.data[0].id # Replace with target user ID
new_role = "admin" # Roles: admin, developer, billing, etc.
update_response = client.organization_users.update(
user_id=user_id,
role=new_role
)
print(f"Updated user {user_id} to role {new_role}") output
Organization users: - alice@example.com (Role: developer) - bob@example.com (Role: admin) Updated user usr_1234567890abcdef to role admin
Common variations
You can also manage API keys programmatically, revoke keys, and audit usage logs. For asynchronous workflows, use asyncio with the OpenAI SDK's async methods. Admin controls extend to setting organization-wide policies via the dashboard or API.
import asyncio
from openai import OpenAI
async def list_api_keys():
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
keys = await client.api_keys.list()
for key in keys.data:
print(f"Key ID: {key.id}, Status: {key.status}")
asyncio.run(list_api_keys()) output
Key ID: key_abcdef123456, Status: active Key ID: key_123456abcdef, Status: revoked
Troubleshooting
- If you receive
403 Forbidden, verify your API key has admin scope and your account is Enterprise. - For
401 Unauthorized, check yourOPENAI_API_KEYenvironment variable is set correctly. - Use the Enterprise dashboard to audit logs if API calls fail unexpectedly.
Key Takeaways
- Use the OpenAI Enterprise dashboard and API for centralized admin control over users and keys.
- Manage user roles and API keys programmatically with the official OpenAI Python SDK.
- Ensure your API key has admin privileges to access Enterprise admin endpoints.
- Use async SDK methods for scalable admin automation workflows.
- Troubleshoot permission errors by verifying API key scope and environment variables.