Files
openrouter-python-sdk-retry…/src/openrouter/components/chatwebsearchshorthand.py
T

83 lines
4.7 KiB
Python

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .searchqualitylevel import SearchQualityLevel
from .websearchconfig import WebSearchConfig, WebSearchConfigTypedDict
from .websearchengineenum import WebSearchEngineEnum
from .websearchuserlocationservertool import (
WebSearchUserLocationServerTool,
WebSearchUserLocationServerToolTypedDict,
)
from openrouter.types import BaseModel, UnrecognizedStr
from openrouter.utils import validate_open_enum
from pydantic.functional_validators import PlainValidator
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
ChatWebSearchShorthandType = Union[
Literal[
"web_search",
"web_search_preview",
"web_search_preview_2025_03_11",
"web_search_2025_08_26",
],
UnrecognizedStr,
]
class ChatWebSearchShorthandTypedDict(TypedDict):
r"""Web search tool using OpenAI Responses API syntax. Automatically converted to openrouter:web_search."""
type: ChatWebSearchShorthandType
allowed_domains: NotRequired[List[str]]
r"""Limit search results to these domains. Supported by Exa, Parallel, and most native providers (Anthropic, OpenAI, xAI). Not supported with Firecrawl or Perplexity."""
engine: NotRequired[WebSearchEngineEnum]
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
excluded_domains: NotRequired[List[str]]
r"""Exclude search results from these domains. Supported by Exa, Parallel, Anthropic, and xAI. Not supported with Firecrawl, OpenAI (silently ignored), or Perplexity."""
max_results: NotRequired[int]
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
max_total_results: NotRequired[int]
r"""Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops."""
parameters: NotRequired[WebSearchConfigTypedDict]
search_context_size: NotRequired[SearchQualityLevel]
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
user_location: NotRequired[WebSearchUserLocationServerToolTypedDict]
r"""Approximate user location for location-biased results."""
class ChatWebSearchShorthand(BaseModel):
r"""Web search tool using OpenAI Responses API syntax. Automatically converted to openrouter:web_search."""
type: Annotated[
ChatWebSearchShorthandType, PlainValidator(validate_open_enum(False))
]
allowed_domains: Optional[List[str]] = None
r"""Limit search results to these domains. Supported by Exa, Parallel, and most native providers (Anthropic, OpenAI, xAI). Not supported with Firecrawl or Perplexity."""
engine: Annotated[
Optional[WebSearchEngineEnum], PlainValidator(validate_open_enum(False))
] = None
r"""Which search engine to use. \"auto\" (default) uses native if the provider supports it, otherwise Exa. \"native\" forces the provider's built-in search. \"exa\" forces the Exa search API. \"firecrawl\" uses Firecrawl (requires BYOK). \"parallel\" uses the Parallel search API."""
excluded_domains: Optional[List[str]] = None
r"""Exclude search results from these domains. Supported by Exa, Parallel, Anthropic, and xAI. Not supported with Firecrawl, OpenAI (silently ignored), or Perplexity."""
max_results: Optional[int] = None
r"""Maximum number of search results to return per search call. Defaults to 5. Applies to Exa, Firecrawl, and Parallel engines; ignored with native provider search."""
max_total_results: Optional[int] = None
r"""Maximum total number of search results across all search calls in a single request. Once this limit is reached, the tool will stop returning new results. Useful for controlling cost and context size in agentic loops."""
parameters: Optional[WebSearchConfig] = None
search_context_size: Annotated[
Optional[SearchQualityLevel], PlainValidator(validate_open_enum(False))
] = None
r"""How much context to retrieve per result. Defaults to medium (15000 chars). Only applies when using the Exa engine; ignored with native provider search."""
user_location: Optional[WebSearchUserLocationServerTool] = None
r"""Approximate user location for location-biased results."""