Registry / ai-ml / oci-openai

oci-openai

JSON →
library1.1.0pypypi✓ verified 79d ago

OCI authentication and authorization utilities for the OpenAI Python SDK, enabling secure access to OpenAI models via OCI API keys and signing. Version 1.1.0 released 2024-12, requires Python >=3.9.

pip install oci-openai
INSTALL
IMPORT
SIG · OCI-OPENAI
O
oci-openai
ai-mlpythonv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

OciOpenAI
from oci_openai import OciOpenAI
from oci_openai import OCIAuthMiddleware
AsyncOciOpenAI
from oci_openai import AsyncOciOpenAI
OciUserPrincipalAuth
from oci_openai import OciUserPrincipalAuth

Initialize OpenAI client with OCI authentication middleware.

import os from openai import OpenAI from oci_openai import OCIAuthMiddleware default_compartment = os.environ.get('OCI_COMPARTMENT_ID', '') client = OpenAI( api_key=default_compartment, # Placeholder, OCI signature is used instead default_headers={ "oci-auth-middleware": OCIAuthMiddleware() } ) # Example: client.chat.completions.create(...)
Debug
Known issues
gotchaThe OCI authentication middleware replaces the standard API key; the 'api_key' parameter in OpenAI client is ignored but must be set to a non-empty string (e.g., a placeholder).
fix
Set api_key to any non-empty string, e.g., api_key='placeholder'.
affects: >=1.0.0
breakingVersion 1.0.0 introduced a breaking change: the middleware class was renamed from 'OCIAuth' to 'OCIAuthMiddleware'.
fix
Replace 'from oci_openai import OCIAuth' with 'from oci_openai import OCIAuthMiddleware'.
affects: <1.0.0 to >=1.0.0
gotchaOCI environment variables (OCI_CONFIG_FILE, OCI_CONFIG_PROFILE) must be set correctly; otherwise the middleware silently fails to authenticate.
fix
Verify OCI configuration by running 'oci os ns get' before using the library.
affects: >=1.0.0
deprecatedPython 3.9 is the minimum; support for older Python versions was dropped in earlier releases.
fix
Ensure Python version >= 3.9.
affects: >=1.0.0
Upgrade
Version history
1.1.0latest on PyPI · released Feb 3, 2026
Audit
Dependencies
openairequiredOCI OpenAI works as a request middleware for the OpenAI Python SDK
ocirequiredOCI SDK for authentication and signing
Agent activity
25 hits · last 30 days
node
20
OpenAI (training)
1
Resources
oci-openai — pip install oci-openai · libregistry