openai-python  by openai

Python SDK for the OpenAI API

created 4 years ago
27,549 stars

Top 1.4% on sourcepulse

GitHubView on GitHub
Project Summary

The openai-python library provides a Pythonic interface to the OpenAI REST API, enabling developers to integrate advanced AI models into their applications. It supports both synchronous and asynchronous operations, offers type-hinted requests and responses for improved developer experience, and includes features like streaming, pagination, and robust error handling.

How It Works

This library is generated from OpenAI's OpenAPI specification using Stainless, ensuring type safety and adherence to the API contract. It leverages httpx for efficient HTTP communication, supporting both synchronous and asynchronous clients. The library maps API endpoints to Python methods, providing structured data models (Pydantic) for responses and TypedDicts for request parameters, facilitating autocompletion and early error detection.

Quick Start & Requirements

Highlighted Details

  • Supports text, image, and audio modalities, including a Realtime API beta for low-latency conversational experiences.
  • Automatic pagination for list endpoints and robust error handling with retries and timeouts.
  • Allows customization of the underlying httpx client for proxies, custom transports, and more.
  • Includes specific support for Azure OpenAI via the AzureOpenAI class.

Maintenance & Community

  • Actively maintained by OpenAI.
  • Feedback and contributions are encouraged via GitHub issues.

Licensing & Compatibility

  • MIT License.
  • Compatible with commercial and closed-source applications.

Limitations & Caveats

  • The Realtime API is in beta and may have breaking changes.
  • Azure OpenAI usage may have type mismatches between the library's static types and the actual API response shapes.
Health Check
Last commit

14 hours ago

Responsiveness

1 day

Pull Requests (30d)
34
Issues (30d)
54
Star History
1,164 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.