# SDK

A TypeScript SDK is in active development. Once released, integrating Klink into your agent will look like this:

```ts
import { KlinkClient } from "@klink/sdk";

const klink = new KlinkClient({ apiKey: process.env.AGENT_API_KEY });

// Direct USDC transfer to a pre-approved recipient
await klink.spend.transfer({
  recipient: "<base58-pubkey>",
  amount: 500_000, // USDC base units (1 USDC = 1_000_000)
});

// Pay an x402 service inline
const result = await klink.spend.service({
  slug: "openai-chatgpt",
  path: "/v1/chat/completions",
  body: { model: "gpt-4", messages: [/* ... */] },
  maxAmount: 100_000,
});

// Read your vault position
const pos = await klink.yield.position();
```

## What you'll get

* Typed bindings for every Klink API endpoint
* Built-in retry + backoff for cold-start `502`s and transient RPC errors
* Pluggable `fetch` for testing (no global mocks needed)
* Helpful error subclasses (`KlinkApiError` with `status` and `KlinkDenyReason`) so your agent code can branch on the cause cleanly

## Status

🛠️ **Coming soon.** Until the SDK ships, you can integrate against the HTTP API directly, see the [Quickstart](/klink-docs/getting-started/quickstart.md) and the [Agent Skill](/klink-docs/developer-resources/skill.md) page for ready-to-paste `curl` examples covering every endpoint.

## Get notified

Watch the public repo (link will appear here once the SDK is open-sourced) or check the [Roadmap](/klink-docs/reference/roadmap.md) page for milestones.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://klink-4.gitbook.io/klink-docs/developer-resources/sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
