Add ODEN web search to LangChain

Wire ODEN into LangChain as a tool or retriever in a few lines: give your agent real-time web search that returns a synthesized answer plus citations.

Use case1 min readUpdated 2026-07-30

ODEN is a plain HTTP API, so adding it to LangChain is a few lines — no special integration package required. This guide wires it up as a tool an agent can call, and as a simple retriever.

As a LangChain tool#

Wrap the ODEN call in a @tool and hand it to your agent:

import os, requests
from langchain_core.tools import tool

@tool
def oden_web_search(query: str) -> str:
    """Search the live web and return a synthesized answer with citations."""
    r = requests.post(
        "https://api.oden-api.com/search",
        headers={"Authorization": f"Bearer {os.environ['ODEN_KEY']}"},
        json={"query": query, "include_snippets": True},
        timeout=30,
    )
    r.raise_for_status()
    d = r.json()["results"]
    cites = "\n".join(f"- {c['title']}: {c['url']}" for c in d["citations"])
    return f"{d.get('answer','')}\n\nSources:\n{cites}"

# Give it to any LangChain agent
from langchain.agents import create_react_agent  # or your agent of choice
# tools=[oden_web_search]

As a retriever#

If you want ODEN's citations as LangChain Document objects for a retrieval chain:

import os, requests
from langchain_core.documents import Document
from langchain_core.retrievers import BaseRetriever

class OdenRetriever(BaseRetriever):
    def _get_relevant_documents(self, query: str):
        r = requests.post(
            "https://api.oden-api.com/search",
            headers={"Authorization": f"Bearer {os.environ['ODEN_KEY']}"},
            json={"query": query, "include_snippets": True},
            timeout=30,
        )
        r.raise_for_status()
        return [
            Document(
                page_content=c.get("snippet", c["title"]),
                metadata={"title": c["title"], "url": c["url"], "score": c["score"]},
            )
            for c in r.json()["results"]["citations"]
        ]

retriever = OdenRetriever()
docs = retriever.invoke("who won the 2026 Ballon d'Or")

Notes#

  • The tool returns the synthesized answer plus sources, which is often all an agent needs. The retriever returns per-source Documents for chains that expect documents.
  • Set depth: "basic" in the body for cheaper, faster lookups where you only need which sources are relevant.
  • Keep your key server-side; see authentication.

FAQ#

Does ODEN have a first-party LangChain package?#

Not yet — but it does not need one. ODEN is an HTTP endpoint, so the @tool and BaseRetriever snippets above are the whole integration.

Can I use ODEN with LangGraph agents?#

Yes. The @tool above works anywhere LangChain tools work, including LangGraph nodes and ReAct agents.

How is this different from the LangChain Tavily tool?#

Functionally similar — both give an agent web search. ODEN is EU-hosted and returns citations you attribute directly; see ODEN vs Tavily.

Build it on the free tier
1,000 searches a month, no card required.