Metadata-Version: 2.4
Name: keirolabs-api
Version: 1.0.0
Summary: Web search for AI agents. One-line search, prompt-ready web context, and web search for any OpenAI or Anthropic client.
Author-email: Keirolabs <team@keirolabs.cloud>
License: MIT
Project-URL: Homepage, https://keirolabs.cloud
Project-URL: Documentation, https://platform.keirolabs.cloud/docs
Project-URL: Source, https://github.com/Keirolabs-API/keirolabs-python
Keywords: web search,search api,ai agents,llm,rag,tavily alternative,openai,anthropic,tool calling
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# keirolabs-api

Web search for AI agents, in one line. No dependencies.

```bash
pip install keirolabs-api
export KEIRO_API_KEY=keiro_...   # free key, 750 credits: https://keirolabs.cloud
```

```python
from keirolabs import search

search("latest llama release")
# [{"title": ..., "url": ..., "snippet": ..., "content": ...}, ...]
```

## Give any LLM web search

Wrap your OpenAI or Anthropic client. The model searches when it needs to, and you get a normal response back.

```python
from openai import OpenAI
from keirolabs import wrap

client = wrap(OpenAI())
client.chat.completions.create(
    model="gpt-4.1",
    messages=[{"role": "user", "content": "What did Nvidia report this quarter?"}],
)
```

```python
from anthropic import Anthropic
client = wrap(Anthropic())
```

Any client with the OpenAI chat completions API should work, such as OpenRouter or Groq (tested on Groq). Your own tools keep working: if the model calls one of them, you get the response back as usual. The model gets up to 3 searches per call (`max_steps`). Sync clients only for now (`OpenAI()`, `Anthropic()`, not the async ones). Streaming calls (`stream=True`) go straight to the model without search.

## Prompt-ready web context

Searches, reads the pages, and returns the passages most likely to answer the question, packed into your token budget.

```python
from keirolabs import context

prompt = f"""Answer using these sources.

{context("who won the 2022 world cup", max_tokens=1500)}

Question: who won the 2022 world cup?"""
```

It runs on Keiro deep search, which scores 96.5% on SimpleQA.

## Switching from Tavily

Change one import. The methods and response keys match Tavily's.

```diff
- from tavily import TavilyClient
+ from keirolabs.compat import TavilyClient
```

`search`, `get_search_context`, `qna_search` and `extract` are supported. Differences: `score` comes from the result's rank, domain filters are applied after the search (so you can get fewer results than you asked for), and `images` is always empty. A Tavily key is ignored: pass a Keiro key or set `KEIRO_API_KEY`.

## Everything else

```python
from keirolabs import search, deep, answer, md, tool, run_tool

search("query", mode="lite")      # cheapest: $0.10 per 1,000 on paid plans
search("query", mode="fast")      # fast live results
search("query", mode="content")   # full page markdown for each result
deep("query", budget=2000)        # ranked evidence + confidence
answer("query")                   # {"answer": ..., "sources": [...]}
md("https://example.com")         # any page as clean text

tool()               # web_search tool for OpenAI-style APIs
tool("anthropic")    # ...or Anthropic, "gemini", "json"
run_tool(args)       # run a model's web_search call, get the tool result text
```

Use a client object for a different key, base URL or timeout:

```python
from keirolabs import Keiro
k = Keiro(api_key="keiro_...", timeout=60)
k.search("query")
```

Errors raise `keirolabs.KeiroError` with `.status` (401 bad key, 402 out of credits, 429 rate limited).

Results are lists of dicts. The full API response (credits used, latency) is on `.raw`.

## Pricing

Free: 750 credits at signup. Lite costs 1 credit on free, and $0.10 per 1,000 searches on paid plans. [Pricing](https://keirolabs.cloud/pricing).

MIT license.
