Documentation

SDKs

Drop OpenUSDC into your stack. Every SDK shares the same wallet, policy, fetch, and receipt model — pick the language, the rest is the same.

Node / TypeScript

npm i @openusdc/sdk

import { openusdc } from "@openusdc/sdk";

const wallet = openusdc.wallet({
  chain: "base",
  policy: "./policy.json",
  signer: { kind: "coinbase-mpc", id: process.env.MPC_ID! },
});

const data = await wallet.fetch(
  "https://api.partner.io/v1/score",
  { method: "POST", body: { input: "..." }, maxSpend: "0.05 USDC" }
);

console.log(data.$receipt);

The Node SDK ships with a typed fetch wrapper, a streaming-aware client for token-by-token billing, an OpenTelemetry instrumentation that emits openusdc.payment spans, and an Express middleware for hosting protected routes.

Python

pip install openusdc

from openusdc import Wallet, Policy

wallet = Wallet(
    chain="base",
    policy=Policy.from_file("policy.json"),
    signer={"kind": "turnkey", "id": "wallet_42"},
)

res = wallet.post(
    "https://api.partner.io/v1/score",
    json={"input": "..."},
    max_spend="0.05 USDC",
)

print(res.receipt)

The Python SDK is fully type-annotated, integrates with the httpx async client, and ships with an OpenTelemetry exporter that mirrors the Node spans for cross-language tracing.

Go

go get github.com/openusdc/openusdc-go

import "github.com/openusdc/openusdc-go"

w := openusdc.NewWallet(openusdc.WalletConfig{
    Chain:  openusdc.Base,
    Policy: openusdc.PolicyFromFile("policy.json"),
    Signer: openusdc.Turnkey("wallet_42"),
})

res, err := w.Post(ctx,
    "https://api.partner.io/v1/score",
    map[string]any{"input": "..."},
    openusdc.MaxSpend("0.05 USDC"),
)
if err != nil { return err }

fmt.Println(res.Receipt)

Rust

# Cargo.toml
openusdc = "0.6"

let wallet = openusdc::Wallet::builder()
    .chain(Chain::Base)
    .policy_file("policy.json")
    .signer(Signer::Turnkey("wallet_42"))
    .build()?;

let res = wallet
    .post("https://api.partner.io/v1/score")
    .json(&body)
    .max_spend("0.05 USDC")
    .send()
    .await?;

Deno

import { openusdc } from "https://deno.land/x/openusdc/mod.ts";

const wallet = openusdc.wallet({
  chain: "base",
  signer: { kind: "raw-pk", env: "AGENT_PK" },
});

const r = await wallet.fetch("https://api.partner.io/v1/score", { ... });

Cloudflare Workers

The Workers SDK is a sub-export of the Node package that drops the Node-only signer kinds and substitutes the Workers KV / D1 storage for the local cache. Bundle size is < 14 KB gzipped.

import { openusdc } from "@openusdc/sdk/workers";

export default {
  async fetch(req, env) {
    const wallet = openusdc.wallet({
      chain: "base",
      signer: { kind: "coinbase-mpc", env: "MPC_ID" },
    });
    return wallet.fetchProxy(req, env);
  },
};

Versioning

SDKs follow semver. The wire format is versioned independently — an SDK at version 0.6 will speak to a gateway at version 0.4 as long as the wire version is the same (currently x402/0.5). We aim to give 6 months of overlap on any breaking wire change.