Skip to content

TavilyConfig

Base classes

Name Children Inherits
BaseSearchProviderConfig
searchly_config.configs
Base search provider configuration.

⋔ Inheritance diagram

graph TD
  3118389750["configs.TavilyConfig"]
  860522681["configs.BaseSearchProviderConfig"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  860522681 --> 3118389750
  330168112 --> 860522681
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseSearchProviderConfig

Tavily provider configuration.

Uses the Tavily API for web and news search. Supports domain filtering and search depth options.

Source code in src/searchly_config/configs.py
class TavilyConfig(BaseSearchProviderConfig):
    """Tavily provider configuration.

    Uses the Tavily API for web and news search.
    Supports domain filtering and search depth options.
    """

    type: Literal["tavily"] = Field("tavily", init=False)
    """Tavily provider."""

    api_key: SecretStr | None = Field(default=None, title="API Key")
    """Tavily API key. Defaults to TAVILY_API_KEY env var."""

    def is_configured(self) -> bool:
        """Check if Tavily credentials are configured."""
        return self.api_key is not None or bool(os.getenv("TAVILY_API_KEY"))

    def get_provider(self) -> AsyncTavilyClient:
        """Create Tavily provider instance."""
        from searchly.providers.tavily_provider.client import AsyncTavilyClient

        api_key = self.api_key.get_secret_value() if self.api_key else None
        return AsyncTavilyClient(api_key=api_key)

api_key class-attribute instance-attribute

api_key: SecretStr | None = Field(default=None, title='API Key')

Tavily API key. Defaults to TAVILY_API_KEY env var.

type class-attribute instance-attribute

type: Literal['tavily'] = Field('tavily', init=False)

Tavily provider.

get_provider

get_provider() -> AsyncTavilyClient

Create Tavily provider instance.

Source code in src/searchly_config/configs.py
def get_provider(self) -> AsyncTavilyClient:
    """Create Tavily provider instance."""
    from searchly.providers.tavily_provider.client import AsyncTavilyClient

    api_key = self.api_key.get_secret_value() if self.api_key else None
    return AsyncTavilyClient(api_key=api_key)

is_configured

is_configured() -> bool

Check if Tavily credentials are configured.

Source code in src/searchly_config/configs.py
def is_configured(self) -> bool:
    """Check if Tavily credentials are configured."""
    return self.api_key is not None or bool(os.getenv("TAVILY_API_KEY"))

:fa-brands-github: Show source on GitHub