Skip to main content

langchain-latam-synth

PyPI version Python License: MIT

LangChain tool for generating realistic, privacy-safe synthetic financial data for Latin American fintech applications.

langchain-latam-synth exposes the LatAm Synth generator as a ready-to-use LangChain tool for AI agents, testing, QA, demos, machine-learning experiments, data pipelines, and agent evaluation without using personally identifiable information.

The package provides one tool:

generate_latam_financial_data

It generates linked synthetic:

  • financial users
  • savings goals
  • deposit and withdrawal transactions

The underlying generator is LatAm Synth, executed through its hosted Apify Actor.


Installation

pip install -U langchain-latam-synth

Requires Python 3.10+.


Authentication

The tool runs the hosted LatAm Synth Actor on Apify, so you need an Apify API token.

Set it as the APIFY_TOKEN environment variable:

macOS / Linux

export APIFY_TOKEN="your-apify-token"

Windows PowerShell

$env:APIFY_TOKEN = "your-apify-token"

Do not hard-code API tokens in source code or commit them to GitHub.


Quick start

from langchain_latam_synth import generate_latam_financial_data

result = generate_latam_financial_data.invoke(
    {
        "users": 25,
        "seed": 42,
        "countries": ["Colombia", "Mexico"],
    }
)

print(result["meta"])
print(len(result["users"]))
print(len(result["goals"]))
print(len(result["transactions"]))

The tool returns a dictionary with:

run_id
generator
meta
users
goals
transactions

meta carries the row counts, the seed, the requested countries, the Apify run id and the generation timestamp:

{
    "users": 25,
    "goals": 31,
    "transactions": 87,
    "seed": 42,
    "countries": ["Colombia", "Mexico"],
    "generated_at": "2026-08-25T10:00:00Z",
    "run_id": "abc123",
    "transport": "apify-actor",
    "synthetic": True,
    "contains_pii": False,
}

This is the same meta block returned by the LatAm Synth local MCP server and by the Actor's OUTPUT_DATA record, so an agent can consume any of the three integration paths interchangeably.


Tool arguments

Argument Type Default Description
users int 25 Number of synthetic users to generate. Accepted range: 1–200.
seed int 42 Random seed for reproducible datasets.
countries list[str] | None None Optional list of Latin American countries to include.

Example:

result = generate_latam_financial_data.invoke(
    {
        "users": 100,
        "seed": 7,
        "countries": ["Colombia"],
    }
)

Use inside a LangChain agent

Because generate_latam_financial_data is a LangChain tool, it can be passed directly to an agent.

from langchain.agents import create_agent
from langchain_latam_synth import generate_latam_financial_data

agent = create_agent(
    model="claude-sonnet-4-6",
    tools=[generate_latam_financial_data],
)

response = agent.invoke(
    {
        "messages": [
            {
                "role": "user",
                "content": (
                    "Generate a small synthetic Colombian fintech dataset "
                    "for testing a savings recommendation agent."
                ),
            }
        ]
    }
)

A model with tool-calling support can decide when to invoke LatAm Synth based on the user's request.


Example agent use cases

langchain-latam-synth is useful when an agent needs realistic financial test data without accessing production customer data.

Examples include:

  • generating QA fixtures for fintech applications
  • evaluating financial AI agents
  • testing savings or recommendation assistants
  • creating synthetic datasets for demos and POCs
  • bootstrapping ML experiments
  • validating data pipelines
  • generating reproducible test datasets for regression tests

Privacy

LatAm Synth is designed to generate synthetic financial behavior for development and experimentation.

The generator produces synthetic users, savings goals, and transactions rather than returning production customer records. It is intended for scenarios where realistic financial structure is useful but personally identifiable information should not be used.

For details about the source generator and its statistical calibration, see the LatAm Synth repository.


How it works

The LangChain integration is intentionally small:

LangChain agent
      |
      | tool call
      v
generate_latam_financial_data
      |
      | Apify API
      v
LatAm Synth Actor
      |
      v
synthetic users + goals + transactions

The package starts the hosted Actor, waits for the run to finish, reads the generated JSON output, and returns the structured data to LangChain.


Related MCP access

LatAm Synth is also available independently to MCP-compatible AI clients through the hosted Apify MCP Server.

MCP endpoint:

https://mcp.apify.com?tools=active_yardstick/latam-synth

Official MCP Registry server name:

io.github.jmendozapuche/latam-fintech-synthetic-data

The MCP server and this LangChain package are two different integration paths to the same underlying LatAm Synth generator:

LangChain agents -> langchain-latam-synth -> Apify Actor
MCP clients      -> Apify MCP Server      -> Apify Actor
MCP clients      -> latam-synth-mcp (local, stdio, no Apify)

All three return the same tables with the same referential integrity and the same meta block, because all three are thin adapters over the same generator.

See the LatAm Synth repository for MCP configuration details.


Development

git clone https://github.com/jmendozapuche/langchain-latam-synth.git
cd langchain-latam-synth
pip install -e .
pip install pytest
pytest -v

The test suite validates the tool name and schema, input limits, required Apify authentication, and the returned contract against a simulated Apify API — no network calls and no Actor runs are billed while testing.


Links


License

MIT

Metadata

Release files for langchain-latam-synth 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-latam-synth 0.1.2
File Size Uploaded
langchain_latam_synth-0.1.2.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-latam-synth 0.1.2
File Interpreter ABI Platform
langchain_latam_synth-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.4 kB

Release files / langchain_latam_synth-0.1.2.tar.gz

Download URL langchain_latam_synth-0.1.2.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2d3255462accf23defcf72bb3fd0de8be0111fa7b0fd6db410f933b4dc7291ed
BLAKE2b-256 checksum
How to use checksums
c06f324833c80556eb5a167491ff6f02f4adcecb039551fd56f0954e1b97148b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / langchain_latam_synth-0.1.2-py3-none-any.whl

Download URL langchain_latam_synth-0.1.2-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebacb30b70e050b4ac59f84f24f1a3ce1c7abad2f70d7fb25efaba14393ab32e
BLAKE2b-256 checksum
How to use checksums
442d982cb9cae451556412b8bae601bd94d6763fa6eefd8eaeda8a1774ac8e20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page