LangChain.js tools

@orizn/langchain

Two ready-made tools for a LangChain.js agent. Drop them in and the model stops inventing entry rules.

What was executed to write this page

@orizn/langchain 0.2.0 installed from npm into an empty project, then both tools were invoked directly under Node 25 — with a key and without one. The output blocks are their real return values.

Before you start

  • Node.js 18 or later.
  • A LangChain.js setup. The tools only need @langchain/core and zod; the agent example additionally needs @langchain/openai and @langchain/langgraph plus an OpenAI key.
  • An Orizn API key. Free tier: 50 requests/month, no credit card — get one at visa.orizn.app/visa-api. It is 5 requests until you confirm your email, so click the link in the confirmation mail.
Get a free API key

Walkthrough

1. Install

Terminal
npm install @orizn/langchain @langchain/core zod
export ORIZN_API_KEY=orizn_visa_...

2. Invoke the tools directly first

Before wiring an LLM in, prove the tools work on their own. This costs no model tokens and isolates a key problem from a prompt problem.

tools.mjs
import { OriznQuickVisaCheckTool, OriznVisaCheckTool } from "@orizn/langchain";

const quick = new OriznQuickVisaCheckTool();   // reads ORIZN_API_KEY
console.log("QUICK:", await quick.invoke({ passport: "FRA", destination: "JPN" }));

const full = new OriznVisaCheckTool();
const out = await full.invoke({ passport: "FRA", destination: "JPN", lang: "fr" });
console.log("FULL:", String(out).slice(0, 400));
Output · node tools.mjs — real stdout, trimmed
QUICK: {"passport":"FRA","destination":"JPN","requirement":"visa_free",
        "visa_free_days":90,"visa_required":false,"last_verified":"2026-05-08", ...}

FULL: {"data":{"passport":"FRA","destination":"JPN","requirement":"visa_free",
       "visa_free_days":90,"visa_required":false,
       "description":"Les ressortissants français bénéficient d'une exemption de visa
        de 90 jours pour le Japon. Un accord bilatéral de longue date permet les
        séjours touristiques sans visa.",
       "documents_required":["Passeport français en cours de validité",
                             "Billet de retour ou de continuation", ...

3. Wire them into an agent

agent.mjs
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { OriznQuickVisaCheckTool, OriznVisaCheckTool } from "@orizn/langchain";

const agent = createReactAgent({
  llm: new ChatOpenAI({ model: "gpt-4o-mini" }),
  tools: [new OriznQuickVisaCheckTool(), new OriznVisaCheckTool()],
});

const res = await agent.invoke({
  messages: [{ role: "user", content: "I hold a Brazilian passport — do I need a visa for Japan?" }],
});
console.log(res.messages.at(-1)?.content);

4. Which tool for which question

  • OriznQuickVisaCheckTool — “do I need a visa, and for how long?” One line back. Cheapest.
  • OriznVisaCheckTool — documents, fees, processing time, application steps, tips. Takes a lang argument.

Give the agent both. Left with only the detailed one it burns context on every trivial yes/no; left with only the quick one it cannot answer “what do I need to bring”.

When it goes wrong

Every failure the integration can hand you, with the message it actually prints.

No ORIZN_API_KEY set

Error, thrown on invoke
Orizn Visa API: no API key configured. Get a free one (50 requests/month, no credit card) at https://visa.orizn.app/visa-api, then set ORIZN_API_KEY.

The error names the URL on purpose, so an agent can relay what it needs instead of failing opaquely. A three-line hint also goes to stderr at construction.

Key unknown or deactivated

403 from the API
The tool surfaces the API's own message, which carries the dashboard URL.

Re-copy the key.

Alpha-2 country code from the model

400 from the API
{"error":"Required: ?passport=FRA&destination=JPN (ISO3 codes)"}

Common failure mode: models like emitting FR. The message is explicit enough that a ReAct agent usually self-corrects on the next step.

Monthly quota spent

429 from the API
The message carries the upgrade URL.

Agents fan out fast — 50 requests/month is a handful of conversations. Watch the quota before shipping.

The no-key row is verbatim stdout from a run with the environment variable unset. The others are the API's own responses, reproduced with curl but not through the tool wrapper. The 429 was not reproduced.

End to end: the agent that does not guess

The failure this fixes is specific. Ask any model “can a Brazilian passport holder enter Vietnam without a visa” and it will answer confidently from training data that may be two years old — visa policy moves faster than that.

  • With the tools attached, the agent calls quick_visa_check and gets e_visa back, with a last_verified date it can quote.
  • Follow up with “what do I need for the e-visa” and it calls the detailed tool: documents, steps, fee, processing days.
  • Ask in French and it passes lang=fr, so the documents come back in French rather than being translated by the model.

Same pattern in Python: rather than the langchain-orizn package, wrap the official orizn SDK in a @tool — the version currently on PyPI is 0.1.1 and predates the API requiring a key on /check. The Python tutorial has a working ten-line version.

Source & reference

Other integrations

50 requests a month, no credit card

All 15 languages included on the free plan. Hit a wall with this tutorial? Mail [email protected] — a tutorial that does not work is a bug.