pub struct CreateEmbeddingRequest {
pub model: String,
pub input: EmbeddingInput,
pub encoding_format: Option<EncodingFormat>,
pub dimensions: Option<i32>,
pub user: Option<String>,
}Expand description
Request to create embeddings.
§Example
use portkey_sdk::model::{CreateEmbeddingRequest, EmbeddingInput, EncodingFormat};
let request = CreateEmbeddingRequest {
model: "text-embedding-ada-002".to_string(),
input: EmbeddingInput::String("The quick brown fox jumped over the lazy dog".to_string()),
encoding_format: Some(EncodingFormat::Float),
dimensions: None,
user: None,
};Fields§
§model: StringID of the model to use.
Common models:
text-embedding-ada-002text-embedding-3-smalltext-embedding-3-large
input: EmbeddingInputInput text to embed.
Can be a string, array of strings, array of tokens, or array of token arrays.
The input must not exceed the max input tokens for the model (8192 tokens for
text-embedding-ada-002), cannot be an empty string, and any array must be
2048 dimensions or less.
encoding_format: Option<EncodingFormat>The format to return the embeddings in.
Can be either float or base64. Defaults to float.
dimensions: Option<i32>The number of dimensions the resulting output embeddings should have.
Only supported in text-embedding-3 and later models.
user: Option<String>A unique identifier representing your end-user.
This can help providers monitor and detect abuse.
Implementations§
Source§impl CreateEmbeddingRequest
impl CreateEmbeddingRequest
Sourcepub fn new(model: impl Into<String>, input: impl Into<EmbeddingInput>) -> Self
pub fn new(model: impl Into<String>, input: impl Into<EmbeddingInput>) -> Self
Creates a new embedding request with the minimum required fields.
§Arguments
model- The model ID to use (e.g., “text-embedding-ada-002”, “text-embedding-3-small”)input- The input text or texts to embed
§Example
use portkey_sdk::model::{CreateEmbeddingRequest, EmbeddingInput};
let request = CreateEmbeddingRequest::new(
"text-embedding-ada-002",
"Hello, world!",
);Trait Implementations§
Source§impl Clone for CreateEmbeddingRequest
impl Clone for CreateEmbeddingRequest
Source§fn clone(&self) -> CreateEmbeddingRequest
fn clone(&self) -> CreateEmbeddingRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CreateEmbeddingRequest
impl Debug for CreateEmbeddingRequest
Source§impl<'de> Deserialize<'de> for CreateEmbeddingRequest
impl<'de> Deserialize<'de> for CreateEmbeddingRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CreateEmbeddingRequest
impl RefUnwindSafe for CreateEmbeddingRequest
impl Send for CreateEmbeddingRequest
impl Sync for CreateEmbeddingRequest
impl Unpin for CreateEmbeddingRequest
impl UnwindSafe for CreateEmbeddingRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more