coinbase / coinbase/agentkit

Action Provider Proposal: OpenRelay — x402-paid LLM inference + on-chain tools on Base

Open
#1,466 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.3k
Forks
815
Avg merge
13h 31m
Merged PRs (30d)
2

Description

## Proposal

Add an ActionProvider that exposes **OpenRelay** to any AgentKit agent — an OpenAI-compatible LLM gateway and utility toolbox where every call is auto-paid in USDC on Base via x402, using the agent's own `EvmWalletProvider`. **No API key, no signup, no upfront funding.**

Package already published: **[`@openrelay999/agentkit-provider`](https://www.npmjs.com/package/@openrelay999/agentkit-provider)** · v0.1.0, MIT
Source: **https://github.com/GitVova999/openrelay-agentkit-provider**
Backend (open, indexed on x402scan): https://x402scan.com/server/2ed5dcb1-e941-411f-927f-bf221729a62e

## Actions surfaced

| Action | Price / call | What it does |
|---|---|---|
| `openrelay_prompt` | $0.001-0.05 (capped) | OpenAI-compatible chat completion — DeepSeek V4 Flash (400k ctx), Kimi K2.6, MiniMax M2.7 |
| `openrelay_wallet_balance` | $0.001 | USDC / native balance on Base or Solana |
| `openrelay_base_gas` | $0.001 | Base gas price w/ slow/std/fast tiers |
| `openrelay_tx_status` | $0.001 | tx confirmation Base or Solana |
| `openrelay_polymarket_markets` | $0.003 | active Polymarket markets by volume |

## Why this fits AgentKit

- **Wallet-native auth.** The agent already has an `EvmWalletProvider` — we just call `wallet.signTypedData(...)` to sign an EIP-3009 `TransferWithAuthorization`. No new credential class needed.
- **Base-first.** `supportsNetwork()` returns true only for chainId `8453`.
- **No lock-in.** OpenRelay is a plain OpenAI-compatible relay; agents can switch providers by changing the URL.
- **Adds a working example of the x402 handshake pattern** — several recent issues (#1437, #1463, #1434, #1391) want x402-adjacent capabilities; this is the first end-to-end implementation ready to merge.

## Security posture (already implemented in v0.1.0)

- Trusted-host allow-list (only `openrelay.hggfffdfy687.workers.dev` by default)
- `resource.url` in x402 challenge must match request URL — rejects challenge substitution
- Amount = positive integer µUSDC regex; addresses validated by regex
- `accepts[]` size cap = 20 entries
- Hard USD cap per request (default `$0.05`)
- Single retry after signing — no unbounded loop

## Proposed layout in the AgentKit monorepo

```
typescript/agentkit/src/action-providers/openrelay/
├── openrelayActionProvider.ts
├── schemas.ts
├── x402.ts
├── index.ts
├── openrelayActionProvider.test.ts
└── README.md
```

I have the code ready to submit as a PR once you're OK with the scope. Happy to accommodate any structural preferences (e.g., splitting the LLM prompt action into its own provider vs bundling with tools).

## Optional follow-up (post-merge)

- Solana branch — needs a `SvmWalletProvider` analog, blocked on AgentKit's Solana surface
- Streaming (SSE) for chat completions
- Python parallel implementation

Thanks for looking. Ping if a maintainer wants a video walkthrough of the x402 handshake / plugin behavior.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.