pub struct ChatCompletionRequest {Show 21 fields
pub model: String,
pub messages: Vec<ChatCompletionRequestMessage>,
pub frequency_penalty: Option<f32>,
pub logit_bias: Option<Map<String, Value>>,
pub logprobs: Option<bool>,
pub top_logprobs: Option<i32>,
pub max_tokens: Option<i32>,
pub n: Option<i32>,
pub presence_penalty: Option<f32>,
pub response_format: Option<ResponseFormat>,
pub seed: Option<i64>,
pub stop: Option<Stop>,
pub stream: Option<bool>,
pub stream_options: Option<StreamOptions>,
pub thinking: Option<ThinkingConfig>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub tools: Option<Vec<Tool>>,
pub tool_choice: Option<ToolChoice>,
pub parallel_tool_calls: Option<bool>,
pub user: Option<String>,
}Expand description
Chat completion request
Fields§
§model: StringID of the model to use
messages: Vec<ChatCompletionRequestMessage>A list of messages comprising the conversation
frequency_penalty: Option<f32>Number between -2.0 and 2.0 for frequency penalty
logit_bias: Option<Map<String, Value>>Modify the likelihood of specified tokens
logprobs: Option<bool>Whether to return log probabilities
top_logprobs: Option<i32>Number of most likely tokens to return at each position
max_tokens: Option<i32>Maximum number of tokens to generate
n: Option<i32>How many chat completion choices to generate
presence_penalty: Option<f32>Number between -2.0 and 2.0 for presence penalty
response_format: Option<ResponseFormat>Response format configuration
seed: Option<i64>Seed for deterministic sampling
stop: Option<Stop>Stop sequences
stream: Option<bool>Whether to stream the response
stream_options: Option<StreamOptions>Stream options
thinking: Option<ThinkingConfig>Thinking mode configuration (Claude models)
temperature: Option<f32>Sampling temperature (0-2)
top_p: Option<f32>Nucleus sampling parameter (0-1)
tools: Option<Vec<Tool>>List of tools the model may call
tool_choice: Option<ToolChoice>Controls which tool is called
parallel_tool_calls: Option<bool>Whether to enable parallel tool calls
user: Option<String>A unique identifier for the end-user
Implementations§
Source§impl ChatCompletionRequest
impl ChatCompletionRequest
Sourcepub fn new(
model: impl Into<String>,
messages: Vec<ChatCompletionRequestMessage>,
) -> Self
pub fn new( model: impl Into<String>, messages: Vec<ChatCompletionRequestMessage>, ) -> Self
Creates a new chat completion request with the minimum required fields.
§Arguments
model- The model ID to use (e.g., “gpt-4o”, “claude-3-5-sonnet-20241022”)messages- The conversation messages
§Example
use portkey_sdk::model::{ChatCompletionRequest, ChatCompletionRequestMessage};
let request = ChatCompletionRequest::new(
"gpt-4o",
vec![
ChatCompletionRequestMessage::user("Hello!"),
],
);Trait Implementations§
Source§impl Clone for ChatCompletionRequest
impl Clone for ChatCompletionRequest
Source§fn clone(&self) -> ChatCompletionRequest
fn clone(&self) -> ChatCompletionRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more