Implementation:Openai Openai python Resources Package Exports
| Knowledge Sources | |
|---|---|
| Domains | SDK_Infrastructure |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for resource class re-exports provided by the openai-python SDK.
Description
The resources/__init__.py module serves as the centralized re-export hub for all API resource classes in the SDK. It imports and exposes 18 resource families, each consisting of a sync class, async class, and their raw-response and streaming-response variants (6 exports per family). The resource families are: Beta, Chat, Audio, Evals, Files, Images, Models, Skills, Videos, Batches, Uploads, Containers, Embeddings, Completions, FineTuning, Moderations, VectorStores. The __all__ list contains 108 symbols covering all variants. This file is auto-generated from the OpenAPI spec by Stainless and provides a single, flat import namespace for all resource classes.
Usage
Use this module to import any resource class or its response wrapper variants from a single location, e.g., from openai.resources import Chat, AsyncChat.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/resources/__init__.py
- Lines: 1-243
Signature
# Each resource family exports 6 symbols:
# {Name}, Async{Name}, {Name}WithRawResponse, Async{Name}WithRawResponse,
# {Name}WithStreamingResponse, Async{Name}WithStreamingResponse
# Example for Chat:
from .chat import (
Chat,
AsyncChat,
ChatWithRawResponse,
AsyncChatWithRawResponse,
ChatWithStreamingResponse,
AsyncChatWithStreamingResponse,
)
# 18 resource families, 108 total exports in __all__
Import
from openai.resources import (
Chat, AsyncChat,
Files, AsyncFiles,
Models, AsyncModels,
Moderations, AsyncModerations,
Embeddings, AsyncEmbeddings,
# ... and all other resource families
)
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| N/A | N/A | N/A | This is a re-export module with no runtime inputs |
Outputs
| Name | Type | Description |
|---|---|---|
| Resource classes | type | 108 resource class symbols organized by API domain |
Usage Examples
Basic Usage
from openai.resources import Chat, Moderations, Files
# These are the same classes used internally by the client:
from openai import OpenAI
client = OpenAI()
assert type(client.chat).__name__ == "Chat"
assert type(client.moderations).__name__ == "Moderations"