pub struct Completions<'c, C: Config> { /* private fields */ }
Expand description
Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position. We recommend most users use our Chat completions API. Learn more
Related guide: Legacy Completions
Implementations§
Source§impl<'c, C: Config> Completions<'c, C>
impl<'c, C: Config> Completions<'c, C>
pub fn new(client: &'c Client<C>) -> Self
Sourcepub async fn create(
&self,
request: CreateCompletionRequest,
) -> Result<CreateCompletionResponse, OpenAIError>
pub async fn create( &self, request: CreateCompletionRequest, ) -> Result<CreateCompletionResponse, OpenAIError>
Creates a completion for the provided prompt and parameters
You must ensure that “stream: false” in serialized request
Creates a completion for the provided prompt and parameters
You must ensure that “stream: false” in serialized request
Sourcepub async fn create_byot<T0: Serialize, R: DeserializeOwned>(
&self,
request: T0,
) -> Result<R, OpenAIError>
pub async fn create_byot<T0: Serialize, R: DeserializeOwned>( &self, request: T0, ) -> Result<R, OpenAIError>
Creates a completion for the provided prompt and parameters
You must ensure that “stream: false” in serialized request
Sourcepub async fn create_stream(
&self,
request: CreateCompletionRequest,
) -> Result<CompletionResponseStream, OpenAIError>
pub async fn create_stream( &self, request: CreateCompletionRequest, ) -> Result<CompletionResponseStream, OpenAIError>
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.
You must ensure that “stream: true” in serialized request
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.
You must ensure that “stream: true” in serialized request
Sourcepub async fn create_stream_byot<T0: Serialize, R>(
&self,
request: T0,
) -> Result<Pin<Box<dyn Stream<Item = Result<R, OpenAIError>> + Send>>, OpenAIError>where
R: Send + 'static + DeserializeOwned,
pub async fn create_stream_byot<T0: Serialize, R>(
&self,
request: T0,
) -> Result<Pin<Box<dyn Stream<Item = Result<R, OpenAIError>> + Send>>, OpenAIError>where
R: Send + 'static + DeserializeOwned,
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.
You must ensure that “stream: true” in serialized request