Struct OpenAIApi

Source
pub struct OpenAIApi { /* private fields */ }

Implementations§

Source§

impl OpenAIApi

Source

pub fn new(configuration: Configuration) -> Self

Source

pub async fn list_models(self) -> Result<ListModelsResponse, OpenAIApiError>

List models GET https://api.openai.com/v1/models Lists the currently available models, and provides basic information about each one such as the owner and availability.

Source

pub async fn retrieve_model( self, model: String, ) -> Result<RetrieveModelResponse, OpenAIApiError>

Retrieve model GET https://api.openai.com/v1/models/{model} Retrieves a model instance, providing basic information about the model such as the owner and permissioning.

Source

pub async fn create_completion( self, request: CreateCompletionRequest, ) -> Result<CreateCompletionResponse, OpenAIApiError>

Create completion POST https://api.openai.com/v1/completions Creates a completion for the provided prompt and parameters

Source

pub async fn create_completion_stream( self, request: CreateCompletionRequest, ) -> Result<CreateCompletionResponseStream, OpenAIApiError>

Creates a completion request for the provided prompt and parameters

Stream back partial progress. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.

[CompletionResponseStream] is a parsed SSE stream until a [DONE] is received from server.

Source

pub async fn create_chat_completion( self, request: CreateChatCompletionRequest, ) -> Result<CreateChatCompletionResponse, OpenAIApiError>

Create chat completion POST https://api.openai.com/v1/chat/completions Creates a completion for the chat message

Source

pub async fn create_chat_completion_stream( self, request: CreateChatCompletionRequest, ) -> Result<CreateChatCompletionResponseStream, OpenAIApiError>

Creates a chat completion request for the provided prompt and parameters

Stream back partial progress. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.

[ChatCompletionResponseStream] is a parsed SSE stream until a [DONE] is received from server.

Source

pub async fn create_edit( self, request: CreateEditRequest, ) -> Result<CreateEditResponse, OpenAIApiError>

Create edit POST https://api.openai.com/v1/edits Creates a new edit for the provided input, instruction, and parameters.

Source

pub async fn create_image( self, request: CreateImageRequest, ) -> Result<CreateImageResponse, OpenAIApiError>

Create image POST https://api.openai.com/v1/images/generations Creates an image given a prompt.

Source

pub async fn create_image_edit( self, request: CreateImageEditRequest, ) -> Result<CreateImageEditResponse, OpenAIApiError>

Create image editBeta POST https://api.openai.com/v1/images/edits Creates an edited or extended image given an original image and a prompt.

Source

pub async fn create_image_variation( self, request: CreateImageVariationRequest, ) -> Result<CreateImageVariationResponse, OpenAIApiError>

Create image variation POST https://api.openai.com/v1/images/variations Creates a variation of a given image.

Source

pub async fn create_embeddings( self, request: CreateEmbeddingsRequest, ) -> Result<CreateEmbeddingsResponse, OpenAIApiError>

Create embeddings POST https://api.openai.com/v1/embeddings Creates an embedding vector representing the input text.

Source

pub async fn create_transcription( self, request: CreateTranscriptionRequest, ) -> Result<CreateTranscriptionResponse, OpenAIApiError>

Create transcription POST https://api.openai.com/v1/audio/transcriptions Transcribes audio into the input language.

Source

pub async fn create_translation( self, request: CreateTranslationRequest, ) -> Result<CreateTranslationResponse, OpenAIApiError>

Create translation POST https://api.openai.com/v1/audio/translations Translates audio into into English.

Source

pub async fn list_files(self) -> Result<ListFilesResponse, OpenAIApiError>

List files GET https://api.openai.com/v1/files Returns a list of files that belong to the user’s organization.

Source

pub async fn upload_file( self, request: UploadFileRequest, ) -> Result<UploadFileResponse, OpenAIApiError>

Upload file POST https://api.openai.com/v1/files Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.

Source

pub async fn delete_file( self, file_id: String, ) -> Result<DeleteFileResponse, OpenAIApiError>

Delete file DELETE https://api.openai.com/v1/files/{file_id} Delete a file.

Source

pub async fn retrieve_file( self, file_id: String, ) -> Result<RetrieveFileResponse, OpenAIApiError>

Retrieve file GET https://api.openai.com/v1/files/{file_id} Returns information about a specific file.

Source

pub async fn retrieve_file_content( self, file_id: String, ) -> Result<String, OpenAIApiError>

Retrieve file content GET https://api.openai.com/v1/files/{file_id}/content Returns the contents of the specified file

Source

pub async fn create_fine_tune( self, request: CreateFineTuneRequest, ) -> Result<CreateFineTuneResponse, OpenAIApiError>

Create fine-tune POST https://api.openai.com/v1/fine-tunes Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.

Source

pub async fn list_fine_tunes( self, ) -> Result<ListFineTunesResponse, OpenAIApiError>

List fine-tunes GET https://api.openai.com/v1/fine-tunes List your organization’s fine-tuning jobs

Source

pub async fn retrieve_fine_tune( self, fine_tune_id: String, ) -> Result<RetrieveFineTuneResponse, OpenAIApiError>

Retrieve fine-tune GET https://api.openai.com/v1/fine-tunes/{fine_tune_id} Gets info about the fine-tune job.

Source

pub async fn cancel_fine_tune( self, fine_tune_id: String, ) -> Result<CancelFineTuneResponse, OpenAIApiError>

Cancel fine-tune POST https://api.openai.com/v1/fine-tunes/{fine_tune_id}/cancel Immediately cancel a fine-tune job.

Source

pub async fn list_fine_tune_events( self, fine_tune_id: String, ) -> Result<ListFineTuneEventsResponse, OpenAIApiError>

List fine-tune events GET https://api.openai.com/v1/fine-tunes/{fine_tune_id}/events Get fine-grained status updates for a fine-tune job.

Source

pub async fn delete_fine_tune_model( self, model: String, ) -> Result<DeleteFineTuneModelResponse, OpenAIApiError>

Delete fine-tune model DELETE https://api.openai.com/v1/models/{model} Delete a fine-tuned model. You must have the Owner role in your organization.

Source

pub async fn create_moderation( self, request: CreateModerationRequest, ) -> Result<CreateModerationResponse, OpenAIApiError>

Create moderation POST https://api.openai.com/v1/moderations Classifies if text violates OpenAI’s Content Policy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,