feat(search): add APISerpent (apiserpent.com) as search provider - #29448
Conversation
APISerpent is a multi-engine SERP API covering Google, Bing, Yahoo, and DuckDuckGo. It exposes two endpoints, quick search (/api/search/quick) and deep search (/api/search), both billed at $0.60 per 1k searches. Both are surfaced under a single `apiserpent` provider; callers select the deep endpoint with `deep=True`, following the way Linkup and Tavily ship two search setups under one provider. All supported parameters and their defaults live in a single APISerpentSearchParams dataclass, which enforces the documented bounds (num 1 to 100, pages 1 to 10) and types the constrained string params (engine, safe, freshness, format) as Literals.
Greptile SummaryThis PR adds APISerpent as a new search provider under
Confidence Score: 5/5Safe to merge; the provider integration is additive, all previous findings are resolved, and no existing behaviour is modified. All changed paths are new files (new provider, new tests, JSON pricing entries) with no modifications to shared infrastructure beyond the two one-line registration additions. The null-results and api_base routing regressions flagged in the prior round are fixed and covered by regression tests. No auth, routing, or data-loss concerns exist in the changed code. No files require special attention; the only note is test hygiene in the integration tests around environment-variable cleanup.
|
| Filename | Overview |
|---|---|
| litellm/llms/apiserpent/search/transformation.py | New APISerpent provider implementing BaseSearchConfig; correctly handles null results, GET-based URL construction with idempotent endswith guard, and quick/deep routing. |
| litellm/llms/apiserpent/search/defaults.py | Frozen dataclass defining APISerpent request params with bounds enforcement; NUM_MIN_DEEP floor is intentionally delegated to the transform layer (documented in the class docstring). |
| tests/test_litellm/llms/apiserpent/test_apiserpent_search.py | Comprehensive mock-only test suite covering defaults, URL routing, response parsing, and null-results regression; integration tests set os.environ without cleanup which can persist across tests in the same session. |
| litellm/utils.py | Registers APISerpentSearchConfig in get_provider_search_config(); lazy import keeps it consistent with other search providers. |
| model_prices_and_context_window.json | Adds apiserpent/search and apiserpent/deep_search entries at $0.0006/query; matches provider documentation and is consistent with other search entries. |
| litellm/types/utils.py | Adds APISERPENT to the SearchProviders enum; straightforward one-line addition. |
| tests/code_coverage_tests/enforce_llms_folder_style.py | Adds apiserpent to SEARCH_PROVIDERS allowlist; required for the coverage job to recognize the new provider folder. |
Reviews (2): Last reviewed commit: "address review: null results, idempotent..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
Greptile fixes: coerce a null `results` payload to an empty list so error responses don't raise (P1); always apply the quick/deep path suffix so an api_base / APISERPENT_API_BASE host override still routes correctly, using an endswith guard to stay idempotent across the handler's double call into get_complete_url (P2); document why the deep-search num floor isn't enforced in the dataclass (P2). Move the test suite from tests/search_tests to tests/test_litellm/llms/apiserpent so the unit-test/coverage job (`pytest tests/test_litellm`) actually exercises it; the package now reports 100% patch coverage. Adds regression tests for the null-results and api_base-routing fixes.
5bbee99 to
8bbc2b7
Compare
|
@greptileai please re-review. The latest commit addresses the earlier findings: a null |
The check_provider_folders_documented CI gate requires every litellm/llms folder to have an entry; add apiserpent with a search endpoint, mirroring the serper and tavily entries.
|
@krrish-berri-2 this adds APISerpent as a search provider, following the same pattern as the recent You.com addition. Greptile is at 5/5, all CI checks are green, and the provider-folder documentation gate passes. Docs are filed separately in BerriAI/litellm-docs#277 per the convention. Ready for review when you have a chance, thanks. |
Documents the APISerpent search provider being registered upstream in BerriAI/litellm#29448. APISerpent is a multi-engine SERP API (Google, Bing, Yahoo, DuckDuckGo) with quick and deep search endpoints, selected via the `deep` flag. Adds the provider page plus the three index.md provider lists and the sidebar entry.
Relevant issues
N/A; new feature addition
Pre-Submission checklist
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewType
🆕 New Feature
Changes
Adds APISerpent as a new provider for the LiteLLM Search API. APISerpent is a multi-engine SERP API covering Google, Bing, Yahoo, and DuckDuckGo via GET requests.
It exposes two endpoints, quick search (
/api/search/quick) and deep search (/api/search), both billed at $0.60 per 1k searches. Both are surfaced under a singleapiserpentprovider; callers select the deep endpoint by passingdeep=True, which follows the way Linkup and Tavily already ship two search setups under one provider. Unified params (max_results,country,search_domain_filter) are supported alongside APISerpent-specific ones (engine,language,freshness,safe,pages,format,pixel_position).All supported parameters and their defaults live in a single
APISerpentSearchParamsdataclass, which is the source of truth for the request schema. It enforces the documented bounds (num1 to 100,pages1 to 10, raising on out-of-range values) and types the constrained string params (engine,safe,freshness,format) asLiterals.New files:
litellm/llms/apiserpent/search/transformation.py;APISerpentSearchConfigwith quick/deep routing and response parsinglitellm/llms/apiserpent/search/defaults.py;APISerpentSearchParamsdataclass with defaults, bounds enforcement, and Literal typestests/search_tests/test_apiserpent_search.pyModified files:
litellm/types/utils.py; addAPISERPENTtoSearchProviderslitellm/utils.py; register inget_provider_search_config()model_prices_and_context_window.jsonand the backup copy; addapiserpent/searchandapiserpent/deep_searchcost entries ($0.0006/query)tests/code_coverage_tests/enforce_llms_folder_style.py; addapiserpenttoSEARCH_PROVIDERSScreenshots / Proof of Fix
Live calls against the real APISerpent API (
APISERPENT_API_KEYset), one per endpoint: