Understanding services
Your RTVI client can configure any services registered in an RTVI-powered bot using the configuration options it makes available. Service registration within your bot might look something like this pseudocode:llm with two config options, model and messages, as well as their associated handlers.
Bots can define one or more services to a particular function. For example, we may want to run a pipeline that can be switched between different LLM providers e.g. OpenAI, Together, Anthropic etc.
Names and providers
In the above example, we have a factory method that returns the relevant provider class for a specific service based on name string.- Service Name - An arbitrary string that references the service in your bot file, e.g.
"llm" - Service Provider - A provider-specific implementation that gets included in the pipeline, e.g.
OpenAILLMService
Selecting between services on the client
RTVI bots can be passed an optionalservices object at startup that can be used to specify which provider to use for the specified service name.
In the above above example, we can configure a voice client to use Together like so:
Passing API keys
RTVI bots accept anapi_keys object, mapping them to the relevant service account. Here is an example server-side route
using NextJS:
You can also extend your config object here, if you wanted to provide some
defaults outside of the client constructor.
configreferences the service name that it was registered with in your bot file.servicesspecifies which provider / service account to use for a specific name-matched service in the registry (in this case,llm.)api_keysprovides a key matched to the service account.