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]

LangGraph state graph agent integration#

For complex autonomous multi-step reasoning agents built on LangGraph, wire ODEN into a specialized research node:

from typing import TypedDict, Annotated, List
from langgraph.graph import StateGraph, END

class AgentState(TypedDict):
    messages: List[str]
    research_summary: str

def research_node(state: AgentState):
    last_query = state["messages"][-1]
    search_data = oden_web_search.invoke(last_query)
    return {"research_summary": search_data}

builder = StateGraph(AgentState)
builder.add_node("researcher", research_node)
builder.set_entry_point("researcher")
builder.add_edge("researcher", END)
graph = builder.compile()

High-concurrency async tool implementation#

When serving multiple concurrent agent requests in production FastAPI or asynchronous workers, implement the asynchronous tool handler:

import httpx
from langchain_core.tools import tool

@tool
async def oden_async_search(query: str) -> str:
    """Asynchronous live web retrieval tool for high-concurrency LangChain applications."""
    async with httpx.AsyncClient(timeout=25.0) as client:
        resp = await client.post(
            "https://api.oden-api.com/search",
            headers={"Authorization": f"Bearer {os.environ['ODEN_KEY']}"},
            json={"query": query, "include_snippets": True}
        )
        resp.raise_for_status()
        data = resp.json()["results"]
        return data.get("answer", "")

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.