openai/openai-python
Publicmirrored fromhttps://github.com/openai/openai-pythonAvailable
api.md
310lines · modecode
| 1 | # Completions |
| 2 | |
| 3 | Types: |
| 4 | |
| 5 | ```python |
| 6 | from openai.types import Completion, CompletionChoice, CompletionUsage |
| 7 | ``` |
| 8 | |
| 9 | Methods: |
| 10 | |
| 11 | - <code title="post /completions">client.completions.<a href="./src/openai/resources/completions.py">create</a>(\*\*<a href="src/openai/types/completion_create_params.py">params</a>) -> <a href="./src/openai/types/completion.py">Completion</a></code> |
| 12 | |
| 13 | # Chat |
| 14 | |
| 15 | ## Completions |
| 16 | |
| 17 | Types: |
| 18 | |
| 19 | ```python |
| 20 | from openai.types.chat import ( |
| 21 | ChatCompletion, |
| 22 | ChatCompletionAssistantMessageParam, |
| 23 | ChatCompletionChunk, |
| 24 | ChatCompletionContentPart, |
| 25 | ChatCompletionContentPartImage, |
| 26 | ChatCompletionContentPartText, |
| 27 | ChatCompletionFunctionCallOption, |
| 28 | ChatCompletionFunctionMessageParam, |
| 29 | ChatCompletionMessage, |
| 30 | ChatCompletionMessageParam, |
| 31 | ChatCompletionMessageToolCall, |
| 32 | ChatCompletionNamedToolChoice, |
| 33 | ChatCompletionRole, |
| 34 | ChatCompletionSystemMessageParam, |
| 35 | ChatCompletionTool, |
| 36 | ChatCompletionToolChoiceOption, |
| 37 | ChatCompletionToolMessageParam, |
| 38 | ChatCompletionUserMessageParam, |
| 39 | ) |
| 40 | ``` |
| 41 | |
| 42 | Methods: |
| 43 | |
| 44 | - <code title="post /chat/completions">client.chat.completions.<a href="./src/openai/resources/chat/completions.py">create</a>(\*\*<a href="src/openai/types/chat/completion_create_params.py">params</a>) -> <a href="./src/openai/types/chat/chat_completion.py">ChatCompletion</a></code> |
| 45 | |
| 46 | # Edits |
| 47 | |
| 48 | Types: |
| 49 | |
| 50 | ```python |
| 51 | from openai.types import Edit |
| 52 | ``` |
| 53 | |
| 54 | Methods: |
| 55 | |
| 56 | - <code title="post /edits">client.edits.<a href="./src/openai/resources/edits.py">create</a>(\*\*<a href="src/openai/types/edit_create_params.py">params</a>) -> <a href="./src/openai/types/edit.py">Edit</a></code> |
| 57 | |
| 58 | # Embeddings |
| 59 | |
| 60 | Types: |
| 61 | |
| 62 | ```python |
| 63 | from openai.types import CreateEmbeddingResponse, Embedding |
| 64 | ``` |
| 65 | |
| 66 | Methods: |
| 67 | |
| 68 | - <code title="post /embeddings">client.embeddings.<a href="./src/openai/resources/embeddings.py">create</a>(\*\*<a href="src/openai/types/embedding_create_params.py">params</a>) -> <a href="./src/openai/types/create_embedding_response.py">CreateEmbeddingResponse</a></code> |
| 69 | |
| 70 | # Files |
| 71 | |
| 72 | Types: |
| 73 | |
| 74 | ```python |
| 75 | from openai.types import FileContent, FileDeleted, FileObject |
| 76 | ``` |
| 77 | |
| 78 | Methods: |
| 79 | |
| 80 | - <code title="post /files">client.files.<a href="./src/openai/resources/files.py">create</a>(\*\*<a href="src/openai/types/file_create_params.py">params</a>) -> <a href="./src/openai/types/file_object.py">FileObject</a></code> |
| 81 | - <code title="get /files/{file_id}">client.files.<a href="./src/openai/resources/files.py">retrieve</a>(file_id) -> <a href="./src/openai/types/file_object.py">FileObject</a></code> |
| 82 | - <code title="get /files">client.files.<a href="./src/openai/resources/files.py">list</a>(\*\*<a href="src/openai/types/file_list_params.py">params</a>) -> <a href="./src/openai/types/file_object.py">SyncPage[FileObject]</a></code> |
| 83 | - <code title="delete /files/{file_id}">client.files.<a href="./src/openai/resources/files.py">delete</a>(file_id) -> <a href="./src/openai/types/file_deleted.py">FileDeleted</a></code> |
| 84 | - <code title="get /files/{file_id}/content">client.files.<a href="./src/openai/resources/files.py">retrieve_content</a>(file_id) -> str</code> |
| 85 | - <code>client.files.<a href="./src/openai/resources/files.py">wait_for_processing</a>(\*args) -> FileObject</code> |
| 86 | |
| 87 | # Images |
| 88 | |
| 89 | Types: |
| 90 | |
| 91 | ```python |
| 92 | from openai.types import Image, ImagesResponse |
| 93 | ``` |
| 94 | |
| 95 | Methods: |
| 96 | |
| 97 | - <code title="post /images/variations">client.images.<a href="./src/openai/resources/images.py">create_variation</a>(\*\*<a href="src/openai/types/image_create_variation_params.py">params</a>) -> <a href="./src/openai/types/images_response.py">ImagesResponse</a></code> |
| 98 | - <code title="post /images/edits">client.images.<a href="./src/openai/resources/images.py">edit</a>(\*\*<a href="src/openai/types/image_edit_params.py">params</a>) -> <a href="./src/openai/types/images_response.py">ImagesResponse</a></code> |
| 99 | - <code title="post /images/generations">client.images.<a href="./src/openai/resources/images.py">generate</a>(\*\*<a href="src/openai/types/image_generate_params.py">params</a>) -> <a href="./src/openai/types/images_response.py">ImagesResponse</a></code> |
| 100 | |
| 101 | # Audio |
| 102 | |
| 103 | ## Transcriptions |
| 104 | |
| 105 | Types: |
| 106 | |
| 107 | ```python |
| 108 | from openai.types.audio import Transcription |
| 109 | ``` |
| 110 | |
| 111 | Methods: |
| 112 | |
| 113 | - <code title="post /audio/transcriptions">client.audio.transcriptions.<a href="./src/openai/resources/audio/transcriptions.py">create</a>(\*\*<a href="src/openai/types/audio/transcription_create_params.py">params</a>) -> <a href="./src/openai/types/audio/transcription.py">Transcription</a></code> |
| 114 | |
| 115 | ## Translations |
| 116 | |
| 117 | Types: |
| 118 | |
| 119 | ```python |
| 120 | from openai.types.audio import Translation |
| 121 | ``` |
| 122 | |
| 123 | Methods: |
| 124 | |
| 125 | - <code title="post /audio/translations">client.audio.translations.<a href="./src/openai/resources/audio/translations.py">create</a>(\*\*<a href="src/openai/types/audio/translation_create_params.py">params</a>) -> <a href="./src/openai/types/audio/translation.py">Translation</a></code> |
| 126 | |
| 127 | ## Speech |
| 128 | |
| 129 | Methods: |
| 130 | |
| 131 | - <code title="post /audio/speech">client.audio.speech.<a href="./src/openai/resources/audio/speech.py">create</a>(\*\*<a href="src/openai/types/audio/speech_create_params.py">params</a>) -> HttpxBinaryResponseContent</code> |
| 132 | |
| 133 | # Moderations |
| 134 | |
| 135 | Types: |
| 136 | |
| 137 | ```python |
| 138 | from openai.types import Moderation, ModerationCreateResponse |
| 139 | ``` |
| 140 | |
| 141 | Methods: |
| 142 | |
| 143 | - <code title="post /moderations">client.moderations.<a href="./src/openai/resources/moderations.py">create</a>(\*\*<a href="src/openai/types/moderation_create_params.py">params</a>) -> <a href="./src/openai/types/moderation_create_response.py">ModerationCreateResponse</a></code> |
| 144 | |
| 145 | # Models |
| 146 | |
| 147 | Types: |
| 148 | |
| 149 | ```python |
| 150 | from openai.types import Model, ModelDeleted |
| 151 | ``` |
| 152 | |
| 153 | Methods: |
| 154 | |
| 155 | - <code title="get /models/{model}">client.models.<a href="./src/openai/resources/models.py">retrieve</a>(model) -> <a href="./src/openai/types/model.py">Model</a></code> |
| 156 | - <code title="get /models">client.models.<a href="./src/openai/resources/models.py">list</a>() -> <a href="./src/openai/types/model.py">SyncPage[Model]</a></code> |
| 157 | - <code title="delete /models/{model}">client.models.<a href="./src/openai/resources/models.py">delete</a>(model) -> <a href="./src/openai/types/model_deleted.py">ModelDeleted</a></code> |
| 158 | |
| 159 | # FineTuning |
| 160 | |
| 161 | ## Jobs |
| 162 | |
| 163 | Types: |
| 164 | |
| 165 | ```python |
| 166 | from openai.types.fine_tuning import FineTuningJob, FineTuningJobEvent |
| 167 | ``` |
| 168 | |
| 169 | Methods: |
| 170 | |
| 171 | - <code title="post /fine_tuning/jobs">client.fine_tuning.jobs.<a href="./src/openai/resources/fine_tuning/jobs.py">create</a>(\*\*<a href="src/openai/types/fine_tuning/job_create_params.py">params</a>) -> <a href="./src/openai/types/fine_tuning/fine_tuning_job.py">FineTuningJob</a></code> |
| 172 | - <code title="get /fine_tuning/jobs/{fine_tuning_job_id}">client.fine_tuning.jobs.<a href="./src/openai/resources/fine_tuning/jobs.py">retrieve</a>(fine_tuning_job_id) -> <a href="./src/openai/types/fine_tuning/fine_tuning_job.py">FineTuningJob</a></code> |
| 173 | - <code title="get /fine_tuning/jobs">client.fine_tuning.jobs.<a href="./src/openai/resources/fine_tuning/jobs.py">list</a>(\*\*<a href="src/openai/types/fine_tuning/job_list_params.py">params</a>) -> <a href="./src/openai/types/fine_tuning/fine_tuning_job.py">SyncCursorPage[FineTuningJob]</a></code> |
| 174 | - <code title="post /fine_tuning/jobs/{fine_tuning_job_id}/cancel">client.fine_tuning.jobs.<a href="./src/openai/resources/fine_tuning/jobs.py">cancel</a>(fine_tuning_job_id) -> <a href="./src/openai/types/fine_tuning/fine_tuning_job.py">FineTuningJob</a></code> |
| 175 | - <code title="get /fine_tuning/jobs/{fine_tuning_job_id}/events">client.fine_tuning.jobs.<a href="./src/openai/resources/fine_tuning/jobs.py">list_events</a>(fine_tuning_job_id, \*\*<a href="src/openai/types/fine_tuning/job_list_events_params.py">params</a>) -> <a href="./src/openai/types/fine_tuning/fine_tuning_job_event.py">SyncCursorPage[FineTuningJobEvent]</a></code> |
| 176 | |
| 177 | # FineTunes |
| 178 | |
| 179 | Types: |
| 180 | |
| 181 | ```python |
| 182 | from openai.types import FineTune, FineTuneEvent, FineTuneEventsListResponse |
| 183 | ``` |
| 184 | |
| 185 | Methods: |
| 186 | |
| 187 | - <code title="post /fine-tunes">client.fine_tunes.<a href="./src/openai/resources/fine_tunes.py">create</a>(\*\*<a href="src/openai/types/fine_tune_create_params.py">params</a>) -> <a href="./src/openai/types/fine_tune.py">FineTune</a></code> |
| 188 | - <code title="get /fine-tunes/{fine_tune_id}">client.fine_tunes.<a href="./src/openai/resources/fine_tunes.py">retrieve</a>(fine_tune_id) -> <a href="./src/openai/types/fine_tune.py">FineTune</a></code> |
| 189 | - <code title="get /fine-tunes">client.fine_tunes.<a href="./src/openai/resources/fine_tunes.py">list</a>() -> <a href="./src/openai/types/fine_tune.py">SyncPage[FineTune]</a></code> |
| 190 | - <code title="post /fine-tunes/{fine_tune_id}/cancel">client.fine_tunes.<a href="./src/openai/resources/fine_tunes.py">cancel</a>(fine_tune_id) -> <a href="./src/openai/types/fine_tune.py">FineTune</a></code> |
| 191 | - <code title="get /fine-tunes/{fine_tune_id}/events">client.fine_tunes.<a href="./src/openai/resources/fine_tunes.py">list_events</a>(fine_tune_id, \*\*<a href="src/openai/types/fine_tune_list_events_params.py">params</a>) -> <a href="./src/openai/types/fine_tune_events_list_response.py">FineTuneEventsListResponse</a></code> |
| 192 | |
| 193 | # Beta |
| 194 | |
| 195 | ## Assistants |
| 196 | |
| 197 | Types: |
| 198 | |
| 199 | ```python |
| 200 | from openai.types.beta import Assistant, AsssitantDeleted |
| 201 | ``` |
| 202 | |
| 203 | Methods: |
| 204 | |
| 205 | - <code title="post /assistants">client.beta.assistants.<a href="./src/openai/resources/beta/assistants/assistants.py">create</a>(\*\*<a href="src/openai/types/beta/assistant_create_params.py">params</a>) -> <a href="./src/openai/types/beta/assistant.py">Assistant</a></code> |
| 206 | - <code title="get /assistants/{assistant_id}">client.beta.assistants.<a href="./src/openai/resources/beta/assistants/assistants.py">retrieve</a>(assistant_id) -> <a href="./src/openai/types/beta/assistant.py">Assistant</a></code> |
| 207 | - <code title="post /assistants/{assistant_id}">client.beta.assistants.<a href="./src/openai/resources/beta/assistants/assistants.py">update</a>(assistant_id, \*\*<a href="src/openai/types/beta/assistant_update_params.py">params</a>) -> <a href="./src/openai/types/beta/assistant.py">Assistant</a></code> |
| 208 | - <code title="get /assistants">client.beta.assistants.<a href="./src/openai/resources/beta/assistants/assistants.py">list</a>(\*\*<a href="src/openai/types/beta/assistant_list_params.py">params</a>) -> <a href="./src/openai/types/beta/assistant.py">SyncCursorPage[Assistant]</a></code> |
| 209 | - <code title="delete /assistants/{assistant_id}">client.beta.assistants.<a href="./src/openai/resources/beta/assistants/assistants.py">delete</a>(assistant_id) -> <a href="./src/openai/types/beta/asssitant_deleted.py">AsssitantDeleted</a></code> |
| 210 | |
| 211 | ### Files |
| 212 | |
| 213 | Types: |
| 214 | |
| 215 | ```python |
| 216 | from openai.types.beta.assistants import AssistantFile, FileDeleteResponse |
| 217 | ``` |
| 218 | |
| 219 | Methods: |
| 220 | |
| 221 | - <code title="post /assistants/{assistant_id}/files">client.beta.assistants.files.<a href="./src/openai/resources/beta/assistants/files.py">create</a>(assistant_id, \*\*<a href="src/openai/types/beta/assistants/file_create_params.py">params</a>) -> <a href="./src/openai/types/beta/assistants/assistant_file.py">AssistantFile</a></code> |
| 222 | - <code title="get /assistants/{assistant_id}/files/{file_id}">client.beta.assistants.files.<a href="./src/openai/resources/beta/assistants/files.py">retrieve</a>(file_id, \*, assistant_id) -> <a href="./src/openai/types/beta/assistants/assistant_file.py">AssistantFile</a></code> |
| 223 | - <code title="get /assistants/{assistant_id}/files">client.beta.assistants.files.<a href="./src/openai/resources/beta/assistants/files.py">list</a>(assistant_id, \*\*<a href="src/openai/types/beta/assistants/file_list_params.py">params</a>) -> <a href="./src/openai/types/beta/assistants/assistant_file.py">SyncCursorPage[AssistantFile]</a></code> |
| 224 | - <code title="delete /assistants/{assistant_id}/files/{file_id}">client.beta.assistants.files.<a href="./src/openai/resources/beta/assistants/files.py">delete</a>(file_id, \*, assistant_id) -> <a href="./src/openai/types/beta/assistants/file_delete_response.py">FileDeleteResponse</a></code> |
| 225 | |
| 226 | ## Threads |
| 227 | |
| 228 | Types: |
| 229 | |
| 230 | ```python |
| 231 | from openai.types.beta import Thread, ThreadDeleted |
| 232 | ``` |
| 233 | |
| 234 | Methods: |
| 235 | |
| 236 | - <code title="post /threads">client.beta.threads.<a href="./src/openai/resources/beta/threads/threads.py">create</a>(\*\*<a href="src/openai/types/beta/thread_create_params.py">params</a>) -> <a href="./src/openai/types/beta/thread.py">Thread</a></code> |
| 237 | - <code title="get /threads/{thread_id}">client.beta.threads.<a href="./src/openai/resources/beta/threads/threads.py">retrieve</a>(thread_id) -> <a href="./src/openai/types/beta/thread.py">Thread</a></code> |
| 238 | - <code title="post /threads/{thread_id}">client.beta.threads.<a href="./src/openai/resources/beta/threads/threads.py">update</a>(thread_id, \*\*<a href="src/openai/types/beta/thread_update_params.py">params</a>) -> <a href="./src/openai/types/beta/thread.py">Thread</a></code> |
| 239 | - <code title="delete /threads/{thread_id}">client.beta.threads.<a href="./src/openai/resources/beta/threads/threads.py">delete</a>(thread_id) -> <a href="./src/openai/types/beta/thread_deleted.py">ThreadDeleted</a></code> |
| 240 | - <code title="post /threads/runs">client.beta.threads.<a href="./src/openai/resources/beta/threads/threads.py">create_and_run</a>(\*\*<a href="src/openai/types/beta/thread_create_and_run_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/run.py">Run</a></code> |
| 241 | |
| 242 | ### Runs |
| 243 | |
| 244 | Types: |
| 245 | |
| 246 | ```python |
| 247 | from openai.types.beta.threads import RequiredActionFunctionToolCall, Run |
| 248 | ``` |
| 249 | |
| 250 | Methods: |
| 251 | |
| 252 | - <code title="post /threads/{thread_id}/runs">client.beta.threads.runs.<a href="./src/openai/resources/beta/threads/runs/runs.py">create</a>(thread_id, \*\*<a href="src/openai/types/beta/threads/run_create_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/run.py">Run</a></code> |
| 253 | - <code title="get /threads/{thread_id}/runs/{run_id}">client.beta.threads.runs.<a href="./src/openai/resources/beta/threads/runs/runs.py">retrieve</a>(run_id, \*, thread_id) -> <a href="./src/openai/types/beta/threads/run.py">Run</a></code> |
| 254 | - <code title="post /threads/{thread_id}/runs/{run_id}">client.beta.threads.runs.<a href="./src/openai/resources/beta/threads/runs/runs.py">update</a>(run_id, \*, thread_id, \*\*<a href="src/openai/types/beta/threads/run_update_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/run.py">Run</a></code> |
| 255 | - <code title="get /threads/{thread_id}/runs">client.beta.threads.runs.<a href="./src/openai/resources/beta/threads/runs/runs.py">list</a>(thread_id, \*\*<a href="src/openai/types/beta/threads/run_list_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/run.py">SyncCursorPage[Run]</a></code> |
| 256 | - <code title="post /threads/{thread_id}/runs/{run_id}/cancel">client.beta.threads.runs.<a href="./src/openai/resources/beta/threads/runs/runs.py">cancel</a>(run_id, \*, thread_id) -> <a href="./src/openai/types/beta/threads/run.py">Run</a></code> |
| 257 | - <code title="post /threads/{thread_id}/runs/{run_id}/submit_tool_outputs">client.beta.threads.runs.<a href="./src/openai/resources/beta/threads/runs/runs.py">submit_tool_outputs</a>(run_id, \*, thread_id, \*\*<a href="src/openai/types/beta/threads/run_submit_tool_outputs_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/run.py">Run</a></code> |
| 258 | |
| 259 | #### Steps |
| 260 | |
| 261 | Types: |
| 262 | |
| 263 | ```python |
| 264 | from openai.types.beta.threads.runs import ( |
| 265 | CodeToolCall, |
| 266 | FunctionToolCall, |
| 267 | MessageCreationStepDetails, |
| 268 | RetrievalToolCall, |
| 269 | RunStep, |
| 270 | ToolCallsStepDetails, |
| 271 | ) |
| 272 | ``` |
| 273 | |
| 274 | Methods: |
| 275 | |
| 276 | - <code title="get /threads/{thread_id}/runs/{run_id}/steps/{step_id}">client.beta.threads.runs.steps.<a href="./src/openai/resources/beta/threads/runs/steps.py">retrieve</a>(step_id, \*, thread_id, run_id) -> <a href="./src/openai/types/beta/threads/runs/run_step.py">RunStep</a></code> |
| 277 | - <code title="get /threads/{thread_id}/runs/{run_id}/steps">client.beta.threads.runs.steps.<a href="./src/openai/resources/beta/threads/runs/steps.py">list</a>(run_id, \*, thread_id, \*\*<a href="src/openai/types/beta/threads/runs/step_list_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/runs/run_step.py">SyncCursorPage[RunStep]</a></code> |
| 278 | |
| 279 | ### Messages |
| 280 | |
| 281 | Types: |
| 282 | |
| 283 | ```python |
| 284 | from openai.types.beta.threads import ( |
| 285 | MessageContentImageFile, |
| 286 | MessageContentText, |
| 287 | ThreadMessage, |
| 288 | ThreadMessageDeleted, |
| 289 | ) |
| 290 | ``` |
| 291 | |
| 292 | Methods: |
| 293 | |
| 294 | - <code title="post /threads/{thread_id}/messages">client.beta.threads.messages.<a href="./src/openai/resources/beta/threads/messages/messages.py">create</a>(thread_id, \*\*<a href="src/openai/types/beta/threads/message_create_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/thread_message.py">ThreadMessage</a></code> |
| 295 | - <code title="get /threads/{thread_id}/messages/{message_id}">client.beta.threads.messages.<a href="./src/openai/resources/beta/threads/messages/messages.py">retrieve</a>(message_id, \*, thread_id) -> <a href="./src/openai/types/beta/threads/thread_message.py">ThreadMessage</a></code> |
| 296 | - <code title="post /threads/{thread_id}/messages/{message_id}">client.beta.threads.messages.<a href="./src/openai/resources/beta/threads/messages/messages.py">update</a>(message_id, \*, thread_id, \*\*<a href="src/openai/types/beta/threads/message_update_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/thread_message.py">ThreadMessage</a></code> |
| 297 | - <code title="get /threads/{thread_id}/messages">client.beta.threads.messages.<a href="./src/openai/resources/beta/threads/messages/messages.py">list</a>(thread_id, \*\*<a href="src/openai/types/beta/threads/message_list_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/thread_message.py">SyncCursorPage[ThreadMessage]</a></code> |
| 298 | |
| 299 | #### Files |
| 300 | |
| 301 | Types: |
| 302 | |
| 303 | ```python |
| 304 | from openai.types.beta.threads.messages import MessageFile |
| 305 | ``` |
| 306 | |
| 307 | Methods: |
| 308 | |
| 309 | - <code title="get /threads/{thread_id}/messages/{message_id}/files/{file_id}">client.beta.threads.messages.files.<a href="./src/openai/resources/beta/threads/messages/files.py">retrieve</a>(file_id, \*, thread_id, message_id) -> <a href="./src/openai/types/beta/threads/messages/message_file.py">MessageFile</a></code> |
| 310 | - <code title="get /threads/{thread_id}/messages/{message_id}/files">client.beta.threads.messages.files.<a href="./src/openai/resources/beta/threads/messages/files.py">list</a>(message_id, \*, thread_id, \*\*<a href="src/openai/types/beta/threads/messages/file_list_params.py">params</a>) -> <a href="./src/openai/types/beta/threads/messages/message_file.py">SyncCursorPage[MessageFile]</a></code> |
| 311 | |