langchain-unirate
LangChain integration for the UniRate API — drop-in currency-exchange tooling for LangChain agents and chains.
UniRate provides 593+ fiat, crypto, and commodity exchange rates. Latest rates and conversions are available on the free tier; historical and time-series endpoints require a Pro plan.
Why this package
There's no first-class FX tool in core LangChain — most tutorials show users
hand-rolling one against exchangerate-api.com or AlphaVantage. This package
gives you a typed, tested wrapper plus a ready-to-use BaseTool that an agent
can call directly via tool-calling.
Install
pip install langchain-unirate
Quick start
import os
os.environ["UNIRATE_API_KEY"] = "..." # https://unirateapi.com
from langchain_unirate import UniRateAPIWrapper, UniRateExchangeTool
wrapper = UniRateAPIWrapper()
# Direct API
print(wrapper.convert("USD", "EUR", amount=100)) # 92.5
print(wrapper.get_rate("USD", "GBP")) # 0.79
print(wrapper.get_supported_currencies()[:5])
# As an agent tool
tool = UniRateExchangeTool(api_wrapper=wrapper)
tool.invoke({"from_currency": "USD", "to_currency": "EUR", "amount": 100})
# -> "100 USD = 92.5 EUR (UniRate latest rate)"
Use with an agent
from langchain.chat_models import init_chat_model
from langgraph.prebuilt import create_react_agent
from langchain_unirate import UniRateAPIWrapper, UniRateExchangeTool
tool = UniRateExchangeTool(api_wrapper=UniRateAPIWrapper())
agent = create_react_agent(init_chat_model("openai:gpt-4o-mini"), tools=[tool])
agent.invoke({"messages": [("user", "How many euros is 250 dollars right now?")]})
API
UniRateAPIWrapper
| Method | Returns | Description |
|---|---|---|
get_rate(from_currency="USD", to_currency=None) |
float or dict[str, float] |
Latest rate; if to_currency is omitted, returns every supported target. |
convert(from_currency, to_currency, amount=1.0) |
float |
Convert amount at the latest rate. |
get_supported_currencies() |
list[str] |
All currency codes UniRate can convert between. |
run(from_currency, to_currency, amount=1.0) |
str |
Agent-friendly formatter wrapping convert. |
UniRateExchangeTool
BaseTool with a structured args_schema over (from_currency,
to_currency, amount). Compatible with any LangChain tool-calling pattern:
bind_tools(), create_react_agent, ToolNode, etc.
Configuration
| Constructor arg | Env var | Default |
|---|---|---|
unirate_api_key |
UNIRATE_API_KEY |
— (required) |
base_url |
— | https://api.unirateapi.com |
request_timeout |
— | 30 (seconds) |
Errors map cleanly to ValueError for 401 / 403 / 404 / 429; other
non-2xx responses raise requests.HTTPError.
Related UniRate clients
If you want to call the API directly from a non-Python application, there are official clients in Python, Node.js, Go, Rust, Java, Ruby, PHP, .NET, and Swift, as well as an MCP server for Claude Desktop and other MCP hosts.
License
MIT — see LICENSE.
Metadata
Release files for langchain-unirate 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_unirate-0.1.0.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_unirate-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.6 kB
Release files / langchain_unirate-0.1.0.tar.gz
| Download URL | langchain_unirate-0.1.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54bbbaeb08bedcf9b3286da2e8df32a2292db36c5a7622bef38d6eeef64095a7
|
|
BLAKE2b-256 checksum How to use checksums |
a748ea8f1797d866a21ec06a51511ade75d0894fc820c66df8eb83b9c2e5800e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2026.
Transparency logRelease files / langchain_unirate-0.1.0-py3-none-any.whl
| Download URL | langchain_unirate-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ced8708d9b821f2391449f3d39fcee64015dabaef81c54962dbaad6f9863552
|
|
BLAKE2b-256 checksum How to use checksums |
4c310a812ef2d945973efb8b7dc21bfcb35824a5aec25a7b9b9c73989a0e3a50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 1, 2026.
Transparency log