Table of Contents
Module spoon_ai.llm.providers.openai_compatible_provider
OpenAI Compatible Provider base class for providers that use OpenAI-compatible APIs. This includes OpenAI, OpenRouter, DeepSeek, and other providers with similar interfaces.
OpenAICompatibleProvider Objects​
class OpenAICompatibleProvider(LLMProviderInterface)
Base class for OpenAI-compatible providers.
get_provider_name​
def get_provider_name() -> str
Get the provider name. Should be overridden by subclasses.
get_default_base_url​
def get_default_base_url() -> str
Get the default base URL. Should be overridden by subclasses.
get_default_model​
def get_default_model() -> str
Get the default model. Should be overridden by subclasses.
get_additional_headers​
def get_additional_headers(config: Dict[str, Any]) -> Dict[str, str]
Get additional headers for the provider. Can be overridden by subclasses.
initialize​
async def initialize(config: Dict[str, Any]) -> None
Initialize the provider with configuration.
chat​
async def chat(messages: List[Message], **kwargs) -> LLMResponse
Send chat request to the provider.
chat_stream​
async def chat_stream(messages: List[Message],
callbacks: Optional[List[BaseCallbackHandler]] = None,
**kwargs) -> AsyncIterator[LLMResponseChunk]
Send streaming chat request with full callback support.
Yields:
LLMResponseChunk- Structured streaming response chunks
completion​
async def completion(prompt: str, **kwargs) -> LLMResponse
Send completion request to the provider.
chat_with_tools​
async def chat_with_tools(messages: List[Message], tools: List[Dict],
**kwargs) -> LLMResponse
Send chat request with tools to the provider.
get_metadata​
def get_metadata() -> ProviderMetadata
Get provider metadata. Should be overridden by subclasses.
health_check​
async def health_check() -> bool
Check if provider is healthy.
cleanup​
async def cleanup() -> None
Cleanup provider resources.