openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.22.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

openai/__init__.py

77lines · modecode

1# OpenAI Python bindings.
2#
3# Originally forked from the MIT-licensed Stripe Python bindings.
4
5import os
6from typing import Optional
7
8from openai.api_resources import (
9 Answer,
10 Classification,
11 Completion,
12 Customer,
13 Edit,
14 Deployment,
15 Embedding,
16 Engine,
17 ErrorObject,
18 File,
19 FineTune,
20 Model,
21 Moderation,
22 Search,
23)
24from openai.error import APIError, InvalidRequestError, OpenAIError
25
26api_key = os.environ.get("OPENAI_API_KEY")
27# Path of a file with an API key, whose contents can change. Supercedes
28# `api_key` if set. The main use case is volume-mounted Kubernetes secrets,
29# which are updated automatically.
30api_key_path: Optional[str] = os.environ.get("OPENAI_API_KEY_PATH")
31
32organization = os.environ.get("OPENAI_ORGANIZATION")
33api_base = os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1")
34api_type = os.environ.get("OPENAI_API_TYPE", "open_ai")
35api_version = (
36 "2022-03-01-preview" if api_type in ("azure", "azure_ad", "azuread") else None
37)
38verify_ssl_certs = True # No effect. Certificates are always verified.
39proxy = None
40app_info = None
41enable_telemetry = False # Ignored; the telemetry feature was removed.
42ca_bundle_path = None # No longer used, feature was removed
43debug = False
44log = None # Set to either 'debug' or 'info', controls console logging
45
46__all__ = [
47 "APIError",
48 "Answer",
49 "Classification",
50 "Completion",
51 "Customer",
52 "Edit",
53 "Deployment",
54 "Embedding",
55 "Engine",
56 "ErrorObject",
57 "File",
58 "FineTune",
59 "InvalidRequestError",
60 "Model",
61 "Moderation",
62 "OpenAIError",
63 "Search",
64 "api_base",
65 "api_key",
66 "api_type",
67 "api_key_path",
68 "api_version",
69 "app_info",
70 "ca_bundle_path",
71 "debug",
72 "enable_elemetry",
73 "log",
74 "organization",
75 "proxy",
76 "verify_ssl_certs",
77]
78