Configure the client
The defaults work for Assay: you pass an API key, and a signer for paid calls. This page lists every option, for when you need to change one.
Options and defaults
Section titled “Options and defaults”Node names first, then Python names.
| Node / Python | Default | What it does |
|---|---|---|
apiKey / api_key |
ASSAY_API_KEY from the environment |
The agent API key. What it may do is set on the key in the web app (see API key permissions). |
mcpUrl / mcp_url |
https://mcp.goassay.ai/ |
The MCP URL for tool calls: a full URL or a path such as /my/research. See Choose a URL. |
apiUrl / api_url |
https://api.goassay.ai/api/v1 |
The API used for receipts and for binding a payment key. |
webUrl / web_url |
https://portal.goassay.ai |
The web app. The SDK builds the payment-key approval link on this origin. |
signer / signer |
None: free calls only | The signer for paid calls. signers takes a list, one per chain namespace. |
limits / limits |
{ maxPerCall: "0.50", maxPerDay: "5" } (max_per_call, max_per_day) |
Local spend limits in dollars, as strings. Checked before every signature, per signing key. |
onPayment / on_payment |
None | Your hook before each voucher is signed. Return false to refuse. |
channels / channels |
A lane file per payment key in your Assay config folder | Where channel payments keep their lane record: { store: fileChannelStore(path) } / FileChannelStore(path). Required on a runtime without a file system. |
networks / networks |
The built-in table | Payment networks you add or replace. See Networks. |
rpcUrls / rpc_urls |
The table’s public RPC URLs | Your own RPC URLs for a network, for example a private RPC. |
fetch / http_client |
The global fetch / a new httpx.Client (httpx.AsyncClient for AsyncAssay) |
The HTTP client. Pass your own for proxies, tracing or tests. |
timeoutMs / timeout |
120,000 ms / 120 s | The time limit for each attempt. In Python, httpx applies it to each of connect, read, write and pool. |
maxRetries / max_retries |
2 | Retries of a failed request: network errors, HTTP 408, 429, 500, 502, 503, 504 and rate limits. Node accepts 0 to 10. |
logger / logger |
Silent | Where the SDK writes what it does. Lines never carry keys, headers, bodies or signatures. |
Retries back off and honour Retry-After. A server that asks to wait longer than 60 seconds is not retried; you get the error.
Example
Section titled “Example”import { Assay, evmSigner } from "@goassay-ai/sdk";import { privateKeyToAccount } from "viem/accounts";
const assay = new Assay({ apiKey: process.env.ASSAY_API_KEY, signer: evmSigner(privateKeyToAccount(process.env.PAYMENT_KEY)), limits: { maxPerCall: "1", maxPerDay: "20" }, onPayment: (p) => BigInt(p.amount.amount) <= 1_000_000n, // at most $1 per call timeoutMs: 30_000, maxRetries: 3, logger: { debug: () => {}, warn: (msg, fields) => console.warn(msg, fields) },});import loggingimport os
from eth_account import Accountfrom goassay import Assay, evm_signer
assay = Assay( api_key=os.environ["ASSAY_API_KEY"], signer=evm_signer(Account.from_key(os.environ["PAYMENT_KEY"])), limits={"max_per_call": "1", "max_per_day": "20"}, on_payment=lambda p: int(p["amount"]["amount"]) <= 1_000_000, # at most $1 per call timeout=30, max_retries=3, logger=logging.getLogger("goassay"),)A Node logger has debug(message, fields) and warn(message, fields). A Python logger has debug and warning, so a standard logging.Logger works.
API key permissions
Section titled “API key permissions”The key is sent only to the MCP and API origins you configured, never to another host, and never along a redirect. URLs must be https (plain http only to localhost).
What the key may do is chosen when a person creates it in the web app:
| Permission | Scope | The SDK needs it for |
|---|---|---|
| Call tools | tools:call |
tools.search, tools.get, tools.call |
| Pay | payments |
Paid calls, and paidCalls.status, bind and waitUntilActive |
| Read activity | activity:read |
receipts.get |
| Report bad results | reports:write |
Reporting a bad result (not in the SDK yet) |
The Agent choice gives the first three. A call that needs a permission the key does not have raises ScopeMissingError with requiredScope (required_scope) naming it. Keys expire: 90 days by default, at most one year. Create a new key before the old one ends; an expired key is refused like a revoked one.
No API key can change the controls over an agent: its limits, its keys or where its alerts go. Only a person signed in to the web app can.
Spend limits and the payment hook
Section titled “Spend limits and the payment hook”With a signer, every voucher is checked against the local limits before it is signed. The defaults are $0.50 per call and $5 per rolling 24 hours, per signing key.
The record is kept in memory, per process. A restart starts again at zero, and worker threads (Node) or several processes each keep their own. The on-chain caps that a person set when approving the key bound it across all processes.
onPayment (on_payment) receives each payment after every check passed and before it is signed:
| Field | Meaning |
|---|---|
tool |
The tool being paid for |
network |
The chain, as a CAIP-2 id |
amount |
The exact amount: { amount, asset, decimals }, atomic units |
provider |
The provider paid, as a CAIP-10 account |
payer |
The account that pays |
idempotencyKey |
The call’s idempotency key |
Use it for your own rules, such as an allow-list of providers. Answer quickly: the voucher’s lifetime, at most 240 seconds, starts before the hook runs. In Python with AsyncAssay, the hook and sign_typed_data may be async.
Networks
Section titled “Networks”The SDK checks every payment against a network table that it holds: per network, the escrow contract, the asset, its decimals and RPC URLs. It never takes these values from the server. So even a compromised API cannot redirect a payment to another contract or token.
The built-in table is pinned in each SDK release and holds Assay’s payment network: USDG on Robinhood Chain. An address change ships as a new release. For Assay, pass nothing.
When to pass networks:
- You run against another deployment of Assay. Pass its network entry together with its
mcpUrl,apiUrlandwebUrl. - You test against your own chain.
Your entries are merged over the built-in table. A new network is added. An entry for a built-in network replaces that entry whole, so the escrow and asset never come from two deployments.
const assay = new Assay({ mcpUrl: "https://<mcp host>/", apiUrl: "https://<api host>/api/v1", webUrl: "https://<web host>", signer, networks: { "eip155:<chainId>": { escrow: "eip155:<chainId>:<escrow address>", asset: "eip155:<chainId>/erc20:<token address>", decimals: 6, rpcUrls: ["https://<rpc 1>", "https://<rpc 2>"], }, },});assay = Assay( mcp_url="https://<mcp host>/", api_url="https://<api host>/api/v1", web_url="https://<web host>", signer=signer, networks={ "eip155:<chainId>": { "escrow": "eip155:<chainId>:<escrow address>", "asset": "eip155:<chainId>/erc20:<token address>", "decimals": 6, "rpcUrls": ["https://<rpc 1>", "https://<rpc 2>"], } },)Addresses are checksummed CAIP-10 and CAIP-19 ids on the network’s own chain. An entry may also give chainId; it must match the id in the key. RPC URLs must be https (plain http only to localhost). When several RPC URLs are given, every one must agree on what it reads.
Use your own RPC
Section titled “Use your own RPC”To keep the built-in values but read the chain through your own provider, pass only rpcUrls (rpc_urls). It replaces that network’s RPC URLs and nothing else:
const assay = new Assay({ signer, rpcUrls: { "eip155:<chainId>": ["https://<your private rpc>"] } });The chain reads go straight to these URLs, without your API key.
A paid call or a bind on a network that is in no table raises PaymentNetworkUnknownError, which names the network.
Errors
Section titled “Errors”| Error | Meaning | Fix |
|---|---|---|
ConfigError (CONFIG_INVALID) “an API key is required” |
No apiKey and no ASSAY_API_KEY. |
Pass the key or set the variable. |
ConfigError “… must be an https URL” |
A URL is not https, or carries a user name or password. |
Use an https URL. |
ConfigError “give one signer per namespace” |
Two signers for the same chain family. | Pass one signer per namespace. |
ConfigError “rpcUrls.… must be a non-empty list of https URLs” |
An RPC list is empty, not https, or for a non-EVM network. |
Fix the list. |
PaymentNetworkUnknownError |
The payment’s network is not in the table. | For Assay, update the SDK. For another deployment, pass its networks entry. |
