pub struct GenericCompletionModel<Ext = OpenAICompletionsExt, H = Client> {
pub model: String,
/* private fields */
}Expand description
A chat-completions model over any OpenAICompatibleProvider extension.
This is the advertised path for OpenAI-compatible providers; see the
provider checklist in crate::providers.
Fields§
§model: StringImplementations§
Source§impl<Ext, H> GenericCompletionModel<Ext, H>where
Client<Ext, H>: HttpClientExt + Clone + 'static,
Ext: Provider + OpenAICompatibleProvider + Clone + WasmCompatSend + 'static,
impl<Ext, H> GenericCompletionModel<Ext, H>where
Client<Ext, H>: HttpClientExt + Clone + 'static,
Ext: Provider + OpenAICompatibleProvider + Clone + WasmCompatSend + 'static,
Sourcepub async fn raw_stream(
&self,
completion_request: CompletionRequest,
) -> Result<Pin<Box<dyn Stream<Item = Result<RawStreamingChoice<StreamingCompletionResponse<<Ext as OpenAICompatibleProvider>::StreamingUsage>>, CompletionError>> + Send>>, CompletionError>
pub async fn raw_stream( &self, completion_request: CompletionRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<RawStreamingChoice<StreamingCompletionResponse<<Ext as OpenAICompatibleProvider>::StreamingUsage>>, CompletionError>> + Send>>, CompletionError>
Open a chat-completions stream whose terminal record stays provider-native.
This is the escape hatch for provider-specific terminal fields rig does
not normalize. It shares the request builder, transport, telemetry, and
error handling with
CompletionModel::stream,
which calls it and normalizes the terminal record — one network request
either way.
Source§impl<Ext, H> GenericCompletionModel<Ext, H>
impl<Ext, H> GenericCompletionModel<Ext, H>
pub fn new( client: Client<Ext, H>, model: impl Into<String>, ) -> GenericCompletionModel<Ext, H>
Sourcepub fn with_strict_tools(self) -> GenericCompletionModel<Ext, H>
pub fn with_strict_tools(self) -> GenericCompletionModel<Ext, H>
Enable strict mode for tool schemas.
When enabled, tool schemas are automatically sanitized to meet OpenAI’s strict mode requirements:
additionalProperties: falseis added to all objects- All properties are marked as required
strict: trueis set on each function definition
This allows OpenAI to guarantee that the model’s tool calls will match the schema exactly.
pub fn with_tool_result_array_content(self) -> GenericCompletionModel<Ext, H>
Source§impl<Ext, H> GenericCompletionModel<Ext, H>where
Client<Ext, H>: HttpClientExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
Ext: Provider + OpenAICompatibleProvider + DebugExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
impl<Ext, H> GenericCompletionModel<Ext, H>where
Client<Ext, H>: HttpClientExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
Ext: Provider + OpenAICompatibleProvider + DebugExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
Sourcepub async fn raw_completion(
&self,
completion_request: CompletionRequest,
) -> Result<<Ext as OpenAICompatibleProvider>::Response, CompletionError>
pub async fn raw_completion( &self, completion_request: CompletionRequest, ) -> Result<<Ext as OpenAICompatibleProvider>::Response, CompletionError>
Execute a chat completion and return the provider’s own wire response.
This is the escape hatch for provider-specific fields rig does not
normalize. It shares the request builder, transport, telemetry, and
error handling with
CompletionModel::completion,
which calls it and then applies the provider-local mapping — one
network request either way.
The transport request id is not on the wire type and is dropped here;
use Self::raw_completion_with_request_id when the typed route must
reproduce everything completion returns.
Sourcepub async fn raw_completion_with_request_id(
&self,
completion_request: CompletionRequest,
) -> Result<(<Ext as OpenAICompatibleProvider>::Response, Option<String>), CompletionError>
pub async fn raw_completion_with_request_id( &self, completion_request: CompletionRequest, ) -> Result<(<Ext as OpenAICompatibleProvider>::Response, Option<String>), CompletionError>
Self::raw_completion plus the transport request id from the
provider’s request-id response header (OpenAICompatibleProvider::REQUEST_ID_HEADER).
The pair exists because the wire type is substitutable — Ext::Response
is whatever the compatible provider parses — so the transport id cannot
live on it, while the normalized completion::CompletionResponse
carries one. Without this method, raw_completion(..) followed by
normalize
would silently lack the provider_request_id that
CompletionModel::completion
reports — the typed escape hatch would not reproduce the normalized
path. Reassemble with
with_optional_provider_request_id.
Source§impl<H> GenericCompletionModel<OpenRouterExt, H>
impl<H> GenericCompletionModel<OpenRouterExt, H>
Sourcepub fn with_prompt_caching(self) -> GenericCompletionModel<OpenRouterExt, H>
pub fn with_prompt_caching(self) -> GenericCompletionModel<OpenRouterExt, H>
Enable explicit prompt caching for supported OpenRouter models.
Adds cache_control: {"type": "ephemeral"} to the system-prompt
block so subsequent turns that share the same system prefix can be
billed at the cache-hit rate when the selected model/provider supports
explicit cache breakpoints.
Trait Implementations§
Source§impl<Ext, H> Clone for GenericCompletionModel<Ext, H>
impl<Ext, H> Clone for GenericCompletionModel<Ext, H>
Source§fn clone(&self) -> GenericCompletionModel<Ext, H>
fn clone(&self) -> GenericCompletionModel<Ext, H>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Ext, H> CompletionModel for GenericCompletionModel<Ext, H>where
Client<Ext, H>: HttpClientExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
Ext: Provider + OpenAICompatibleProvider + DebugExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
impl<Ext, H> CompletionModel for GenericCompletionModel<Ext, H>where
Client<Ext, H>: HttpClientExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
Ext: Provider + OpenAICompatibleProvider + DebugExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
Source§fn capabilities(&self) -> ProviderCapabilities
fn capabilities(&self) -> ProviderCapabilities
Source§async fn completion(
&self,
completion_request: CompletionRequest,
) -> Result<CompletionResponse, CompletionError>
async fn completion( &self, completion_request: CompletionRequest, ) -> Result<CompletionResponse, CompletionError>
Source§async fn stream(
&self,
request: CompletionRequest,
) -> Result<StreamingCompletionResponse, CompletionError>
async fn stream( &self, request: CompletionRequest, ) -> Result<StreamingCompletionResponse, CompletionError>
Source§fn completion_request(
&self,
prompt: impl Into<Message>,
) -> CompletionRequestBuilder<Self>
fn completion_request( &self, prompt: impl Into<Message>, ) -> CompletionRequestBuilder<Self>
prompt.