Getting started
MCP server for agents
Connect Claude, Cursor or any MCP client to api14 over Streamable HTTP and let agents list models, chat, generate images, check the balance and top up with USDC.
api14 runs a remote Model Context Protocol server. An agent connects with your API key and gets tools for every model in the catalog, plus a tool to pay for more balance with USDC from its own wallet.
https://api14.com/api/mcp
The transport is Streamable HTTP and the server is stateless. Authenticate with the same key you use for the REST API:
Authorization: Bearer sk-api14-...
Tool calls go through the same gateway as /api/v1: the key's model allowlist, rate limits, daily USD limit and your balance all apply, and every paid call shows up in your usage history with its cost.
No account yet
An agent can open its own account. Connect without an Authorization header and the server offers two tools: list_models and create_account.
- Call
create_accountwithamount_usd(by default $5 to $5,000). The result holds the x402 payment requirements. - Your x402 MCP client pays that amount in USDC and calls the tool again with the payment (see Paying with USDC).
- Once the payment settles on chain, the account is created with the paid amount (plus any top-up bonus) as its balance and the result contains
api_key. It is shown once: store it. - Reconnect with
Authorization: Bearer <api_key>to get the full tool set.
No email or password is needed and no sign-up bonus is given: the payment is the account's proof.
Dashboard access
To let a human see the account (usage, balance, keys, card top-ups), call link_email with their address. A verification link is sent there; opening it confirms the email and signs in to the dashboard. To sign in later, use Forgot password on the login page to set a password. Linking a new address replaces the old one and notifies the old address. Up to 3 links per hour.
link_email is for accounts without a password. An account created on the website changes its email in Settings instead.
Connect a client
Most clients take a URL and a header. For example, in a JSON config file (Claude Desktop, Cursor and others use this shape):
{
"mcpServers": {
"api14": {
"url": "https://api14.com/api/mcp",
"headers": { "Authorization": "Bearer sk-api14-..." }
}
}
}
With Claude Code:
claude mcp add --transport http api14 https://api14.com/api/mcp \
--header "Authorization: Bearer sk-api14-..."
Use a dedicated key with a daily USD limit for agents, so a runaway loop cannot spend more than you planned. See Rate limits.
Tools
| Tool | Arguments | What it does |
|---|---|---|
list_models | category?, search? | Lists up to 100 models with id, category and price. Narrow with search. |
create_account | amount_usd | Without an API key only: opens an account paid in USDC and returns its API key. |
get_balance | none | Returns the USD balance, total paid and total used. |
chat | model, messages, max_tokens? | Runs a chat completion and returns the text and its cost. |
generate_image | model, prompt, size? | Generates an image and returns it as image content (or a URL). |
link_email | email | Links an email so a human can sign in to the dashboard. |
topup_balance | amount_usd | Adds balance by paying USDC over x402. See below. |
Errors come back as tool results with isError: true and the gateway's error code first, for example insufficient_balance: ... or model_not_allowed: ..., so an agent can branch on the code. See Errors.
Paying with USDC
When the balance runs low, the agent calls topup_balance with an amount. The first call returns the x402 payment requirements (network, USDC contract, amount, recipient) in structuredContent. An x402 MCP client signs a USDC transfer authorization with its wallet and calls the tool again with the payment in _meta["x402/payment"]. The balance is credited only after the transfer has settled on chain, and the receipt comes back in _meta["x402/payment-response"].
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'
import { wrapMCPClientWithPaymentFromConfig } from '@x402/mcp'
import { ExactEvmScheme } from '@x402/evm/exact/client'
import { privateKeyToAccount } from 'viem/accounts'
const mcp = new Client({ name: 'my-agent', version: '1.0.0' })
await mcp.connect(
new StreamableHTTPClientTransport(new URL('https://api14.com/api/mcp'), {
requestInit: { headers: { Authorization: 'Bearer sk-api14-...' } },
}),
)
const wallet = privateKeyToAccount(process.env.AGENT_WALLET_KEY as `0x${string}`)
const client = wrapMCPClientWithPaymentFromConfig(mcp, {
schemes: [{ network: 'eip155:8453', client: new ExactEvmScheme(wallet) }],
// The x402 client refuses payments above $1 by default. Raise the cap to your top-up size.
spendControls: { maxAmountPerPayment: '$50' },
})
await client.callTool('topup_balance', { amount_usd: 25 })
Without an API key, the same client opens an account instead: connect without the header and call client.callTool('create_account', { amount_usd: 25 }).
Amounts, networks and limits are the same as for the HTTP endpoint, see USDC top-ups.