AsyncKagiClient
Base classes¶
| Name | Children | Inherits |
|---|---|---|
| HttpSessionMixin searchly.http Gives a provider one `anyenv.HttpSession`, opened on first use. |
||
| WebSearchProvider searchly.base Protocol for web search providers. |
⋔ Inheritance diagram¶
graph TD
4207035597["client.AsyncKagiClient"]
1226828128["http.HttpSessionMixin"]
2751680898["builtins.object"]
4037333726["base.WebSearchProvider"]
1073422405["typing.Protocol"]
3481597255["typing.Generic"]
1226828128 --> 4207035597
2751680898 --> 1226828128
4037333726 --> 4207035597
1073422405 --> 4037333726
3481597255 --> 1073422405
2751680898 --> 3481597255
🛈 DocStrings¶
Bases: HttpSessionMixin, WebSearchProvider
Async client for Kagi API.
Note: Kagi Search API requires API billing to be set up at https://kagi.com/settings/billing_api
Source code in src/searchly/providers/kagi_provider/client.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
__init__
¶
Initialize Kagi client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
Kagi API key. Defaults to KAGI_API_KEY env var. |
None
|
base_url
|
str
|
Base URL for the API. |
'https://kagi.com/api/v0'
|
Source code in src/searchly/providers/kagi_provider/client.py
summarize
async
¶
summarize(
url: str | None = None,
text: str | None = None,
*,
engine: SummaryEngine = "cecil",
summary_type: SummaryType = "summary",
target_language: str | None = None,
cache: bool = True,
) -> str
Get an AI-generated summary using the Kagi Universal Summarizer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str | None
|
URL to summarize. Exclusive with text. |
None
|
text
|
str | None
|
Text to summarize. Exclusive with url. |
None
|
engine
|
SummaryEngine
|
Summarization engine (cecil, agnes, or muriel). |
'cecil'
|
summary_type
|
SummaryType
|
Type of summary (summary or takeaway). |
'summary'
|
target_language
|
str | None
|
Target language code for translation (e.g., "EN", "DE"). |
None
|
cache
|
bool
|
Whether to allow cached requests/responses. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Generated summary text. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither url nor text is provided, or both are provided. |
Source code in src/searchly/providers/kagi_provider/client.py
web_search
async
¶
web_search(
query: str,
*,
max_results: int = 10,
country: CountryCode | None = None,
language: LanguageCode | None = None,
**kwargs: Any,
) -> WebSearchResponse
Execute a web search query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Search query string. |
required |
max_results
|
int
|
Maximum number of results to return. |
10
|
country
|
CountryCode | None
|
Country code (not used - Kagi inherits account settings). |
None
|
language
|
LanguageCode | None
|
Language code (not used - Kagi inherits account settings). |
None
|
**kwargs
|
Any
|
Additional Kagi-specific options. |
{}
|
Returns:
| Type | Description |
|---|---|
WebSearchResponse
|
Unified web search response. |
Note
Kagi Search API inherits personalization settings from your account, including blocked/promoted sites and regional preferences.