oci-openai
OCI authentication and authorization utilities for OpenAI python SDK
What it is and what it does
oci-openai bridges the OpenAI Python SDK with OCI's Generative AI and Data Science Model Deployment services using OCI-native authentication. It wraps httpx and the openai library to inject OCI credentials (session-based, user principal, or resource principal) into requests, allowing you to use familiar OpenAI API patterns (chat.completions.create, async clients) against OCI endpoints instead of OpenAI's.
The package supports both synchronous (OciOpenAI) and asynchronous (AsyncOciOpenAI) clients, and can patch the native openai SDK's http client for use with frameworks like langchain-openai. It targets OpenAI, xAI Grok, and Meta Llama models hosted on OCI, and works with both OCI Generative AI endpoints and custom model deployments via OCI Data Science.
Use it for:
- Migrate existing OpenAI SDK code to OCI Generative AI without rewriting API calls, using OCI IAM for authentication.
- Build LLM applications on OCI with resource-level or workload-level authentication (e.g., OKE pods, compute instances).
- Integrate OCI-hosted models into langchain or other frameworks that accept a custom http_client.
- Deploy inference against custom models in OCI Data Science Model Deployment using OpenAI-compatible chat and completion APIs.
- Avoid managing separate API keys by leveraging OCI principal authentication across your infrastructure.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides OpenAI-compatible Python clients for accessing OCI Generative AI Service and OCI Data Science Model Deployment, with OCI-native authentication and authorization.
Yes, if you are already using OCI infrastructure and need OpenAI-compatible access to OCI Generative AI or Data Science models. The package is actively maintained, has low install friction, and supports current Python versions. Verify that UPL-1.0 licensing is acceptable for your use case, and confirm you have OCI credentials and the correct endpoint URL before installing.
Install
oci-openai on PyPI
pip
pip install oci-openaiuv
uv add oci-openaipoetry
poetry add oci-openaiInstalling oci-openai
Before you install
Low install friction with a pure-Python wheel. Active maintenance with recent commits (last commit 2026-06-30). Supports current Python versions (3.9–3.12).
License in practice
Licensed under UPL-1.0 (Oracle Public License), classified as unclear treatment. Verify compatibility with your project's license policy before use.
Quickstart
pip install oci-openai
from oci_openai import OciOpenAI, OciSessionAuth
client = OciOpenAI(
base_url="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/20231130/actions/v1",
auth=OciSessionAuth(profile_name=""),
compartment_id="",
)
completion = client.chat.completions.create(
model="",
messages=[{"role": "user", "content": "Your prompt here"}],
)
print(completion.model_dump_json())
Requires OCI credentials configured (OCI CLI profile or environment). Requires valid OCI Generative AI or Data Science Model Deployment endpoint URL and compartment ID.
Verify before relying
- Whether UPL-1.0 is compatible with common commercial or copyleft licensing schemes in your organization.
- Whether OCI API key authentication (alternative mentioned in docs) is preferable for your use case versus this package's principal-based auth.
- Performance and rate-limit behavior under production load.
Package facts
| License | UPL-1.0 (unclear) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — httpx, oci, openai, requests |
| Maintenance | actively maintained — 192 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 125,879/month — #11,795 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: oci_openai-1.1.0-py3-none-any.whl
Keywords: AI, Artificial Intelligence, GenAI, Generative AI, OCI, Oracle, Oracle Cloud Infrastructure
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
langchain-ociIntegrates LangChain with Oracle Cloud…
unclear · top 15,000 on PyPI
ociPython SDK for Oracle Cloud Infrastructure that…
permissive · top 5,000 on PyPI
oci-cliCommand-line interface for managing Oracle…
permissive · top 5,000 on PyPI
openaiProvides a Python client library for the OpenAI…
permissive · top 1,000 on PyPI
sap-ai-sdk-genAccess generative AI models from SAP AI Core…
unclear · top 15,000 on PyPI
generative-ai-hub-sdkProvides Python access to generative AI models…
unclear · top 15,000 on PyPI
orasORAS Python is an SDK that lets you push OCI…
permissive · top 5,000 on PyPI
ocifsProvides a fsspec-compatible filesystem…
unclear · top 15,000 on PyPI
agent-framework-openaiProvides OpenAI and Azure OpenAI integration…
permissive · top 5,000 on PyPI
litellmLiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI