Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ pip install linkup-sdk[x402]

#### 📝 Search

The `search` function can be used to performs web searches. It supports three different complexity
The `search` function can be used to performs web searches. It supports four different complexity
modes, through the `depth` parameter:

- `"fast"` (**beta**), for sub-second responses to simple, focused queries (must be keyword-based)
- `"standard"`, for single-iteration agentic search that can interpret the query, run parallel
sub-searches, and scrape one URL while remaining fast
- `"deep"`, for slower, more agentic and complex responses, suited to more complex queries (e.g.
"What is the company profile of LangChain accross the last few years, and how does it compare to
its concurrents?")
- `"flash"` is lowest latency: ranked sources and snippets in a few hundred milliseconds, built for
low-latency use cases,
- `"fast"` is higher-quality one-shot retrieval in about a second — the recommended default for
most agentic applications,
- `"standard"` is a single pass of agentic search for queries that span several topics or sources,
- `"deep"` runs several search iterations, optimizing for coverage and multi-hop agentic workflows

The `search` function also supports three output types, through the `output_type` parameter:

Expand All @@ -103,7 +103,7 @@ import linkup
client = linkup.Client() # API key can be read from the environment variable or passed as an argument
search_response: linkup.SourcedAnswer = client.search(
query="What are the 3 major events in the life of Abraham Lincoln?",
depth="deep", # "fast" (beta), "standard", or "deep"
depth="deep", # "flash", "fast", "standard", or "deep"
output_type="sourcedAnswer", # "searchResults" or "sourcedAnswer" or "structured"
structured_output_schema=None, # must be filled if output_type is "structured"
)
Expand Down Expand Up @@ -231,7 +231,7 @@ async def main() -> None:
client = linkup.Client() # API key can be read from the environment variable or passed as an argument
search_response: linkup.SourcedAnswer = await client.async_search(
query="What are the 3 major events in the life of Abraham Lincoln?",
depth="deep", # "fast" (beta), "standard", or "deep"
depth="deep", # "flash", "fast", "standard", or "deep"
output_type="sourcedAnswer", # "searchResults" or "sourcedAnswer" or "structured"
structured_output_schema=None, # must be filled if output_type is "structured"
)
Expand Down
46 changes: 25 additions & 21 deletions src/linkup/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["searchResults"],
structured_output_schema: None = None,
include_images: bool | None = None,
Expand All @@ -126,7 +126,7 @@ def search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["sourcedAnswer"],
structured_output_schema: None = None,
include_images: bool | None = None,
Expand All @@ -145,7 +145,7 @@ def search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["structured"],
structured_output_schema: type[pydantic.BaseModel] | dict[str, Any] | str,
include_images: bool | None = None,
Expand All @@ -164,7 +164,7 @@ def search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["structured"],
structured_output_schema: type[pydantic.BaseModel] | dict[str, Any] | str,
include_images: bool | None = None,
Expand All @@ -183,7 +183,7 @@ def search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["searchResults", "sourcedAnswer", "structured"],
structured_output_schema: type[pydantic.BaseModel] | dict[str, Any] | str | None = None,
include_images: bool | None = None,
Expand All @@ -203,7 +203,7 @@ def search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["searchResults", "sourcedAnswer", "structured"],
structured_output_schema: type[pydantic.BaseModel] | dict[str, Any] | str | None = None,
include_images: bool | None = None,
Expand All @@ -224,10 +224,12 @@ def search(

Args:
query: The search query.
depth: The depth of the search. Can be "fast" (beta), for a sub-second search (query
must be keyword-based), "standard", for a simple, straightforward search (query can
be free text), or "deep" for a more powerful agentic workflow (query can be free
text).
depth: The depth of the search. "flash" is lowest latency: ranked sources and snippets
in a few hundred milliseconds, built for low-latency use cases. "fast" is
higher-quality one-shot retrieval in about a second — the recommended default for
most agentic applications. "standard" is a single pass of agentic search for queries
that span several topics or sources. "deep" runs several search iterations,
optimizing for coverage and multi-hop agentic workflows.
output_type: The type of output which is expected: "searchResults" will output raw
search results, "sourcedAnswer" will output the answer to the query and sources
supporting it, and "structured" will base the output on the format provided in
Expand Down Expand Up @@ -304,7 +306,7 @@ async def async_search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["searchResults"],
structured_output_schema: None = None,
include_images: bool | None = None,
Expand All @@ -323,7 +325,7 @@ async def async_search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["sourcedAnswer"],
structured_output_schema: None = None,
include_images: bool | None = None,
Expand All @@ -342,7 +344,7 @@ async def async_search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["structured"],
structured_output_schema: type[pydantic.BaseModel] | dict[str, Any] | str,
include_images: bool | None = None,
Expand All @@ -361,7 +363,7 @@ async def async_search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["structured"],
structured_output_schema: type[pydantic.BaseModel] | dict[str, Any] | str,
include_images: bool | None = None,
Expand All @@ -380,7 +382,7 @@ async def async_search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["searchResults", "sourcedAnswer", "structured"],
structured_output_schema: type[pydantic.BaseModel] | dict[str, Any] | str | None = None,
include_images: bool | None = None,
Expand All @@ -400,7 +402,7 @@ async def async_search(
self,
query: str,
*,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["searchResults", "sourcedAnswer", "structured"],
structured_output_schema: type[pydantic.BaseModel] | dict[str, Any] | str | None = None,
include_images: bool | None = None,
Expand All @@ -421,10 +423,12 @@ async def async_search(

Args:
query: The search query.
depth: The depth of the search. Can be "fast" (beta), for a sub-second search (query
must be keyword-based), "standard", for a simple, straightforward search (query can
be free text), or "deep" for a more powerful agentic workflow (query can be free
text).
depth: The depth of the search. "flash" is lowest latency: ranked sources and snippets
in a few hundred milliseconds, built for low-latency use cases. "fast" is
higher-quality one-shot retrieval in about a second — the recommended default for
most agentic applications. "standard" is a single pass of agentic search for queries
that span several topics or sources. "deep" runs several search iterations,
optimizing for coverage and multi-hop agentic workflows.
output_type: The type of output which is expected: "searchResults" will output raw
search results, "sourcedAnswer" will output the answer to the query and sources
supporting it, and "structured" will base the output on the format provided in
Expand Down Expand Up @@ -1460,7 +1464,7 @@ def _raise_linkup_error(self, response: httpx.Response) -> None:
def _get_search_params(
self,
query: str,
depth: Literal["fast", "standard", "deep"],
depth: Literal["flash", "fast", "standard", "deep"],
output_type: Literal["searchResults", "sourcedAnswer", "structured"],
structured_output_schema: type[pydantic.BaseModel] | str | dict[str, Any] | None,
include_images: bool | None,
Expand Down
4 changes: 2 additions & 2 deletions src/linkup/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class LinkupSearchTaskInput(_LinkupBaseModel):

Attributes:
query: The search query.
depth: The search depth. "fast" depth is in beta and only works with keyword-based queries.
depth: The search depth.
output_type: The expected search output type.
include_images: Whether image results should be included.
from_date: The start date used to filter search sources, if any.
Expand All @@ -150,7 +150,7 @@ class LinkupSearchTaskInput(_LinkupBaseModel):
"""

query: str = pydantic.Field(validation_alias="q")
depth: Literal["fast", "standard", "deep"]
depth: Literal["flash", "fast", "standard", "deep"]
output_type: Literal["searchResults", "sourcedAnswer", "structured"] = pydantic.Field(
validation_alias="outputType"
)
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Company(pydantic.BaseModel):

test_search_parameters = [
(
{"query": "query", "depth": "standard", "output_type": "searchResults"},
{"q": "query", "depth": "standard", "outputType": "searchResults"},
{"query": "query", "depth": "flash", "output_type": "searchResults"},
{"q": "query", "depth": "flash", "outputType": "searchResults"},
b"""
{
"results": [
Expand Down Expand Up @@ -1276,7 +1276,7 @@ def test_create_tasks(mocker: MockerFixture, client: linkup.Client) -> None:
[
linkup.SearchTaskInput(
query="query",
depth="deep",
depth="flash",
output_type="structured",
structured_output_schema=Company,
),
Expand All @@ -1299,7 +1299,7 @@ def test_create_tasks(mocker: MockerFixture, client: linkup.Client) -> None:
"type": "search",
"input": {
"q": "query",
"depth": "deep",
"depth": "flash",
"outputType": "structured",
"structuredOutputSchema": json.dumps(Company.model_json_schema()),
},
Expand Down
Loading