TypeScript SDK

Buy API access from code with the Proxygate SDK

One ProxygateClient lets your agent browse the marketplace, proxy requests, manage a prepaid USDC balance, stream responses, and verify signed receipts. A long-lived client amortizes TLS and auth across calls, so an agent in a hot loop pays setup cost once. Provider keys never leave the gateway.

Install

The SDK is published on npm as @proxygate/sdk:

bash
npm install @proxygate/sdk

On-chain operations (deposit and withdraw) need optional peer deps:

bash
npm install @solana/web3.js @solana/spl-token

Core usage

Create a client

For a spending agent an API key is the least-privilege choice: a scoped, revocable token tied to your wallet, with no per-request signing. Get one at app.proxygate.ai/wallets, no Solana wallet needed.

typescript
import { ProxygateClient } from '@proxygate/sdk';

const client = await ProxygateClient.create({
  apiKey: 'pg_live_abc123...',
});

Browse and call

Discovery needs no auth. proxy() accepts a service name, a slug, a composite seller-handle/listing-slug, or a UUID, and returns the upstream response. Proxygate injects the provider key server-side and charges your balance.

typescript
const apis = await client.apis({ query: 'weather' });

const res = await client.proxy('weather-api', '/v1/forecast', {
  latitude: 52.37, longitude: 4.90, hourly: 'temperature_2m',
});
const data = await res.json();

Stream responses

Server-sent events are parsed for you with parseSSE, so an agent can consume tokens as they arrive.

typescript
import { parseSSE } from '@proxygate/sdk';

const res = await client.proxy('llm-service', '/v1/completions', {
  prompt: 'Explain quantum computing', stream: true,
});

for await (const event of parseSSE(res)) {
  process.stdout.write(event.data);
}

Verify signed receipts

Every proxy call returns a signed receipt in the x-receipt header. Verify them to prove what was charged.

typescript
const res = await client.proxy('service', '/path', body);
const receipt = JSON.parse(res.headers.get('x-receipt')!);

const results = client.vault.verifyReceipts([receipt]);
// [{ valid: true, receipt }]

SDK, CLI, or MCP server?

  • SDK for a TypeScript app or a long-lived agent in a hot loop, where one client amortizes TLS and auth across calls.
  • CLI for terminal use, scripting, and agent shell calls, where compact, token-efficient output matters.
  • MCP server when your agent runs inside an MCP client (Claude, Claude Code, Cursor) and should buy API calls as native tools.

SDK: frequently asked questions

It is the @proxygate/sdk TypeScript client for buying and selling API capacity through Proxygate. An AI agent uses one ProxygateClient to browse the marketplace, proxy requests, manage a prepaid USDC balance, stream responses, and verify signed receipts, with provider keys kept server-side.

Use the SDK when you build a TypeScript app or a long-lived agent that calls the marketplace in a hot loop: a long-lived client amortizes TLS and auth across calls instead of paying process and connection setup each time. Use the CLI for terminal use, scripting, and agent shell calls where compact, token-efficient output matters. Use the MCP server when your agent runs inside an MCP client (Claude, Claude Code, Cursor) and should buy API calls as native tools. All three reach the same marketplace and the same prepaid balance.

Pass an API key to ProxygateClient.create({ apiKey: "pg_live_..." }) for spending from a pre-funded balance. Use a wallet keypair ({ walletAddress, secretKey }) only when the agent must sign on-chain transactions itself, such as autonomous deposit or withdraw. A delegation token (pg_del_...) fits scoped, time-limited access for a third party.

No. Keys live in the gateway and are injected per request. Your agent authenticates to Proxygate only and never sees or handles the upstream provider credentials. Buyers never see a seller IP, headers, or API keys.

Each proxy call spends from your prepaid USDC balance on Solana and returns a signed receipt with the exact amount charged. There is no subscription and no upstream API key to manage. Vault operations (deposit and withdraw) require a wallet keypair; with an API key, manage funds in the web dashboard.

Ways to connect your agent

Four integration paths reach the same marketplace, one prepaid USDC balance, and the same provider keys kept server-side. Pick the one that fits how your agent runs.