Skip to main content

CompletionClient

Trait CompletionClient 

Source
pub trait CompletionClient {
    type CompletionModel: CompletionModel;

    // Required method
    fn completion_model(
        &self,
        model: impl Into<String>,
    ) -> Self::CompletionModel;
}
Expand description

A provider client with completion capabilities.

Clients remain Clone for conversions between client types; the models they construct no longer need to be.

Required Associated Types§

Source

type CompletionModel: CompletionModel

The type of CompletionModel used by the client.

Required Methods§

Source

fn completion_model(&self, model: impl Into<String>) -> Self::CompletionModel

Create a completion model with the given model.

Construction lives here rather than on CompletionModel so a model type can be implemented — and used — without any client type at all. Implement this by calling the model’s own inherent constructor.

§Example with OpenAI
use rig_core::prelude::*;
use rig_core::providers::openai::{Client, self};

// Initialize the OpenAI client
let openai = Client::new("your-open-ai-api-key")?;

let gpt = openai.completion_model(openai::GPT_5_2);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<M, Ext, H> CompletionClient for Client<Ext, H>
where Ext: Capabilities<H, Completion = Capable<M>>, M: CompletionModel + ConstructCompletionModel<Client<Ext, H>>,