Skip to main content

pinelabs-agent-toolkit (Python)

PyPI Python License

Pine Labs payment APIs as tools for AI agent frameworks — OpenAI (Chat Completions + Agents SDK), LangChain, Pydantic AI, CrewAI, and Anthropic Claude. Built on top of pinelabs-python.

74 Pine Labs operations (orders, refunds, payouts, payment links, settlements, subscriptions, …) become typed, schema-validated tools your agent can call.

The npm equivalent is pinelabs-agent-toolkit. Both packages are generated from the same OpenAPI spec and use the same operation names.

Install

pip install pinelabs-agent-toolkit

Then install only the framework adapter(s) you need:

Framework Extra Peer dependency
OpenAI Chat Completions + Agents SDK [openai] openai, openai-agents
LangChain [langchain] langchain-core
Pydantic AI [pydantic-ai] pydantic-ai
CrewAI [crewai] crewai
Anthropic Messages API [anthropic] anthropic
Everything [all] all of the above
pip install 'pinelabs-agent-toolkit[openai,langchain]'

Requires Python ≥ 3.9.

Authenticate

The toolkit takes your Pine Labs OAuth credentials and handles client_credentials token refresh automatically (with a thread-safe cache and a separate bootstrap auth client so the supplier callback can never recurse):

from pinelabs_agent_toolkit.shared import pinelabs_environment

opts = dict(
    environment=pinelabs_environment["UAT"],  # or pinelabs_environment["PROD"]
    client_id="<client-id>",
    client_secret="<client-secret>",
)
Constant Base URL
pinelabs_environment["UAT"] https://pluraluat.v2.pinepg.in
pinelabs_environment["PROD"] https://api.pluralpay.in

Or pass any URL string directly to environment.

Never commit your client_id / client_secret. Load them from environment variables or a secret manager.

Quickstart by framework

OpenAI Chat Completions

import json
import openai
from pinelabs_agent_toolkit.openai import PinelabsAgentToolkit
from pinelabs_agent_toolkit.shared import pinelabs_environment

toolkit = PinelabsAgentToolkit(
    environment=pinelabs_environment["UAT"],
    client_id="<client-id>",
    client_secret="<client-secret>",
)

client = openai.OpenAI()
messages = [{"role": "user", "content": "Create a 500 INR order with reference ord-1."}]

while True:
    resp = client.chat.completions.create(
        model="gpt-4o",
        messages=messages,
        tools=toolkit.get_tools(),
    )
    msg = resp.choices[0].message
    messages.append(msg)
    if not msg.tool_calls:
        break
    for call in msg.tool_calls:
        out = toolkit.handle_tool_call(call.function.name, call.function.arguments)
        messages.append({"role": "tool", "tool_call_id": call.id, "content": out})

OpenAI Agents SDK

from agents import Agent, Runner
from pinelabs_agent_toolkit.openai import PinelabsAgentToolkit

toolkit = PinelabsAgentToolkit(
    environment="https://pluraluat.v2.pinepg.in",
    client_id="<client-id>",
    client_secret="<client-secret>",
)

agent = Agent(
    name="Payments Agent",
    instructions="Help the user manage Pine Labs payments.",
    model="gpt-4o",
    tools=toolkit.get_agent_tools(),
)
result = Runner.run_sync(agent, "Create a 500 INR order for ord-1.")
print(result.final_output)

LangChain

from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from pinelabs_agent_toolkit.langchain import PinelabsAgentToolkit

toolkit = PinelabsAgentToolkit(
    environment="https://pluraluat.v2.pinepg.in",
    client_id="<client-id>",
    client_secret="<client-secret>",
)

llm = ChatOpenAI(model="gpt-4o")
agent = create_react_agent(llm, toolkit.get_tools())
result = agent.invoke({"messages": [("user", "Create a 500 INR order.")]})

Pydantic AI

from pydantic_ai import Agent
from pinelabs_agent_toolkit.pydantic_ai import PinelabsAgentToolkit

toolkit = PinelabsAgentToolkit(
    environment="https://pluraluat.v2.pinepg.in",
    client_id="<client-id>",
    client_secret="<client-secret>",
)

agent = Agent("openai:gpt-4o", tools=toolkit.get_tools())
result = agent.run_sync("Create a 500 INR order with reference ord-1.")
print(result.output)

CrewAI

from crewai import Agent, Crew, Task
from pinelabs_agent_toolkit.crewai import PinelabsAgentToolkit

