openai-python  by openai

Python SDK for the OpenAI API

Created 4 years ago
28,709 stars

Top 1.3% 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

1 day ago

Responsiveness

1 day

Pull Requests (30d)
40
Issues (30d)
33
Star History
385 stars in the last 30 days

Explore Similar Projects

Starred by Patrick von Platen Patrick von Platen(Author of Hugging Face Diffusers; Research Engineer at Mistral) and Jeff Hammerbacher Jeff Hammerbacher(Cofounder of Cloudera).

client-python by mistralai

0.6%
648
Python SDK for Mistral AI platform
Created 1 year ago
Updated 2 weeks ago
Feedback? Help us improve.