openai-python (openai/openai-python)

Searching Database…

What is this?This is the official Python library for the OpenAI API, giving convenient programmatic access to OpenAI models like GPT for text, vision, audio and more.
Is this a framework or just an API client library?It is a lightweight SDK/client library, not a framework: it is generated from OpenAI's OpenAPI specification and gives you typed request/response objects to call the API.
How do I add this to my project?Install it with pip (the package is 'openai'), then create an OpenAI client and call its methods like responses.create() or chat.completions.create().
Do I need an OpenAI API key to use it?Yes, you need an API key from OpenAI; the recommended practice is storing it in a .env file rather than passing it directly in code.
What Python version do I need?Python 3.10 or newer is required to use this library.
Does it support both sync and async usage?Yes, it ships both a synchronous OpenAI client and an asynchronous AsyncOpenAI client with identical functionality, both powered by HTTPX2 by default.
Does it support cloud workload identity instead of long-lived API keys?Yes, for secure automated environments it supports workload identity authentication using short-lived tokens from Kubernetes, Azure, or Google Cloud Platform instead of a static API key.
Does it support streaming responses?Yes, it supports streaming via Server Side Events (SSE) for both sync and async clients, so you can process model output as it is generated.
Can I use it for real-time voice conversations?Yes, the Realtime API lets you build low-latency, multi-modal conversations with text and audio input/output and function calling over a WebSocket connection.
How are errors handled?Connection failures raise APIConnectionError, non-2xx responses raise typed subclasses of APIStatusError (like RateLimitError or AuthenticationError), and certain errors like timeouts and 429s are automatically retried twice by default.
Can I verify incoming webhook signatures?Yes, client.webhooks.unwrap() parses and verifies a webhook payload in one step, or client.webhooks.verifysignature() can verify the signature separately before you parse the body yourself.
Creator
openai
Size
29.7 MB
Stars
32.3K
Age
6y
Commits · 90 Days