Skip to content

New: deep research, balance and auto-reload tools in the keyless MCP server. Install in one line

Switch from Tavily to ContextFetch in Python with one line

You do not need to rewrite anything. ContextFetch serves a Tavily-compatible API under /tavily, so tavily-python keeps working once you pass api_base_url and a ContextFetch key. Results keep Tavily's shape: title, url, content, raw_content and score, and each search costs one credit, basic or advanced. The one real difference is that include_answer returns a passage quoted from the sources, not text written by a model.

Verified PythonTavily SDK/tavily/search

1. Get an API key

Claim a free key with one POST request. It needs no signup and comes with 2,500 credits, and one free key is issued per network. Export it so the code below can read it.

You can also try the API with no key at all: requests without an Authorization header get 25 free calls per IP address per UTC day.

curl -X POST https://api.contextfetch.dev/v1/keys/free# {"apiKey": "cf_live_...", "credits": 2500}export CONTEXTFETCH_API_KEY="cf_live_..."

2. Change the client

Create the client with your ContextFetch key and api_base_url. Every method you already call now goes to ContextFetch, and nothing else in your code has to change.

tavily-python sends the key as a bearer token, which ContextFetch reads. Raw HTTP requests can also send it as api_key in the JSON body, the way Tavily's own API takes it.

import osfrom tavily import TavilyClient # before# client = TavilyClient(api_key="tvly-...") # afterclient = TavilyClient(    api_key=os.environ["CONTEXTFETCH_API_KEY"],    api_base_url="https://api.contextfetch.dev/tavily",)

3. What stays the same

  • search() takes query, search_depth, max_results, include_domains, exclude_domains, include_raw_content and include_answer.
  • Each result has title, url, content, raw_content and score, and raw_content is the page as clean Markdown when you ask for it.
  • Errors use Tavily's shape, {"detail": {"error": ...}}, and running out of credits is HTTP 432 as on Tavily, so tavily-python raises its usual error.
  • Crawl and map are served at /tavily/crawl and /tavily/map under the same base URL.

4. What is different

search_depth accepts basic and advanced, and both cost one credit. include_answer adds an answer quoted from the most relevant passages, or null when none is relevant enough. ContextFetch runs no generative model, so the answer is never a paraphrase, which also means it never states something the sources do not say.

If your code relied on a fluent written summary, pass the results to your own LLM and have it write one from the quoted material.

5. Check it worked

Run the program below. It makes one search through tavily-python and prints the quoted answer and the top URLs. Every billable response also carries an X-Credits-Remaining header, and GET /v1/balance with your key returns the same number, so you can watch the credit count drop by one per search.

The complete code

Python, runnable as is with CONTEXTFETCH_API_KEY set. Install first: tavily-python. We ran it against the live API; the output below is what it printed.

import os from tavily import TavilyClient client = TavilyClient(    api_key=os.environ["CONTEXTFETCH_API_KEY"],    api_base_url="https://api.contextfetch.dev/tavily",) res = client.search(    "how does HNSW indexing work",    max_results=3,    include_answer=True,) print("answer:", (res.get("answer") or "no passage was relevant enough")[:300])for r in res["results"]:    print(f"{r['score']:.2f}  {r['title']}\n      {r['url']}")print("response_time:", res["response_time"]) 
OutputRecorded
answer: ## How does HNSW work?# HNSW uses proximity graphs (graphs connecting nodes based on distance between them) to approximate nearest-neighbor search. To understand HNSW, we can break it down into 2 parts: - **Hierarchical (H):** The algorithm operates over multiple layers - **Navigable Small W…
1.00  HNSW indexes | Supabase Docs
      https://supabase.com/docs/guides/ai/vector-indexes/hnsw-indexes
1.00  HNSW Explained: How Vector Database Indexes Work
      https://ai-tldr.dev/learn/embeddings-vector-databases/similarity-search-indexing/hnsw-explained
1.00  HNSW Indexing Fundamentals - Qdrant
      https://qdrant.tech/course/essentials/day-2/what-is-hnsw
response_time: 0.002

The same call with curl

The raw HTTP request, and the response it returned (long text fields and lists shortened).

curl -s https://api.contextfetch.dev/tavily/search \  -H "Content-Type: application/json" \  -d '{"api_key": "'"$CONTEXTFETCH_API_KEY"'", "query": "how does HNSW indexing work", "max_results": 3, "include_answer": true}'
ResponseRecorded
{
  "query": "how does HNSW indexing work",
  "images": [],
  "results": [
    {
      "title": "HNSW indexes | Supabase Docs",
      "url": "https://supabase.com/docs/guides/ai/vector-indexes/hnsw-indexes",
      "content": "## How does HNSW work?#\n\nHNSW uses proximity graphs (graphs connecting nodes based on distance between them) to approximate nearest-neighbor search. To understand HNSW, we can break it down into 2 parts:\n\n- **Hierarchical (H):** The algorithm operates over multiple layers\n- **Nav…",
      "raw_content": null,
      "score": 0.9998405225057632
    },
    {
      "title": "HNSW Explained: How Vector Database Indexes Work",
      "url": "https://ai-tldr.dev/learn/embeddings-vector-databases/similarity-search-indexing/hnsw-explained",
      "content": "You zoom out, pick the right continent, then the right country, then the right region, and only then do you zoom in and compare the handful of candidates nearby. That multi-scale drill-down is exactly the idea behind\nHNSW — Hierarchical Navigable Small World\ngraphs.\nHNSW\n— datasc…",
      "raw_content": null,
      "score": 0.9998355138433457
    },
    {
      "title": "HNSW Indexing Fundamentals - Qdrant",
      "url": "https://qdrant.tech/course/essentials/day-2/what-is-hnsw",
      "content": "## Configuring HNSW\n\nWe can fine-tune how our HNSW graph is built to balance search speed, accuracy, memory usage, and indexing time, depending on our use case needs. Qdrant allows you to control how the HNSW index behaves with three key parameters: `m`, `hnsw_ef`, and `ef_constr…",
      "raw_content": null,
      "score": 0.9994862244941404
    }
  ],
  "answer": "## How does HNSW work?# HNSW uses proximity graphs (graphs connecting nodes based on distance between them) to approximate nearest-neighbor search. To understand HNSW, we can break it down into 2 parts: - **Hierarchical (H):** The algorithm operates over multiple layers - **Navig…",
  "response_time": 0.001,
  "request_id": "1953bcd391874172ab45261fc9a95a81"
}

Questions

Do I need a different SDK?

No. tavily-python keeps working with api_base_url set to https://api.contextfetch.dev/tavily and a ContextFetch key. The JavaScript SDK, @tavily/core, works the same way; the setup is in [the docs](/docs).

How much does a search cost?

One credit per search, basic or advanced, which is $1 per 1,000 searches at the base pack rate. [The Tavily comparison](/compare/tavily-alternative) has both list prices side by side with their sources.

Is the answer field written by an LLM?

No. It is a passage quoted from the most relevant sources, or null when nothing is relevant enough. Nothing is paraphrased, so the answer can always be found word for word in a result.

What happens when my credits run out?

Tavily-style routes answer HTTP 432, the status Tavily uses for the same case, so tavily-python raises its usual error with ContextFetch's message. Add credits and retry with the same key.

Run it with your own key

A free key has 2,500 searches and needs no signup. Agents can claim one themselves with the POST below.

curl -X POST https://api.contextfetch.dev/v1/keys/free
Get a free key