Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

707 B
Raw Blame
use std::{convert::Infallible, future::Future};

use litellm_host::protocol::Protocol;

pub trait HostCallHandler<P: Protocol>: Send + Sync {
    fn handle_host_call(
        &self,
        call: P::HostCall,
    ) -> impl Future<Output = Result<(), P::Error>> + Send;
}

impl<P: Protocol, T: HostCallHandler<P> + ?Sized> HostCallHandler<P> for &T {
    fn handle_host_call(
        &self,
        call: P::HostCall,
    ) -> impl Future<Output = Result<(), P::Error>> + Send {
        (**self).handle_host_call(call)
    }
}

impl<P: Protocol<HostCall = Infallible>> HostCallHandler<P> for () {
    async fn handle_host_call(&self, call: Infallible) -> Result<(), P::Error> {
        match call {}
    }
}