8be7f59931
Added handling for ProviderType.OPENROUTER in _create_provider_llm in src/cleveragents/providers/registry.py to resolve ValueError: Unsupported provider type when using OpenRouter via create_llm. Created features/openrouter_provider_registry.feature with 11 scenarios validating OpenRouter provider behavior in ProviderRegistry. Created features/steps/openrouter_provider_registry_steps.py with step definitions for the new feature file. Created docs/reference/providers.md with comprehensive documentation including the OpenRouter configuration guide. ISSUES CLOSED: #8907
88 lines
5.2 KiB
Gherkin
88 lines
5.2 KiB
Gherkin
Feature: OpenRouter provider support in ProviderRegistry
|
|
As a developer using CleverAgents
|
|
I want ProviderRegistry to handle ProviderType.OPENROUTER in create_llm and _create_provider_llm
|
|
So that OpenRouter models are accessible without raising ValueError
|
|
|
|
# Covers the core acceptance criterion:
|
|
# ProviderRegistry.create_llm handles ProviderType.OPENROUTER without raising ValueError
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: create_llm dispatches to OpenRouter via _create_provider_llm
|
|
Given I have an openrouter registry with API key "sk-or-test-key"
|
|
And the openrouter registry LangChain ChatOpenAI client is stubbed
|
|
When I call create_llm on the openrouter registry for provider "openrouter" with model "anthropic/claude-3-haiku"
|
|
Then the openrouter registry ChatOpenAI should be called with model "anthropic/claude-3-haiku"
|
|
And the openrouter registry ChatOpenAI should use base url "https://openrouter.ai/api/v1"
|
|
And the openrouter registry ChatOpenAI should use api key "sk-or-test-key"
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: _create_provider_llm builds ChatOpenAI for OpenRouter with default model
|
|
Given I have an openrouter registry with API key "sk-or-default"
|
|
And the openrouter registry LangChain ChatOpenAI client is stubbed
|
|
When I call _create_provider_llm on the openrouter registry for provider "openrouter" with model None
|
|
Then the openrouter registry ChatOpenAI should be called with model "anthropic/claude-sonnet-4-20250514"
|
|
And the openrouter registry ChatOpenAI should use base url "https://openrouter.ai/api/v1"
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: _create_provider_llm injects organization headers when configured
|
|
Given I have an openrouter registry with API key "sk-or-org" and organization "myapp.example.com"
|
|
And the openrouter registry LangChain ChatOpenAI client is stubbed
|
|
When I call _create_provider_llm on the openrouter registry for provider "openrouter" with model "openai/gpt-4o"
|
|
Then the openrouter registry ChatOpenAI should include header "HTTP-Referer" with value "myapp.example.com"
|
|
And the openrouter registry ChatOpenAI should include header "X-Title" with value "myapp.example.com"
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: _create_provider_llm passes custom default_headers through
|
|
Given I have an openrouter registry with API key "sk-or-headers"
|
|
And the openrouter registry LangChain ChatOpenAI client is stubbed
|
|
When I call _create_provider_llm on the openrouter registry for provider "openrouter" with model "openai/gpt-4o" and default_headers "X-Custom=trace-123"
|
|
Then the openrouter registry ChatOpenAI should include header "X-Custom" with value "trace-123"
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: create_llm raises ValueError when OpenRouter API key is missing
|
|
Given I have an openrouter registry with no API keys
|
|
When I try to call create_llm on the openrouter registry for provider "openrouter"
|
|
Then an openrouter registry ValueError should be raised
|
|
And the openrouter registry error should mention "OPENROUTER_API_KEY"
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: ProviderType.OPENROUTER is in the registry fallback order
|
|
Given I have the openrouter ProviderRegistry class
|
|
When I check the openrouter FALLBACK_ORDER
|
|
Then ProviderType.OPENROUTER should be in the fallback order
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: OpenRouter default model is configured correctly
|
|
Given I have the openrouter ProviderRegistry class
|
|
When I check the openrouter DEFAULT_MODELS
|
|
Then the openrouter default model should be "anthropic/claude-sonnet-4-20250514"
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: OpenRouter capabilities are configured correctly
|
|
Given I have the openrouter ProviderRegistry class
|
|
When I check the openrouter DEFAULT_CAPABILITIES for OPENROUTER
|
|
Then the openrouter provider supports_streaming should be True
|
|
And the openrouter provider supports_tool_calls should be True
|
|
And the openrouter provider supports_vision should be True
|
|
And the openrouter provider max_context_length should be 128000
|
|
And the openrouter provider supports_json_mode should be True
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: OpenRouter provider is discovered when API key is set
|
|
Given I have an openrouter registry with API key "sk-or-discover"
|
|
When I call get_provider_info for OPENROUTER on the openrouter registry
|
|
Then the openrouter provider info should be configured
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: OpenRouter provider is not discovered when API key is missing
|
|
Given I have an openrouter registry with no API keys
|
|
When I call get_provider_info for OPENROUTER on the openrouter registry
|
|
Then the openrouter provider info should not be configured
|
|
|
|
@unit @providers @openrouter @registry
|
|
Scenario: create_llm selects OpenRouter as default when it is the only configured provider
|
|
Given I have an openrouter registry with API key "sk-or-only"
|
|
And the openrouter registry LangChain ChatOpenAI client is stubbed
|
|
When I call create_llm on the openrouter registry without specifying a provider
|
|
Then the openrouter registry ChatOpenAI should be called with model "anthropic/claude-sonnet-4-20250514"
|