toolkit = PinelabsAgentToolkit(
    environment="https://pluraluat.v2.pinepg.in",
    client_id="<client-id>",
    client_secret="<client-secret>",
)

payments = Agent(
    role="Payments Specialist",
    goal="Manage Pine Labs payment links and orders.",
    backstory="You are an expert at the Pine Labs payment APIs.",
    tools=toolkit.get_tools(),
)

task = Task(
    description="Create a payment link for 500 INR.",
    expected_output="The payment link URL.",
    agent=payments,
)
Crew(agents=[payments], tasks=[task]).kickoff()

Anthropic Claude (Messages API)

import anthropic
from pinelabs_agent_toolkit.anthropic import PinelabsAgentToolkit

toolkit = PinelabsAgentToolkit(
    environment="https://pluraluat.v2.pinepg.in",
    client_id="<client-id>",
    client_secret="<client-secret>",
)

client = anthropic.Anthropic()
messages = [{"role": "user", "content": "Create a 500 INR order."}]

while True:
    resp = client.messages.create(
        model="claude-3-5-sonnet-latest",
        max_tokens=1024,
        tools=toolkit.get_tools(),
        messages=messages,
    )
    messages.append({"role": "assistant", "content": resp.content})
    tool_uses = [b for b in resp.content if b.type == "tool_use"]
    if not tool_uses:
        break
    results = [
        {
            "type": "tool_result",
            "tool_use_id": b.id,
            "content": toolkit.handle_tool_use(b.name, b.input),
        }
        for b in tool_uses
    ]
    messages.append({"role": "user", "content": results})

Available tools

The toolkit exposes 74 operations spanning every Pine Labs Online product:

  • Authentication — generate access tokens
  • Orders — create, capture, fetch, cancel
  • Refunds — create, fetch
  • Payment Links — create, fetch, cancel, resend, list
  • Card / UPI / NetBanking / Wallet — direct payment methods
  • Apple Pay / International Payments — alternate rails
  • Pay by Points / E-Challans / Affordability Suite / BNPL / Convenience Fee
  • Customers / Tokenization — vault and customer management
  • Payouts — create, update, cancel, list
  • Settlements / Split Settlements — settlement search and reconciliation
  • Subscriptions — plans, subscriptions, presentations, debits, retries

Inspect the full list:

from pinelabs_agent_toolkit import ALL_TOOLS

for td in ALL_TOOLS:
    print(td.name, td.method, td.path)

Each tool's input schema is a strict pydantic model — extra fields raise a validation error so the LLM cannot smuggle arbitrary data into the SDK.

Direct SDK access

The toolkit's Pinelabs client is a drop-in replacement for pinelabs.PinelabsApi with token refresh built in. Use it directly when you want to call the SDK outside an agent loop:

from pinelabs_agent_toolkit.shared import Pinelabs

client = Pinelabs(
    environment="https://pluraluat.v2.pinepg.in",
    client_id="<client-id>",
    client_secret="<client-secret>",
)
client.orders.get_order_by_id(order_id="ord_123")

Environments

Environment Base URL
UAT https://pluraluat.v2.pinepg.in
Production https://api.pluralpay.in

Versioning

Pre-1.0; expect occasional small breaking changes between minor versions. Operation names and signatures stay in lock-step with the npm pinelabs-agent-toolkit.

License

MIT

Metadata

Release files for pinelabs-agent-toolkit 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 pinelabs-agent-toolkit 0.1.2
File Size Uploaded
pinelabs_agent_toolkit-0.1.2.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pinelabs-agent-toolkit 0.1.2
File Interpreter ABI Platform
pinelabs_agent_toolkit-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 26.2 kB

Release files / pinelabs_agent_toolkit-0.1.2.tar.gz

Download URL pinelabs_agent_toolkit-0.1.2.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
df7cf9af850ef49ff584aa97c7da8e88dec7d8a4c32a575b216279c5c06ecee5
BLAKE2b-256 checksum
How to use checksums
dd2a4985ac2c2119b25299fb197947a1f009a1d9a6e55d2ca4e98a1a22bd5ec4
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 21, 2026.

Transparency log

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

Download URL pinelabs_agent_toolkit-0.1.2-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6acaa217beaa6d36d4de72f883fd608f99313d7c6af2552841422b938748909
BLAKE2b-256 checksum
How to use checksums
ed4aa820578506e1ea044f7f3cb8566935b581acf069e524b11c7be5f1db4f21
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 21, 2026.

Transparency log

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