Skip to content

Install

Info

The pages in this Get started section are adapted from the sections in the README.md in the upstream repository.

The OpenAI Python library provides access to the OpenAI REST API in Python applications. It includes type definitions for all request params and response fields and has clients for both synchronous and asynchronous operations powered by httpx.

The OpenAI Python library is generated from OpenAI's OpenAPI specification with Stainless.

Prerequisites

Install the package

You can the openai package from PyPi with pip:

# install from PyPI
pip install openai

Migrate from earlier versions

Released on November 6th 2023, the OpenAI Python library was rewritten for version 1.0.0.

If your project used a pre-v1 version of the library, see the v1 migration guide for information and scripts that can help you update your code.