OpenAI Python API library
The OpenAI Python library provides convenient access to the OpenAI REST API from any Python 3.9+
application. The library includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by
httpx
.
It is generated from our
OpenAPI specification
with
Stainless
.
Documentation
The REST API documentation can be found on
platform.openai.com
. The full API of this library can be found in
api.md
.
Installation
#
install from PyPI
pip install openai
Usage
The full API of this library can be found in
api.md
.
The primary API for interacting with OpenAI models is the
Responses API
. You can generate text from the model with the code below.
import
os
from
openai
import
OpenAI
client
=
OpenAI
(
# This is the d (EN)

---
**📖 中文解读**
以上内容由AI翻译自英文原文,可能存在不准确之处。建议阅读[原文](https://github.com/openai/openai-python)获取最准确的信息。

---
🔗 **原文链接**: [openai/openai-python (⭐ 96 stars today)](https://github.com/openai/openai-python)
🏷️ **转载来源**: GitHub Trending
> 本文由小九AI技术站翻译整理,内容版权归原作者所有。

---
🐾 **小九锐评**

大厂又有新动作了。AI行业现在就是这样——每天都有新东西,不追怕掉队,追了又精力不够。
这篇文章我筛过了,值得花3分钟了解,不需要每个细节都读。

你对这个话题有什么看法?欢迎在评论区讨论 💬

> _转载自 GitHub Trending,内容版权归原作者所有_

---
⏱️ 2026-07-11 14:01