LLM Clients
TrustTest provides a flexible abstraction layer for working with different LLM providers through itsLLMClient interface. This architecture allows for seamless integration with various LLM services while maintaining a consistent interface for generating questions, evaluations, and other LLM-powered features.
Architecture
The core of this system is theLLMClient abstract base class, which defines two main methods:
complete(instructions, system_prompt): For single-prompt completionscomplete_chat(messages): For multi-turn conversations
Supported Providers
get_llm_client(provider=..., model=..., **kwargs) supports: openai, azure, google, anthropic, ollama, vllm, groq, deepseek, http.
HTTP judge / generator
HTTPClient is an LLM client. HttpTarget is the model you are testing. Do not mix them.
concatenate_field supports dot paths. Placeholders default to {{ instructions }} and {{ system_prompt }}.
You can also pass llm_client= on individual probes and evaluators instead of changing global config.
Usage Example
Embeddings Clients
TrustTest provides a flexible abstraction layer for working with different embedding providers through itsEmbeddingsModel interface. This architecture allows for seamless integration with various embedding services while maintaining a consistent interface for generating vector representations of text.
Architecture
The core of this system is theEmbeddingsModel abstract base class, which defines the main method:
embed(texts): Converts a sequence of texts into numerical vector representations
Supported Providers
get_embeddings_model(provider=..., model=...) supports openai, azure, google, and ollama.
trusttest[azure] (or trusttest[rag-azure]) for Azure embeddings. Vector knowledge bases need embeddings plus a topic_summarizer LLM via set_config.
Usage Example
Global Configuration
TrustTest provides a global configuration system to manage LLM and embeddings settings across your application. The configuration can be set using theset_config() function, which accepts a dictionary with settings for different components:
evaluator, question_generator, translation (used by StaticDatasetProbe.translate_into_language), topic_summarizer, embeddings.
LLM fields: provider, model, temperature, optional retry_config (attempts, initial_delay, max_delay, exp_base), optional extra_args. Config provider literals are openai, azure, deepseek, vllm, google, anthropic, ollama, http. Use get_llm_client(provider="groq", ...) for Groq.
Embeddings fields: provider (openai, azure, google, ollama) and model.
Defaults when you do not set config: gpt-4o-mini (all LLM tasks) and text-embedding-3-small.
Config files
On import, TrustTest looks in the current working directory for.trusttest_config.json, then trusttest_config.json. The JSON object uses the same keys as set_config. If neither file exists and you never called set_config, get_config() raises TrustTestConfigError.
Implementing Custom Clients
Both LLM and Embeddings clients can be easily extended by implementing custom providers. The base classes provide a clear interface that you need to implement.Custom LLM Client
To create a custom LLM client, inherit fromLLMClient and implement the required methods:
Custom Embeddings Client
To create a custom embeddings client, inherit fromEmbeddingsModel and implement the required method: