llm_openrouter#

class baf.nlp.llm.llm_openrouter.LLMOpenRouter(agent, name, parameters, num_previous_messages=1, global_context=None)[source]#

Bases: LLMOpenAICompatible

LLM wrapper for models accessed via OpenRouter’s OpenAI-compatible API.

OpenRouter provides a unified gateway to hundreds of models from many providers. Requires nlp.openrouter.api_key to be set in the agent config file. The default base URL points to https://openrouter.ai/api/v1.

Example model names (use the OpenRouter provider/model format): "anthropic/claude-opus-4", "google/gemini-2.5-pro", "openai/gpt-4o", "meta-llama/llama-3.3-70b-instruct".

API_KEY_PROPERTY = <baf.core.property.Property object>#

Property constant used to look up the API key from the agent config file.

DEFAULT_BASE_URL = 'https://openrouter.ai/api/v1'#

Provider base URL. None → use the OpenAI SDK default (api.openai.com).

_abc_impl = <_abc._abc_data object>#