The LLM API Connector is a comprehensive framework for Unity applications to interact with various large language model APIs, including Anthropic's Claude, Google's Gemini, and OpenAI's GPT models. This framework provides a unified interface for sending requests, managing conversations, and processing responses, while abstracting away the differences between the underlying API implementations.
The system is built around a polymorphic singleton pattern that allows for multiple model-specific implementations to share a common interface while maintaining independent instances. The architecture consists of:
Inheritance: MonoBehaviour
A base class that enables polymorphic singleton pattern, allowing derived classes to maintain their own singleton instances while preserving type hierarchies.
Properties:
| Name | Type | Description |
|---|---|---|
| none |
Methods:
| Name | Return Type | Description |
|---|---|---|
| GetInstance<TU>() | TU | Protected static method to retrieve or create the singleton instance of type TU. |
| Awake() | void | Virtual method called when the script instance is being loaded. Ensures proper singleton instance management. |
| OnDestroy() | void | Virtual method called when the MonoBehaviour will be destroyed. Cleans up the singleton instance. |
| OnApplicationQuit() | void | Virtual method called when the application is quitting. Sets the shutdown flag. |