Open Internet by MindsNet
openai/openai-python
Repository: openai/openai-python Stars: 30348 Forks: 4674 Primary language: Python Discovery sources: curated Selection score: 77.96 Usefulness score: 8.7 Source confidence score: 2.6 Languages: Python, Shell, Dockerfile, Ruby Topics: openai, python Summary: The official Python library for the OpenAI API README excerpt: # OpenAI Python API library <!-- prettier-ignore --> [)](https://pypi.org/project/openai/) 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](https://github.com/encode/httpx). It is generated from our [OpenAPI specification](https://github.com/openai/openai-openapi) with [Stainless](https://stainlessapi.com/). ## Documentation The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs/api-reference). The full API of this library can be found in [api.md](api.md). ## Installation ```sh # install from PyPI pip install openai ``` ## Usage The full API of this library can be found in [api.md](api.md). The primary API for interacting with OpenAI models is the [Responses API](https://platform.openai.com/docs/api-reference/responses). You can generate text from the model with the code below. ```python import os from openai import OpenAI client = OpenAI( # This is the default and can be omitted api_key=os.environ.get("OPENAI_API_KEY"), ) response = client.responses.create( model="gpt-5.2", instructions="You are a coding assistant that talks like a pirate.", input="How do I check if a Python object is an instance of a class?", ) print(response.output_text) ``` The previous standard (supported indefinitely) for generating text is the [Chat Completions API](http
Computing & Technology, Computer Science, Artificial Intelligence