pub trait ClientApiAccessors<E>{
// Required methods
fn chat(&self) -> Chat<'_, E>;
fn models(&self) -> Models<'_, E>;
}Expand description
Trait providing convenient API accessors for the client.
This trait adds methods like chat() and models() to the Client type,
providing a fluent interface for accessing different API endpoints.
§Examples
use api_xai::{ Client, XaiEnvironmentImpl, Secret, ClientApiAccessors, Message };
let secret = Secret::load_with_fallbacks( "XAI_API_KEY" )?;
let env = XaiEnvironmentImpl::new( secret )?;
let client = Client::build( env )?;
// Using the chat accessor
let request = api_xai::ChatCompletionRequest::former()
.model( "grok-2-1212".to_string() )
.messages( vec![ Message::user( "Hello!" ) ] )
.form();
let response = client.chat().create( request ).await?;
// Using the models accessor
let models = client.models().list().await?;