# Welcome to Linkex Docs (/en/docs) **Linkex** (linkex.ai) is a unified AI API gateway and a settlement layer for AI agents. It puts 40+ AI providers — OpenAI, Anthropic Claude, Google Gemini, and more — behind a single OpenAI-compatible endpoint with per-token, pay-as-you-go billing. What makes Linkex different: **your agent can pay for itself.** Accounts can be funded with stablecoins over the [x402 protocol](/en/docs/for-agents/x402-protocol) on BNB Smart Chain, Base, and Solana — no credit card, no human in the loop. Register, create a key, and make your first API call. Crypto wallet, autonomous x402, or Alipay+ — pick your rail. Agent credentials, spend caps, and self-funding via x402. Binance Agentic Wallet, Claude Code, Cursor, and any OpenAI SDK. ## At a glance [#at-a-glance] | | | | ---------------- | -------------------------------------------------------------------------------------- | | API base URL | `https://linkex.ai/v1` (OpenAI-compatible) | | Also accepts | Anthropic Messages (`/v1/messages`), Gemini (`/v1beta/...`) | | Billing | Per-token, pay-as-you-go — [live prices](https://linkex.ai/pricing) | | Funding rails | Crypto wallet (Base / BNB Chain / Solana), x402 autonomous top-up, Alipay+ e-wallets | | Agent support | Scoped agent keys with spend caps, revocable at any time | | Machine-readable | [/llms.txt](https://docs.linkex.ai/llms.txt) — every page is available as raw Markdown | # API Reference (/en/docs/api-reference) The reference is generated from the gateway's OpenAPI specs and covers two groups: ## AI relay endpoints [#ai-relay-endpoints] The inference surface under `/v1` (and Gemini's `/v1beta`): chat, responses, embeddings, images, audio, video, rerank, moderations, realtime. Authenticate with `Authorization: Bearer sk-...`. ## Platform endpoints [#platform-endpoints] User-facing account operations: x402 top-up orders and payment, agent credential management, balance, top-up info/status, and Alipay+ payments. Reference pages are English-only; the guides in every other section are bilingual. Each reference page includes an interactive schema viewer and request samples. # Pay with Alipay+ (/en/docs/buying-credits/alipay-plus) Linkex accepts **Alipay+** payments — a cross-border network covering major Asian e-wallets. Payments are denominated in **USD** and credited to your balance on confirmation. ## Supported wallets [#supported-wallets] Availability depends on merchant enablement in your region; the console orders wallets by your last-used choice, then by detected region. | Wallet | Region | | ----------------------------------- | ---------------- | | Alipay (`ALIPAY_CN`) | Chinese mainland | | AlipayHK (`ALIPAY_HK`) | Hong Kong | | GCash (`GCASH`) | Philippines | | BPI (`BPI_PH`) | Philippines | | BillEase (`BILLEASE_PH`) | Philippines | | DANA (`DANA`) | Indonesia | | Kredivo (`KREDIVO_ID`) | Indonesia | | TNG eWallet (`TNG_MY`) | Malaysia | | Boost (`BOOST_MY`) | Malaysia | | KakaoPay (`KAKAOPAY`) | South Korea | | TrueMoney (`TRUEMONEY`) | Thailand | | Rabbit LINE Pay (`RABBIT_LINE_PAY`) | Thailand | | MPay (`MPAY_MO`) | Macau | | Tinaba (`TINABA_IT`) | Italy | ## How to pay [#how-to-pay] ### Choose Alipay+ and an amount [#choose-alipay-and-an-amount] Go to **Console → Wallet**, enter the amount (minimum $1), and pick **Alipay+** — or a specific wallet from the *Local E-Wallets* group. ### Complete the hosted checkout [#complete-the-hosted-checkout] You are redirected to the Alipay+ hosted checkout (or shown a QR code). Confirm the payment in your wallet app. The order is valid for **10 minutes** — Alipay+ QR codes expire after that. If it lapses, start a new top-up; nothing is charged for an unpaid order. ### Return and confirm [#return-and-confirm] After paying you are redirected back to the console. The credit lands once the payment webhook confirms — usually within seconds. Check **Wallet → billing history** if you don't see it immediately. ## Notes [#notes] * Payments are in **USD**; your wallet app performs any currency conversion at its own rate. * The amount charged may reflect your account's top-up group ratio and any promotional discount — the exact figure is previewed before checkout. * If you paid but the balance didn't update within a few minutes, contact [support](/en/docs/resources/support) with your order number (visible in billing history, format `SWP-...`). # Supported chains & tokens (/en/docs/buying-credits/chains-and-tokens) All crypto funding (console wallet dialog and autonomous x402) settles through these assets. Amounts are always **1:1 with USD**. ## Mainnet assets [#mainnet-assets] | Network | CAIP-2 id | Token | Settlement method | Decimals | Contract / mint | | --------------- | ----------------------------------------- | ------------------- | ------------------ | -------- | ---------------------------------------------- | | Base | `eip155:8453` | USDC | EIP-3009 (gasless) | 6 | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | | BNB Smart Chain | `eip155:56` | $U (United Stables) | EIP-3009 (gasless) | 18 | `0xce24439f2d9c6a2289f741120fe202248b666666` | | BNB Smart Chain | `eip155:56` | USDT | Permit2 | 18 | `0x55d398326f99059fF775485246999027B3197955` | | BNB Smart Chain | `eip155:56` | USDC | Permit2 | 18 | `0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d` | | Solana | `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` | USDC | SVM transfer | 6 | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | The live list (including the recipient address per network) is served by `GET /api/user/topup/x402/config` — always prefer it over this table in code. ## Settlement methods explained [#settlement-methods-explained] * **EIP-3009** (`transferWithAuthorization`) — you sign a typed-data authorization; the facilitator submits it on-chain and pays the gas. Zero transactions from your wallet. * **Permit2** — used for BNB Chain USDT/USDC, which lack EIP-3009. Your first payment per token includes a one-time `approve` to the Permit2 contract (gas required once); afterwards every payment is signature-only. * **SVM transfer** — a Solana USDC transfer carrying the order's invoice memo; the fee payer is sponsored by the facilitator. ## Settlement infrastructure [#settlement-infrastructure] Payments are verified and settled by x402 **facilitators**: | Network | Facilitator | | --------------- | ----------------------------- | | BNB Smart Chain | Binance **B402** | | Base | Coinbase CDP (PayAI fallback) | | Solana | Coinbase CDP (PayAI fallback) | This is internal detail — as a payer you only ever talk to the Linkex order and pay endpoints. # Pay with a crypto wallet (/en/docs/buying-credits/crypto-wallet) Fund your account directly from your own wallet. You sign **one authorization** — no deposit address to copy, no manual transfer to reconcile. Under the hood this uses the [x402 protocol](/en/docs/for-agents/x402-protocol); the recipient verifies and credits on-chain settlement automatically. **What you need:** a browser wallet (MetaMask or any EIP-6963 wallet for EVM; a Wallet Standard wallet like Phantom for Solana) holding a supported stablecoin — see [chains & tokens](/en/docs/buying-credits/chains-and-tokens). ## Open the crypto payment dialog [#open-the-crypto-payment-dialog] Go to **Console → Wallet**, enter an amount, and choose the **x402 (Base/BSC)** payment method. The *Pay with Crypto* dialog opens. Pick a network row — **Base**, **BNB Chain**, or **Solana** — and, where a network offers several tokens, a token pill. Each option shows a settlement note: * **USDC on Base / $U on BNB Chain** — gasless; you sign one authorization, no on-chain transaction from your side. * **USDT / USDC on BNB Chain** — your *first* payment with that token includes a one-time Permit2 approval transaction (requires a little BNB for gas, once). * **USDC on Solana** — a transfer signed by your wallet; the network fee payer is sponsored by the facilitator. ## Connect your wallet [#connect-your-wallet] Click **Continue** and pick a wallet. The dialog reads your live token balance on the selected chain and blocks progress if it's insufficient — top up the wallet first if needed. ## Review and sign [#review-and-sign] The final screen shows the amount, the token/network/protocol, and your paying address. It also shows the **recipient (payTo) address** with a copy button. **Verify the recipient.** The dialog displays the expected `payTo` address (on Solana, also the USDC token account). The client refuses to pay if the order's recipient doesn't match the platform configuration — but it never hurts to eyeball it. Click **Pay** and approve the signature in your wallet: * EVM: the wallet switches to the payment chain automatically, then requests an EIP-712 signature (plus the one-time approval transaction for USDT/USDC on BNB Chain). * Solana: the wallet signs a USDC transfer with an order memo. ## Confirmation [#confirmation] On success you'll see a toast and the balance updates immediately (`settled`). Occasionally settlement confirms slightly later (`credit_pending`) — the credit lands within a couple of minutes; a background reconciler retries and verifies on-chain state. Your order also appears under **Wallet → billing history**. ## Notes & troubleshooting [#notes--troubleshooting] * **Amount bounds:** $1 minimum, $1,000 maximum per order (defaults; the dialog enforces live values). * **1:1 crediting:** paying $10 in USDC credits exactly $10 — no rail fee. * **Order expiry:** an unpaid order expires after 10 minutes; just start again. * **Pending cap:** at most 3 pending x402 orders per account; pay or let them expire. * **Signature rejected / wallet closed mid-flow:** nothing was spent — an unsigned order simply expires. * **"Insufficient balance" but I have funds:** you may hold the token on a different chain than the selected network. Check the network row you picked. # Payment methods overview (/en/docs/buying-credits) All top-ups land in the same USD-denominated credit balance. Pick the rail that fits how you pay: | | [Crypto wallet](/en/docs/buying-credits/crypto-wallet) | [x402 (autonomous)](/en/docs/buying-credits/x402-topup) | [Alipay+](/en/docs/buying-credits/alipay-plus) | | -------------- | ------------------------------------------------------ | ------------------------------------------------------- | -------------------------------------------------------- | | Who it's for | Anyone with a crypto wallet | AI agents funding themselves | Users of Asian e-wallets | | You pay with | USDC / USDT / $U on Base, BNB Chain, or Solana | Same tokens, signed programmatically | Alipay, AlipayHK, GCash, DANA, TNG, KakaoPay, TrueMoney… | | Amount | $1 – $1,000 per order | $1 – $1,000 per order | From $1 (USD-denominated) | | Rate | 1 USD paid = 1 USD credit (no rail fee) | Same | 1:1 in USD, before any group ratio/discount | | Human present? | Yes — you sign in your wallet | No — the agent signs | Yes — hosted checkout | | Order validity | 10 minutes | 10 minutes | 10 minutes | | Speed | Credits on on-chain confirmation (typically seconds) | Same | Credits on webhook confirmation | Exact per-order bounds are served live by `GET /api/user/topup/info` (all rails) and `GET /api/user/topup/x402/config` (x402); the values above are platform defaults. ## Which one should I use? [#which-one-should-i-use] * **You have MetaMask / a Solana wallet and stablecoins** → [Crypto wallet](/en/docs/buying-credits/crypto-wallet). Three clicks in the console, gasless on Base (USDC) and BNB Chain ($U). * **You are building an agent that must never stop** → [x402 autonomous top-up](/en/docs/buying-credits/x402-topup) with an [agent credential](/en/docs/for-agents/agent-credentials) and spend caps. * **You prefer local e-wallets / no crypto** → [Alipay+](/en/docs/buying-credits/alipay-plus) supports 14 wallets across Asia, denominated in USD. ## Checking your balance and orders [#checking-your-balance-and-orders] * Balance: shown in the console header and on the Wallet page, or `GET /api/user/self/balance` (returns `quota_usd`). * Orders: **Console → Wallet → billing history**, or poll `GET /api/user/topup/order/{trade_no}`. Order states: `pending → settling → success | failed | expired`. # x402 autonomous top-up (/en/docs/buying-credits/x402-topup) x402 top-up is the programmatic version of the [crypto wallet flow](/en/docs/buying-credits/crypto-wallet): the same order machinery, but driven by code instead of a browser dialog. This page is the human-readable overview; the full protocol reference (endpoints, challenge schema, error codes) lives in [x402 protocol](/en/docs/for-agents/x402-protocol). ## The four calls [#the-four-calls] 1. **Create an order** — authenticated with your API key (or an [agent key](/en/docs/for-agents/agent-credentials)): ```bash curl -X POST https://linkex.ai/api/user/topup/x402/orders \ -H "Authorization: Bearer sk-YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"amount_usd": 5}' ``` The response contains an x402 v2 **challenge**: network, token contract, atomic amount, recipient (`payTo`), and a 10-minute expiry. 2. **Sign it** with any x402 v2-capable wallet: * [Binance Agentic Wallet](/en/docs/integrations/binance-agentic-wallet) (`baw x402-payment preview` / `sign`) * `@linkexai/agent-sdk` (`buildX402PaymentPayload` for EVM, `buildSvmPaymentPayload` for Solana) * Coinbase x402 tooling, or your own EIP-3009 / Permit2 / Solana signer 3. **Submit** the signed payload — note this endpoint is **public**; the signature itself is the authorization: ```bash curl -X POST https://linkex.ai/api/x402/pay/ORDER_ID \ -H "Content-Type: application/json" \ -d @signed-payload.json ``` 4. **Confirm** — the response reports `settled` (credited now) or `credit_pending` (credited after on-chain confirmation). Verify with: ```bash curl https://linkex.ai/api/user/self/balance \ -H "Authorization: Bearer sk-YOUR_KEY" ``` ## Why use an agent key for this [#why-use-an-agent-key-for-this] Creating orders with a plain account key works, but an **agent key** adds guardrails: the order is bound to the agent wallet, and per-call / daily / total **spend caps** are enforced at settlement time (`SPEND_CAP_EXCEEDED`). That means a runaway agent cannot drain the funding wallet beyond the caps you set. See [Agent credentials](/en/docs/for-agents/agent-credentials). ## Keeping an agent funded [#keeping-an-agent-funded] * **Semi-automatic (browser):** the console's [Keep Funded](/en/docs/for-agents/keep-funded) page polls the balance and prompts you to sign a top-up when it drops below a threshold. * **Fully autonomous:** run the funding loop in your own runtime with `@linkexai/agent-sdk`, or the `linkex/funder` Docker image — poll `GET /api/user/self/balance`, create an order when low, sign, submit. # Agent credentials (/en/docs/for-agents/agent-credentials) An **agent** on Linkex is a bring-your-own wallet paired with a dedicated API key. Linkex verifies you own the wallet once, then stores **only the public address** — no private key ever touches the platform. The wallet is the agent's identity; the key is what it authenticates with. ## Create an agent [#create-an-agent] ### Open the Agents page [#open-the-agents-page] Go to **Console → Agents**. Agent management is gated behind a wallet-verified session — if prompted, connect and verify your account wallet first (SIWE). Click **Create Agent**. ### Name it and pick a chain [#name-it-and-pick-a-chain] Give the agent a label (up to 128 characters) and choose the credential chain: * **EVM** — one address works across Base and BNB Chain * **Solana** ### Prove wallet ownership [#prove-wallet-ownership] Connect the wallet that will *be* the agent and sign a one-time ownership proof: * **EVM** — an EIP-712 typed-data signature. Domain name `linkexai-agent-ownership`, primary type `AgentOwnership { agent, nonce, issuedAt }`. * **Solana** — an ed25519 signature over the canonical message `linkexai-agent-ownership\nagent:
\nnonce: \nissuedAt: `. The nonce is single-use and the timestamp must be fresh (within 5 minutes), so a captured signature can't be replayed. ### Save the API key — shown only once [#save-the-api-key--shown-only-once] On success Linkex mints the agent's API key (`sk-...`) and displays it **one time only**. Download the backup JSON or copy the key now; it cannot be retrieved later (revoke and re-register if lost). Programmatic creation uses the same two endpoints — `POST /api/user/self/agents/siwe/nonce` then `POST /api/user/self/agents`; see the [API reference](/en/docs/api-reference). ## Spend caps [#spend-caps] Each agent carries three optional USD caps, enforced **when the agent funds itself over x402** (settlement fails with `SPEND_CAP_EXCEEDED` beyond them): | Cap | Meaning | | ------------------ | ------------------------- | | `per_call_cap_usd` | Max USD per single top-up | | `daily_cap_usd` | Max USD per calendar day | | `total_cap_usd` | Lifetime max USD | `0` means uncapped. Current spend counters (`spent_today_usd`, `spent_total_usd`) are visible on the Agents page and in `GET /api/user/self/agents`. ## Using the agent key [#using-the-agent-key] The agent key works everywhere a normal key does: ```bash # inference curl https://linkex.ai/v1/chat/completions -H "Authorization: Bearer sk-AGENT_KEY" ... # check its balance (shared account balance) curl https://linkex.ai/api/user/self/balance -H "Authorization: Bearer sk-AGENT_KEY" # create a top-up order — automatically bound to this agent, caps enforced curl -X POST https://linkex.ai/api/user/topup/x402/orders \ -H "Authorization: Bearer sk-AGENT_KEY" -d '{"amount_usd": 5}' ``` When authenticated with an agent key, x402 orders are **force-bound** to that agent's wallet — an `agent_wallet_id` in the request body is ignored. This is what makes the caps tamper-proof from the agent's side. ## Revoke [#revoke] Click **Revoke** on the Agents page (or `DELETE /api/user/self/agents/{agent_id}`). In a single transaction the API key is disabled and the wallet unlinked. Revocation is idempotent, and the same wallet can be re-registered later — it gets a fresh key. ## Limits [#limits] * Up to **50 agents** per account. * EVM addresses are stored lowercased; Solana addresses are case-sensitive base58. * One wallet address can be registered as an agent only once at a time (re-registerable after revocation). # Running agents on Linkex (/en/docs/for-agents) Linkex treats an AI agent as a first-class account actor: it gets its own credential, spends within caps you define, funds itself with stablecoins, and can be cut off instantly. ## The lifecycle [#the-lifecycle] 1. **[Agent credentials](/en/docs/for-agents/agent-credentials)** — register an external wallet (EVM or Solana) to your account with a one-time ownership signature. Linkex mints a dedicated API key; the private key never leaves your side. 2. **Inference** — the agent key is a normal API key: point any OpenAI/Anthropic/Gemini-format client at Linkex. 3. **Self-funding** — the agent creates [x402 top-up orders](/en/docs/for-agents/x402-protocol), signs them with its wallet, and submits. Spend caps (per-call / daily / total) are enforced at settlement. 4. **Supervision** — watch usage in the console; [Keep Funded](/en/docs/for-agents/keep-funded) offers a semi-automatic balance guard. Revoke the credential at any time. ## In this section [#in-this-section] Create, scope, and revoke agent keys — with screenshots. The browser-based balance guard, and unattended alternatives. Endpoints, challenge schema, signing methods, error codes. llms.txt and raw-Markdown access for your agent to read. # Keep Funded (balance guard) (/en/docs/for-agents/keep-funded) **Keep Funded** (Console → Agents → Keep Funded) is a **browser-based, semi-automatic balance guard**: it polls an agent's balance and, when it drops below your threshold, prompts you to approve a top-up that **you sign in your connected wallet**. Funds move only on your confirmation, and the tab must stay open. Keep Funded is *not* hands-off automation — it's a supervised safety net. For unattended funding see [Fully autonomous options](#fully-autonomous-options) below. ## Setup [#setup] ### Load the agent credential [#load-the-agent-credential] Paste the agent API key, or upload the backup `.json` you downloaded at creation. Credentials stay in your browser — they are never uploaded. ### Configure the guard [#configure-the-guard] | Setting | Default | Range / notes | | ------------------------------------------- | ---------------- | ------------------------------------------------------- | | Threshold — top up when balance falls below | $1 | any USD amount | | Top-up amount per trigger | $1 | clamped to the x402 order bounds ($1–$1,000 default) | | Check interval | 60 s | 5 s – 86,400 s | | Funding network | platform default | any advertised x402 network (Base / BNB Chain / Solana) | ### Connect the funding wallet [#connect-the-funding-wallet] Connect any wallet holding the stablecoin on the chosen network — it does **not** have to be the agent's own wallet; a mismatch is allowed and the credit still lands on the agent's account. ### Start watching [#start-watching] The guard polls `GET /api/user/self/balance`. When the balance dips below the threshold it builds an x402 order and asks your wallet to sign. Approve, and the credit lands; decline, and it just asks again next cycle. ## Security notes [#security-notes] * Funding requests are sent with the agent key only (browser credentials omitted), so the agent-token spend-cap path applies — caps you set on the agent hold even here. * The recipient address of every order is verified against the platform configuration before signing. ## Fully autonomous options [#fully-autonomous-options] When you need funding with no human present: * **`@linkexai/agent-sdk`** — build the loop into your agent: poll balance → create order → `buildX402PaymentPayload` / `buildSvmPaymentPayload` → submit. The SDK surfaces `SPEND_CAP_EXCEEDED` and friends as typed errors. * **`linkex/funder` Docker image** — a standalone watcher you run on your own machine with a funding key; same loop, zero code. * **[Binance Agentic Wallet](/en/docs/integrations/binance-agentic-wallet)** — if your agent runs in an OpenClaw/skills environment, `baw x402-payment` signs Linkex challenges directly. # Machine-readable docs (/en/docs/for-agents/machine-readable) Agents shouldn't have to scrape HTML. Both Linkex properties expose machine-readable entry points: ## docs.linkex.ai (this site) [#docslinkexai-this-site] | Resource | What it is | | -------------------------------------------------------- | ----------------------------------------------------------------------------- | | [`/llms.txt`](https://docs.linkex.ai/llms.txt) | Index of every docs page with a one-line description and its raw-Markdown URL | | [`/llms-full.txt`](https://docs.linkex.ai/llms-full.txt) | The full English corpus in one plain-text file | | `/llms.mdx/docs/{lang}/{...slug}/content.md` | Raw Markdown of any single page | Every page also has a **Copy Markdown** button and *open in ChatGPT / Claude* actions in its header. ## linkex.ai (main site) [#linkexai-main-site] [`https://linkex.ai/llms.txt`](https://linkex.ai/llms.txt) summarizes the product for AI consumers: the OpenAI-compatible endpoint, pricing page, x402 quickstart, and links here. ## Suggested agent bootstrap [#suggested-agent-bootstrap] ```text 1. GET https://docs.linkex.ai/llms.txt → find the relevant page 2. GET → read it as Markdown 3. GET https://linkex.ai/api/user/topup/x402/config → live payment parameters ``` # x402 protocol reference (/en/docs/for-agents/x402-protocol) Linkex implements **x402 version 2** with the `exact` scheme for account top-ups. This page is the complete integration reference. For the guided version see [x402 autonomous top-up](/en/docs/buying-credits/x402-topup). ## Sequence [#sequence] ## Endpoints [#endpoints] | Method & path | Auth | Purpose | | ---------------------------------------------- | -------------------------------- | -------------------------------------------------------- | | `GET /api/user/topup/x402/config` | API key or session | Discover enabled networks, tokens, bounds, recipients | | `GET /api/user/topup/x402/orders` | API key or session | List pending orders with fresh challenges | | `POST /api/user/topup/x402/orders` | API key or session | Create an order (rate-limited) | | `POST /api/user/topup/x402/orders/{id}/resume` | API key or session | Re-issue the challenge for a pending order | | `POST /api/x402/pay/{orderId}` | **none** — signature is the auth | Submit the signed payment (rate-limited, 1 MiB max body) | Interactive schemas: [API reference → x402](/en/docs/api-reference). ## Order creation [#order-creation] ```json POST /api/user/topup/x402/orders { "amount_usd": 5, "network": "eip155:8453", "symbol": "USDC" } ``` * `amount_usd` — within `[min_topup_usd, max_topup_usd]` from config (defaults $1–$1,000). * `network` / `symbol` — optional; omitted → platform default network and its default token (BNB Chain defaults to $U, everything else USDC). * **Agent binding:** with an agent key, the order is force-bound to that agent's wallet; `agent_wallet_id` in the body is ignored. * At most **3 pending orders** per account (`X402_PENDING_CAP`). * Orders expire **600 seconds** after creation. ## The challenge [#the-challenge] ```json { "x402Version": 2, "accepts": [{ "scheme": "exact", "network": "eip155:8453", "amount": "5000000", "maxAmountRequired": "5000000", "resource": "https://linkex.ai/api/x402/pay/12345", "payTo": "0xRECIPIENT", "maxTimeoutSeconds": 300, "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "extra": { "name": "USD Coin", "version": "2" } }] } ``` `extra` depends on the settlement method: | Method | Networks | `extra` | | -------- | ----------------- | ---------------------------------------------------------------------------------------------------------- | | EIP-3009 | Base USDC, BNB $U | `{ "name", "version" }` — the token's EIP-712 domain (BNB additionally `"assetTransferMethod": "eip3009"`) | | Permit2 | BNB USDT / USDC | `{ "assetTransferMethod": "permit2-exact", "spenderAddress" }` | | SVM | Solana USDC | `{ "feePayer", "memo" }` — sponsored fee payer and the invoice memo to include | Always verify `payTo` (and on Solana the derived token account) against `GET /api/user/topup/x402/config` before signing. Linkex clients refuse mismatched recipients; yours should too. ## Submitting payment [#submitting-payment] `POST /api/x402/pay/{orderId}` with the signed payload. The gateway validates that `scheme`, `network`, `asset`, `payTo`, and the **exact** `amount` match the order, then settles. Responses are always HTTP 200 with an envelope: ```json { "success": true, "data": { "order_id": 12345, "status": "settled", "balance_added": 5, "new_balance": 12.34 } } ``` `status` values: `settled` (credited) or `credit_pending` (on-chain confirmation still in flight; a background reconciler — every 2 minutes, with on-chain verification — completes the credit). ## Spend caps (agent orders) [#spend-caps-agent-orders] For agent-bound orders the caps are charged atomically at the pending→settling transition: * `per_call_cap_usd` — per-order * `daily_cap_usd` — resets by calendar day * `total_cap_usd` — lifetime Exceeding any returns `SPEND_CAP_EXCEEDED`; failed or reset orders reverse the charge. ## Error codes [#error-codes] Returned as `success: false` with an uppercase `message`: | Code | Meaning | | --------------------------------------------- | --------------------------------------------------------------- | | `X402_DISABLED` | Rail disabled on this deployment | | `X402_INVALID_AMOUNT` | Outside min/max bounds | | `X402_UNSUPPORTED_ASSET` | Unknown network/token combination | | `X402_PENDING_CAP` | Already 3 pending orders | | `ORDER_NOT_FOUND` / `INVALID_ORDER_ID` | Bad order reference | | `ORDER_EXPIRED` | Past the 600 s window — create a new order | | `PAYLOAD_MISMATCH` | Signed payload doesn't match the order | | `SETTLING_IN_PROGRESS` | Duplicate submit while settling | | `ORDER_NOT_PENDING` / `ORDER_ALREADY_SETTLED` | Wrong state | | `SPEND_CAP_EXCEEDED` | Agent cap would be breached | | `X402_SETTLE_PENDING` | Facilitator confirmation pending — credit follows automatically | | `X402_SOLANA_FEEPAYER_UNAVAILABLE` | Sponsored fee payer temporarily unavailable | ## Compatible signers [#compatible-signers] * [Binance Agentic Wallet](/en/docs/integrations/binance-agentic-wallet) — `baw x402-payment preview` / `sign` * `@linkexai/agent-sdk` — `buildX402PaymentPayload` (EVM), `buildSvmPaymentPayload` (Solana) * Coinbase x402 tooling and any conformant x402 v2 client # Core concepts (/en/docs/getting-started/concepts) ## Credits [#credits] Your balance is denominated in USD. Every API call deducts from your balance according to the model's per-token price (see [live pricing](https://linkex.ai/pricing)); prompt and completion tokens may be priced differently. ## API keys [#api-keys] A standard key (`sk-...`) is created in **Console → Keys** and authenticates every API surface: ``` Authorization: Bearer sk-YOUR_KEY ``` Keys can be named, disabled, and deleted. Usage is attributed per key in the usage logs, so give each app its own key. ## Agent credentials [#agent-credentials] An **agent** on Linkex is an external wallet (EVM or Solana) registered to your account, paired with a dedicated API key: * You prove wallet ownership once with a signature — Linkex never sees a private key and stores only the public address. * The agent key works like a normal API key for inference, **plus** it can create x402 top-up orders bound to that agent. * Optional **spend caps** (per-call / daily / total, in USD) are enforced when the agent funds itself. * Revoke at any time: the key is disabled and the wallet unlinked in one step. Details: [Agent credentials](/en/docs/for-agents/agent-credentials). ## x402 [#x402] [x402](https://x402.org) is an open payment protocol built around HTTP status `402 Payment Required`. Linkex implements **x402 v2** with the `exact` scheme: 1. Create a top-up order → receive a `PaymentRequired` **challenge** describing exactly what to pay (network, token, amount, recipient). 2. Sign the challenge with a wallet — a gasless authorization (EIP-3009), a Permit2 signature, or a Solana transfer. 3. Submit the signed payload to the public pay endpoint. The gateway verifies and settles on-chain, then credits your account. Any x402 v2 client can pay — including [Binance Agentic Wallet](/en/docs/integrations/binance-agentic-wallet) and Coinbase x402 tooling. Protocol deep-dive: [x402 protocol](/en/docs/for-agents/x402-protocol). ## Order lifecycle [#order-lifecycle] Top-up orders (all rails) move through: ``` pending → settling → success | failed | expired ``` Poll `GET /api/user/topup/order/{trade_no}` for any order, or the x402-specific endpoints for pending x402 orders. # What is Linkex? (/en/docs/getting-started) Linkex solves two problems at once: 1. **Model access.** One endpoint, one key, 40+ providers. Your code speaks the OpenAI API (or Anthropic / Gemini formats), and Linkex routes to the upstream provider, handles failover, rate limiting, and usage analytics. Model names follow the upstream convention — `gpt-4o`, `claude-sonnet-4-5`, `gemini-2.5-pro`. 2. **Payment.** Traditional API platforms assume a human with a credit card. Linkex also supports **stablecoin funding** — pay from any crypto wallet in the console, or let an autonomous agent top up its own account over the [x402 protocol](/en/docs/for-agents/x402-protocol). Settlement rails: BNB Smart Chain (USDT/USDC/$U), Base (USDC), Solana (USDC). ## Who is it for? [#who-is-it-for] * **Developers without an international credit card** — pay for GPT/Claude/Gemini with stablecoins or regional e-wallets (Alipay+, GCash, DANA…). * **Agent builders** — issue each agent a [scoped credential](/en/docs/for-agents/agent-credentials) with spend caps; the agent funds itself and you revoke it at any time. * **Teams shipping abroad** — a single gateway with per-token billing, usage logs, and no subscription lock-in. ## How billing works [#how-billing-works] You buy **credits** denominated in USD; every API call deducts credits based on the model's per-token price. There are no subscriptions and no expiry on the default plan. See [Core concepts](/en/docs/getting-started/concepts) for how billing works and the [pricing page](https://linkex.ai/pricing) for live per-model prices. ## Next steps [#next-steps] First API call in 5 minutes. Credits, API keys, agent credentials, x402. # Quickstart (/en/docs/getting-started/quickstart) ## Create an account [#create-an-account] Register at [linkex.ai/sign-up](https://linkex.ai/sign-up) — email, GitHub, or another supported OAuth provider. New accounts may include trial credit; check the console banner. ## Create an API key [#create-an-api-key] In the [console](https://linkex.ai/console), open **Keys** and click **Add Key**. Give it a name and copy the generated key — it starts with `sk-`. Store the key securely. Anyone holding it can spend your credits. If a key leaks, delete or disable it on the Keys page and create a new one. ## Make your first call [#make-your-first-call] Point any OpenAI-compatible client at `https://linkex.ai/v1`: ```bash curl https://linkex.ai/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-YOUR_KEY" \ -d '{ "model": "gpt-4o", "messages": [{"role": "user", "content": "Hello from Linkex!"}] }' ``` ```python from openai import OpenAI client = OpenAI( base_url="https://linkex.ai/v1", api_key="sk-YOUR_KEY", ) resp = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Hello from Linkex!"}], ) print(resp.choices[0].message.content) ``` ```ts import OpenAI from 'openai'; const client = new OpenAI({ baseURL: 'https://linkex.ai/v1', apiKey: 'sk-YOUR_KEY', }); const resp = await client.chat.completions.create({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello from Linkex!' }], }); console.log(resp.choices[0].message.content); ``` Model list: `GET https://linkex.ai/v1/models`, or browse the [pricing page](https://linkex.ai/pricing). ## Top up when you run low [#top-up-when-you-run-low] Every response deducts credits. When the balance runs out, API calls return an insufficient-balance error — head to [Buying Credits](/en/docs/buying-credits) and pick a rail: crypto wallet, autonomous x402, or Alipay+. ## Where next [#where-next] Streaming, Anthropic/Gemini formats, full API reference. Give an agent its own credential and let it fund itself. # Binance Agentic Wallet (/en/docs/integrations/binance-agentic-wallet) [Binance Agentic Wallet](https://web3.binance.com/zh-CN/agentic-hub?chain=bsc) (`baw`) is Binance's CLI for agent-driven Web3 wallets. It speaks x402 v2 natively, which makes it a drop-in signer for Linkex top-up orders. This guide walks the complete path: install → sign in → create a Linkex order → sign → submit → verify. **Prerequisites** * Node.js ≥ 18 (for `npx`) * The Binance app on your phone (to approve wallet sign-in) * A Linkex API key (`sk-...`) — an [agent key](/en/docs/for-agents/agent-credentials) is recommended so spend caps apply * USDT/USDC/$U on BNB Chain, or USDC on Base/Solana, in your Binance Web3 wallet ## Install the skill [#install-the-skill] For agent runtimes that support the skills ecosystem (Claude Code, OpenClaw, etc.): ```bash npx skills add binance/binance-skills-hub/skills/binance-web3/binance-agentic-wallet ``` This installs the skill from the **binance-skills-hub** repository and the `baw` CLI (npm package `@binance/agentic-wallet`). To install just the CLI: ```bash npm install -g @binance/agentic-wallet ``` ## Sign in to the wallet [#sign-in-to-the-wallet] ```bash baw auth signin --json ``` The response contains a `urlForWeb` and a `pairingCode`. Open the URL, verify the pairing code matches, and confirm the sign-in in your Binance app. Then verify: ```bash baw auth verify --qrCodeId --json ``` `baw wallet status` should now report a connected wallet; `baw wallet balance` shows your token balances. ## Create a Linkex top-up order [#create-a-linkex-top-up-order] ```bash curl -s -X POST https://linkex.ai/api/user/topup/x402/orders \ -H "Authorization: Bearer sk-YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"amount_usd": 5, "network": "eip155:56"}' ``` The response's `data.challenge` is an x402 v2 `PaymentRequired` object. Save it — it's the input for the next step. (`network` is optional; BNB Chain shown here since B402 settlement is Binance-native.) ## Preview the payment [#preview-the-payment] Feed the challenge to `baw`: ```bash baw x402-payment preview --paymentRequirements '' --json ``` The response lists payment options with a 1-based `index`, each marked: * `READY_TO_SIGN` — sign it directly * `ACTION_REQUIRED` — e.g. `INSUFFICIENT_BALANCE`; fund the wallet first * `NOT_SIGNABLE` — e.g. unsupported network; pick another option Note the `paymentId` and your chosen option's `index`. ## Sign [#sign] ```bash baw x402-payment sign --paymentId --selectedIndex 1 --json ``` Returns `paymentHeaderValue` — a base64-encoded signed x402 payload. If `approveTxHash` is non-null (first Permit2 payment for USDT/USDC on BSC), wait for that approval to confirm before proceeding; on BSC the approval gas is sponsored. ## Submit to Linkex [#submit-to-linkex] The `paymentHeaderValue` decodes to the JSON payload the pay endpoint expects: ```bash echo '' | base64 -d > payload.json curl -s -X POST https://linkex.ai/api/x402/pay/ \ -H "Content-Type: application/json" \ -d @payload.json ``` A successful response reports `"status": "settled"` (or `credit_pending` — credited within a couple of minutes). ## Verify the credit [#verify-the-credit] ```bash curl -s https://linkex.ai/api/user/self/balance \ -H "Authorization: Bearer sk-YOUR_KEY" ``` `quota_usd` should have increased by the order amount. Done — your agent paid for its own inference budget. ## Troubleshooting [#troubleshooting] | Symptom | Fix | | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- | | `preview` marks the only option `INSUFFICIENT_BALANCE` | Fund the Binance Web3 wallet with the listed token on the listed chain | | `sign` fails with a daily-limit reason | `BLOCKED_DAILY_LIMIT_REACHED` — raise the wallet's x402 daily limit (`baw wallet settings`) or wait for reset | | Pay endpoint returns `ORDER_EXPIRED` | Orders live 10 minutes; create a new one and re-run preview/sign | | Pay endpoint returns `PAYLOAD_MISMATCH` | The signed option doesn't match the order (wrong network/token) — pick the option whose `network`/`asset` equal the challenge's | | Signature expired | Signatures are single-use and expire (`signatureExpiresAt`); restart from `preview` | ## Beyond top-ups [#beyond-top-ups] `baw` can also send tokens, swap, run limit orders, manage approvals, and more — see the [skill repository](https://github.com/binance/binance-skills-hub) for the full command surface. Only the x402 payment path above is required for Linkex. # Claude Code (/en/docs/integrations/claude-code) Linkex accepts the native Anthropic Messages format (`/v1/messages`), so Claude Code can run against it with two environment variables — no code changes. **Prerequisites:** Claude Code installed; a Linkex API key; enough credit for Claude-class models. ## Configure [#configure] ```bash export ANTHROPIC_BASE_URL="https://linkex.ai" export ANTHROPIC_AUTH_TOKEN="sk-YOUR_LINKEX_KEY" ``` Make it permanent in your shell profile, or per-project in `.claude/settings.json`: ```json { "env": { "ANTHROPIC_BASE_URL": "https://linkex.ai", "ANTHROPIC_AUTH_TOKEN": "sk-YOUR_LINKEX_KEY" } } ``` Use `ANTHROPIC_AUTH_TOKEN` (sent as a Bearer token), not `ANTHROPIC_API_KEY` — Linkex authenticates with `Authorization: Bearer`. ## Pick models [#pick-models] Claude Code's model settings accept any model name Linkex serves: ```bash export ANTHROPIC_MODEL="claude-sonnet-4-5" export ANTHROPIC_SMALL_FAST_MODEL="claude-haiku-4-5" ``` Model names follow the upstream convention — check availability and prices at [linkex.ai/pricing](https://linkex.ai/pricing). ## First run [#first-run] ```bash claude # then ask anything; verify usage appears in Console → Usage Logs ``` ## Troubleshooting [#troubleshooting] | Symptom | Fix | | --------------------------------------- | --------------------------------------------------------------------- | | 401 Unauthorized | Key typo, or the key is disabled — check Console → Keys | | "model not found" | The model name isn't served — copy the exact id from the pricing page | | Insufficient balance error | Top up: [Buying Credits](/en/docs/buying-credits) | | Traffic still goes to api.anthropic.com | `ANTHROPIC_BASE_URL` not exported in the shell that launched `claude` | # Codex CLI (/en/docs/integrations/codex) Codex CLI only speaks the OpenAI **Responses API**, and it can't override the built-in `openai` provider's base URL directly — so Linkex is added as its own custom provider in `~/.codex/config.toml`. **Prerequisites:** Codex CLI installed; a Linkex API key. ## Configure [#configure] Edit **`~/.codex/config.toml`** (user-level — project-local `.codex/config.toml` is not allowed to set provider config): ```toml model_provider = "linkex" model = "gpt-5.1-codex" [model_providers.linkex] name = "Linkex" base_url = "https://linkex.ai/v1" env_key = "LINKEX_API_KEY" wire_api = "responses" ``` Then export the key in the shell that launches Codex: ```bash export LINKEX_API_KEY="sk-YOUR_LINKEX_KEY" ``` `wire_api = "responses"` is required — Codex dropped support for the older Chat Completions wire format, and Linkex's `/v1/responses` endpoint speaks the Responses API natively, so no translation layer is needed. ## Pick a model [#pick-a-model] Use an OpenAI-family model id from [linkex.ai/pricing](https://linkex.ai/pricing) — Codex's tool-calling behavior is tuned for that family. Update the top-level `model` value in `config.toml` to switch. ## First run [#first-run] ```bash codex # then ask anything; verify usage appears in Console → Usage Logs ``` ## Troubleshooting [#troubleshooting] | Symptom | Fix | | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 401 Unauthorized | `LINKEX_API_KEY` isn't exported in the shell that launched `codex`, or the key is disabled | | Startup error about `wire_api` | Missing or wrong `wire_api` value — it must be `"responses"` | | Codex still talks to the default OpenAI endpoint | `model_provider = "linkex"` missing from `config.toml`, or the setting was placed in a project-local `.codex/config.toml` (provider config is user-level only) | | "model not found" | The model id isn't served — copy the exact id from the pricing page | | Insufficient balance error | Top up: [Buying Credits](/en/docs/buying-credits) | # Cursor (/en/docs/integrations/cursor) Cursor lets you override the OpenAI API endpoint, which is all Linkex needs. **Prerequisites:** Cursor installed; a Linkex API key. ## Configure [#configure] ### Open model settings [#open-model-settings] **Cursor Settings → Models** (Cmd/Ctrl+Shift+J → Models). ### Set the key and override the base URL [#set-the-key-and-override-the-base-url] 1. Paste your Linkex key (`sk-...`) into the **OpenAI API Key** field. 2. Enable **Override OpenAI Base URL** and enter: ``` https://linkex.ai/v1 ``` 3. Click **Verify** — Cursor sends a test request through Linkex. ### Add the models you want [#add-the-models-you-want] Cursor's built-in model list may not match Linkex's catalog. Use **Add model** to register the exact ids you use, e.g. `gpt-4o`, `claude-sonnet-4-5`, `deepseek-chat` — copy names from [linkex.ai/pricing](https://linkex.ai/pricing). ## Caveats [#caveats] * The override applies to models Cursor routes through the OpenAI-compatible API. Cursor-native features that bypass the custom endpoint (e.g. Tab autocomplete with Cursor's own models) will still use Cursor's infrastructure. * Usage appears in **Console → Usage Logs** attributed to the key you pasted — give Cursor its own key for clean accounting. ## Troubleshooting [#troubleshooting] | Symptom | Fix | | ----------------------------- | ----------------------------------------------------------------------------------------------------------------- | | Verify fails with 401 | Wrong or disabled key | | Verify fails with model error | The default verification model isn't enabled on your account — add a model you do have first, then verify | | Slow/blank replies | Check status of the specific upstream model on the [rankings page](https://linkex.ai/rankings); try another model | # Integrations (/en/docs/integrations) Each integration page covers exactly one path: **getting that tool to use Linkex** — prerequisites, install, configuration, first call, troubleshooting. We link out to the tool's own docs for everything else. Install linkex-agents-pay and let your agent check balance and top up itself in 3 turns. Install the binance-skills-hub skill and pay Linkex x402 orders with `baw`. Point Anthropic's CLI at Linkex with two environment variables. Add Linkex as a custom model provider in OpenAI Codex's config.toml. Use Linkex models inside the Cursor editor via base-URL override. The generic recipe for every OpenAI-compatible client. **The common denominators** — whatever the tool, you'll need: * Base URL `https://linkex.ai/v1` (OpenAI format) or `https://linkex.ai` (Anthropic format) * A Linkex API key (`sk-...`) from **Console → Keys** * A model name as listed at [linkex.ai/pricing](https://linkex.ai/pricing) # Linkex Skills (/en/docs/integrations/linkex-skills) [linkex-skills](https://github.com/stablepay-llc/linkex-skills) is Linkex's official skill repository for agent runtimes that support the skills ecosystem (Claude Code, OpenClaw, etc.). Its first skill, **`linkex-agents-pay`**, teaches your agent to: * check the API key's remaining balance (`status.sh`) * create an x402 top-up order and preview payment options * hand off signing to an x402 wallet ([Binance Agentic Wallet](/en/docs/integrations/binance-agentic-wallet)) and settle * optionally warn you automatically when the balance runs low (consent-gated hook) Compared with wiring the [x402 endpoints](/en/docs/for-agents/x402-protocol) yourself, the skill's bundled scripts collapse the whole flow into **3 agent turns** — prepare, confirm, execute. **Prerequisites** * An agent runtime with skills support (e.g. Claude Code) and Node.js ≥ 18 * A Linkex API key (`sk-...`) — an [agent key](/en/docs/for-agents/agent-credentials) is recommended * For signing: the `binance-agentic-wallet` skill (the flow drives its `baw` CLI); any x402 v2 `exact` client also works manually ## Install [#install] ```bash npx skills add stablepay-llc/linkex-skills/skills/linkex-agents-pay ``` ## Configure [#configure] The skill reads one required variable: | Variable | Required | Description | | ------------------------ | -------- | ------------------------------------------------------- | | `LINKEX_API_KEY` | Yes | Your Linkex key; used for model calls and top-up orders | | `LINKEX_BASE_URL` | No | Defaults to `https://linkex.ai` | | `LINKEX_LOW_BALANCE_USD` | No | Low-balance warning threshold, default `5` | For Claude Code, put it in the `env` block of `~/.claude/settings.json` (or `.claude/settings.local.json`) so every session inherits it: ```json { "env": { "LINKEX_API_KEY": "sk-YOUR_KEY" } } ``` ## First run [#first-run] Just talk to your agent: > "Check my Linkex balance" → the skill runs `status.sh` and reports balance plus available top-up networks/tokens. > > "Top up $5 on BNB Chain" → **turn 1** creates the order and previews signable options; **turn 2** shows you a table (token, chain, amount, wallet balance) and asks for confirmation; **turn 3** signs via `baw` and reports the settle result with the new balance. The skill never signs or spends without your explicit confirmation, and it holds no private keys — signing lives entirely in the wallet skill. ## Optional: automatic low-balance guard [#optional-automatic-low-balance-guard] The skill ships a `balance-guard.sh` hook: after each conversation turn it checks the key (debounced to once per 10 minutes) and prints a warning when the balance drops below the threshold. Your agent will offer to install it — it's consent-gated, read-only, and never creates orders on its own. ## First-time wallet notes [#first-time-wallet-notes] If you sign with a fresh Binance Agentic Wallet, two things trip people up: * The sign-in link must be opened in a **desktop browser**, then scanned with the Binance App (opening it on the phone shows an app-download page). * The agentic wallet starts **empty** — it's an isolated MPC wallet, separate from your main Binance funds. Fund it with the token on the target chain before creating the order (orders expire in 10 minutes). ## Troubleshooting [#troubleshooting] | Symptom | Fix | | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | | Skill asks for a key every session | Store `LINKEX_API_KEY` in the agent's settings `env` block instead of the shell | | `prepare` succeeds but options aren't signable | Wallet balance insufficient on that chain — fund the wallet, then re-run prepare (old order may have expired) | | `execute` returns `ORDER_EXPIRED` | Orders live 10 minutes; re-run prepare | | `SPEND_CAP_EXCEEDED` | The agent key's [spend caps](/en/docs/for-agents/agent-credentials#spend-caps) are doing their job — raise them if intended | # OpenAI SDK (any language) (/en/docs/integrations/openai-sdk) Any OpenAI-compatible client works with Linkex by changing two values: the **base URL** and the **API key**. This covers the official OpenAI SDKs, LangChain, LlamaIndex, Vercel AI SDK, and most agent frameworks. ## The recipe [#the-recipe] | Setting | Value | | -------- | ---------------------------------------------------------- | | Base URL | `https://linkex.ai/v1` | | API key | your Linkex `sk-...` key | | Model | any id from [linkex.ai/pricing](https://linkex.ai/pricing) | ```python from openai import OpenAI client = OpenAI(base_url="https://linkex.ai/v1", api_key="sk-YOUR_KEY") # streaming works as usual stream = client.chat.completions.create( model="claude-sonnet-4-5", messages=[{"role": "user", "content": "Stream me a haiku"}], stream=True, ) for chunk in stream: print(chunk.choices[0].delta.content or "", end="") ``` ```ts import OpenAI from 'openai'; const client = new OpenAI({ baseURL: 'https://linkex.ai/v1', apiKey: process.env.LINKEX_API_KEY, }); const stream = await client.chat.completions.create({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Stream me a haiku' }], stream: true, }); for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content ?? ''); } ``` ```go import ( "github.com/openai/openai-go" "github.com/openai/openai-go/option" ) client := openai.NewClient( option.WithBaseURL("https://linkex.ai/v1"), option.WithAPIKey(os.Getenv("LINKEX_API_KEY")), ) ``` ```python from langchain_openai import ChatOpenAI llm = ChatOpenAI( base_url="https://linkex.ai/v1", api_key="sk-YOUR_KEY", model="gemini-2.5-pro", ) ``` ```ts import { createOpenAI } from '@ai-sdk/openai'; const linkex = createOpenAI({ baseURL: 'https://linkex.ai/v1', apiKey: process.env.LINKEX_API_KEY, }); const model = linkex('claude-sonnet-4-5'); ``` ## Other request formats [#other-request-formats] Beyond the OpenAI format, the same key also authenticates: * **Anthropic Messages** — `POST https://linkex.ai/v1/messages` (see [Claude Code](/en/docs/integrations/claude-code)) * **Gemini** — `https://linkex.ai/v1beta/models/...` ## Common errors [#common-errors] | HTTP | Cause | Fix | | -------------------------- | -------------------------------------- | -------------------------------------------------------------- | | 401 | Bad or disabled key | Recreate the key in Console → Keys; check the `Bearer ` prefix | | 403 | Model not enabled for your token/group | Check the key's model restrictions in the console | | 429 | Rate limit | Back off and retry; per-key limits protect the shared account | | Insufficient balance error | Balance exhausted | [Top up](/en/docs/buying-credits) | | 404 on model | Wrong model id | Copy the exact id from `GET /v1/models` or the pricing page | # Commission structure (/en/docs/kol/commissions) Commission is calculated on the **USD value of each successful top-up** made by referred users — never on registrations, and never on inference spend directly. ## Three tiers [#three-tiers] For a top-up by user *C*, up to three beneficiaries earn simultaneously: | Tier | Who earns | Rate | | ----------- | -------------------------------------------------------------------------- | ------------------------------------------------------ | | Parent | C's direct inviter | {/* CONFIRM: production rate */} 4% (platform default) | | Grandparent | The inviter's inviter | 0.5% (platform default) | | KOL | The first **manual KOL** found walking up the invite chain (up to 10 hops) | 0.5% (platform default) | Rates are platform-wide (not negotiated per account) and are operator-configurable — the values above are the platform defaults. The **live rates** are always shown on your KOL dashboard (also served by `GET /api/kol/rates`). ## Attribution rules [#attribution-rules] * The KOL tier pays only if that KOL differs from the parent and grandparent (no double-dipping on the same top-up). * Users acquired through partner promotion channels (e.g. exchange campaigns) are excluded from referral commission. * Each top-up order pays each tier at most once — retries and webhook replays cannot double-pay. * A commission validity window may apply (default: unlimited); when set, top-ups after the window earn nothing. ## Affiliate codes (manual KOLs) [#affiliate-codes-manual-kols] Besides the personal link, manual KOLs can create up to **100 named affiliate codes** (6-character) for campaign tracking — each code's signup count is tracked separately. Codes that have been used cannot be deleted (the attribution history stays intact). ## Where earnings show up [#where-earnings-show-up] Commissions credit a dedicated **KOL account balance** (in USD cents internally), separate from your API credit balance. The dashboard lists each commission with its source order, tier, and amount. Withdrawals: [next page](/en/docs/kol/withdrawals). # Referral program overview (/en/docs/kol) Every Linkex account can refer users and earn commission on what they spend. Power promoters can be upgraded to **KOL** status with extra tools. ## How it works [#how-it-works] 1. **Get your link** — the KOL dashboard (**Console → KOL**) shows your personal invite link: `https://linkex.ai/sign-up?aff=YOUR_CODE`. Every account has an invite code automatically. 2. **They register** — anyone signing up through the link (email or OAuth) is permanently attributed to you as their inviter. 3. **You earn on top-ups** — commission triggers on each **successful top-up** by your referrals (registrations alone earn nothing). See [Commission structure](/en/docs/kol/commissions). 4. **Withdraw** — accumulated commission is withdrawn in USDC on BNB Smart Chain. See [Withdrawals](/en/docs/kol/withdrawals). ## Regular referrer vs. KOL [#regular-referrer-vs-kol] | | Every account | Manual KOL | | ------------------------- | ------------- | -------------------------- | | Personal invite link/code | ✓ | ✓ | | Earns referral commission | ✓ | ✓ (plus the KOL tier) | | Custom affiliate codes | — | up to 100 named codes | | How to get it | automatic | granted by the Linkex team | **Becoming a KOL:** KOL status is granted by the Linkex team — [contact us](/en/docs/resources/support) with your channel/audience details. There is no self-service application form. ## The dashboard [#the-dashboard] **Console → KOL** shows: balance / total earned / total paid, referral counts, 30-day activity, recent commissions, your invite link, and (for KOLs) affiliate code management. The referral list masks user identifiers for privacy. # Withdrawals (/en/docs/kol/withdrawals) Commission is withdrawn from the KOL balance to your own wallet, in **USDC on BNB Smart Chain (BEP20)**. ## Requirements [#requirements] | Rule | Value | | ------------------- | ------------------------------------------------------------------ | | Currency / chain | USDC on BSC only | | Minimum amount | $100 (platform default; live value shown in the withdrawal dialog) | | Amount granularity | Whole dollars | | Concurrent requests | One pending withdrawal at a time | | Fee | $1 flat (platform default) — settled off-balance during payout | | Address format | `0x` + 40 hex characters | ## Flow [#flow] ### Request [#request] On the KOL dashboard click **Withdraw**, enter a whole-dollar amount (≥ minimum) and your BSC address. The amount is **deducted from your KOL balance immediately** on submission — it's held in the pending request. ### Review [#review] The Linkex team reviews the request. Payouts are executed manually to the address you provided. ### Outcome [#outcome] * **Approved / paid** — USDC arrives at your address; the request is marked paid. * **Rejected** — the full amount is refunded to your KOL balance with a ledger entry. Track status and history on the dashboard's transactions list. Triple-check the BSC address — payouts to a wrong address cannot be recovered. Send a small first withdrawal if unsure. # FAQ (/en/docs/resources/faq) 1:1 — your balance is shown in USD, and every API call deducts USD directly based on the model's per-token price. See [Core concepts](/en/docs/getting-started/concepts). Usually within seconds of your signature — the response says `settled`. If it says `credit_pending`, on-chain confirmation is still in flight and a reconciler credits it automatically, typically within a couple of minutes. Base (USDC), BNB Smart Chain (USDT, USDC, $U), and Solana (USDC). Full table with contract addresses: [Supported chains & tokens](/en/docs/buying-credits/chains-and-tokens). Crypto/x402: $1 minimum, $1,000 maximum per order, and at most 3 pending orders at once. Alipay+: from $1. Live values come from `GET /api/user/topup/info`. Delete or disable it immediately in **Console → Keys** and create a new one. For agent keys, hit **Revoke** on the Agents page — the key dies and the wallet unlinks atomically. Then review **Usage Logs** for unexpected spend. No — agent keys are shown exactly once at creation. Revoke the agent and re-register the same wallet; a fresh key is minted. Alipay+ orders (and their QR codes) are valid for 10 minutes. Nothing was charged — just start a new top-up. The order would breach one of the agent's spend caps (per-call / daily / total). Raise the cap on the Agents page, or wait for the daily window to reset. This is the guardrail working as intended. Yes — any model through any of the three dialects (OpenAI, Anthropic, Gemini). The gateway converts shapes. See [Request formats](/en/docs/using-the-api/request-formats). Pay-as-you-go credits don't expire. For refunds, see the [Refund Policy](https://linkex.ai/legal/refund). No — don't send tokens directly to any address. Top-ups are order-based: each payment settles against a specific order via a signed authorization. A bare transfer can't be attributed and may be unrecoverable. **Console → Usage Logs** — every request with model, token counts, and the exact deduction, attributed to the key that made it. # Support & policies (/en/docs/resources/support) ## Get help [#get-help] {/* CONFIRM: support email / Discord / Telegram — fill from FACTS-TO-CONFIRM.md */} * **Email:** [support@linkex.ai](mailto:support@linkex.ai) * When reporting a payment issue, include the **order number** (billing history; `SWP-...` for Alipay+, numeric order id for x402) and the approximate time. * For API errors, include the request id from the response headers if present, the model, and the endpoint. ## Status & transparency [#status--transparency] * [Model rankings](https://linkex.ai/rankings) — live usage across the gateway * [Analytics](https://linkex.ai/analytics) — model popularity and value comparisons ## Policies [#policies] * [Terms of Service](https://linkex.ai/legal/terms) * [Privacy Policy](https://linkex.ai/legal/privacy) * [Refund Policy](https://linkex.ai/legal/refund) # Using the API (/en/docs/using-the-api) The primary surface is OpenAI-compatible under `https://linkex.ai/v1`. If your tool speaks OpenAI, it speaks Linkex. ## Core endpoints [#core-endpoints] | Endpoint | Purpose | | -------------------------------------------------------- | ---------------------------------- | | `GET /v1/models` | Models available to your key | | `POST /v1/chat/completions` | Chat (streaming and non-streaming) | | `POST /v1/responses` | OpenAI Responses format | | `POST /v1/embeddings` | Embeddings | | `POST /v1/images/generations` | Image generation | | `POST /v1/audio/...` | Speech, transcription, translation | | `POST /v1/messages` | Anthropic Messages format | | `/v1beta/models/...` | Gemini format | | `POST /v1/rerank` | Rerank | | video routes (`/v1/videos`, `/kling/...`, `/jimeng/...`) | Video generation | The **[API reference](/en/docs/api-reference)** documents every route with schemas, generated from the gateway's OpenAPI spec. ## Streaming [#streaming] Pass `"stream": true` — responses arrive as standard OpenAI SSE chunks. Server-side idle timeout is generous (10 minutes) to accommodate long generations. ```bash curl -N https://linkex.ai/v1/chat/completions \ -H "Authorization: Bearer sk-YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "gpt-4o", "stream": true, "messages": [{"role":"user","content":"hi"}]}' ``` ## In this section [#in-this-section] OpenAI, Anthropic, and Gemini formats side by side. How per-token billing maps to your credit balance. Full generated reference for every endpoint. # Models & pricing (/en/docs/using-the-api/models-and-pricing) ## Where prices live [#where-prices-live] The **[pricing page](https://linkex.ai/pricing)** is the source of truth — live per-token prices for every model, input (prompt) and output (completion) priced separately, quoted per million tokens. Programmatically: * `GET /v1/models` — models available to your key * `GET /api/pricing` — the public pricing feed the pricing page renders ## How a call is billed [#how-a-call-is-billed] 1. The gateway counts prompt tokens and completion tokens for the model's tokenizer. 2. Cost = `prompt_tokens × input_price + completion_tokens × output_price` (per the model's rates). 3. That USD cost is deducted directly from your balance (see [Core concepts](/en/docs/getting-started/concepts)). 4. The deduction, token counts, and model appear in **Console → Usage Logs** per request. Some models bill extras (cached input at a discount, reasoning tokens as output, per-image or per-second media rates) — the pricing page lists these where applicable. ## Choosing a model [#choosing-a-model] * **[Rankings](https://linkex.ai/rankings)** — live usage-based popularity on Linkex. * **[Analytics](https://linkex.ai/analytics)** — blind-tested popularity and value-for-money comparisons (price vs. context length vs. value score). ## Cost control tips [#cost-control-tips] * Give every app/agent its **own key**, so usage logs attribute spend cleanly. * For agents, set [spend caps](/en/docs/for-agents/agent-credentials#spend-caps) — they bound funding, which bounds total damage. * Prefer smaller models for high-volume, low-difficulty steps; route only hard steps to frontier models. # Request formats (/en/docs/using-the-api/request-formats) The same Linkex key authenticates three request dialects. Use whichever your client already speaks; billing and logging are identical. ```bash curl https://linkex.ai/v1/chat/completions \ -H "Authorization: Bearer sk-YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 256 }' ``` Everything in the OpenAI dialect works: `tools`, `response_format`, vision content parts, `stream_options`, etc. This is the recommended default. ```bash curl https://linkex.ai/v1/messages \ -H "Authorization: Bearer sk-YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-5", "max_tokens": 256, "messages": [{"role": "user", "content": "Hello"}] }' ``` Native Anthropic Messages shape — used by Claude Code and the Anthropic SDKs. Point `ANTHROPIC_BASE_URL` at `https://linkex.ai` (no `/v1` suffix; the SDK adds the path). ```bash curl "https://linkex.ai/v1beta/models/gemini-2.5-pro:generateContent" \ -H "Authorization: Bearer sk-YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{"parts": [{"text": "Hello"}]}] }' ``` Google's `v1beta` shape, including `:streamGenerateContent` for streaming. You can call **any model through any dialect** — e.g. Claude via the OpenAI format. Linkex converts request/response shapes at the gateway; pointer-precise parameters (explicit zeros, penalties, etc.) are preserved in conversion. ## Which format should I pick? [#which-format-should-i-pick] * Existing codebase or framework → keep whatever it already uses. * New project → **OpenAI format**: widest tool support and the most battle-tested conversion path. * Claude Code / Anthropic SDK users → Anthropic format with the base-URL override. # Register agent (mint agent key) (/en/docs/api-reference/agents/createAgent) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Get balance (/en/docs/api-reference/agents/getBalance) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # List agents (/en/docs/api-reference/agents/listAgents) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Request ownership nonce (/en/docs/api-reference/agents/requestAgentNonce) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Revoke agent (/en/docs/api-reference/agents/revokeAgent) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Create Alipay+ payment (/en/docs/api-reference/alipay-plus/createAlipayPayment) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Preview Alipay+ payment amount (/en/docs/api-reference/alipay-plus/previewAlipayAmount) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 文本转语音 (/en/docs/api-reference/audio/createSpeech) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 音频转录 (/en/docs/api-reference/audio/createTranscription) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 音频翻译 (/en/docs/api-reference/audio/createTranslation) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 创建聊天对话 (/en/docs/api-reference/chat/createChatCompletion) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Claude 聊天 (/en/docs/api-reference/claude-messages/createMessage) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 创建文本补全 (/en/docs/api-reference/completions/createCompletion) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 创建文本嵌入 (/en/docs/api-reference/embeddings/createEmbedding) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Gemini 嵌入(Embeddings) (/en/docs/api-reference/gemini/createEngineEmbedding) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Gemini 图片(Nano Banana) (/en/docs/api-reference/gemini/geminiRelayV1Beta) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 生成图像(qwen-image) (/en/docs/api-reference/images/createImage) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 编辑图像(qwen-image-edit) (/en/docs/api-reference/images/createImage2) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 获取模型列表 (/en/docs/api-reference/models/listModels) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Gemini 格式获取 (/en/docs/api-reference/models/listModelsGemini) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 内容审核 (/en/docs/api-reference/moderations/createModeration) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 实时 WebSocket 连接 (/en/docs/api-reference/realtime/createRealtimeSession) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 文档重排序 (/en/docs/api-reference/rerank/createRerank) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 压缩对话 (OpenAI Responses API) (/en/docs/api-reference/responses/compactResponse) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 创建响应 (OpenAI Responses API) (/en/docs/api-reference/responses/createResponse) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Get top-up options (/en/docs/api-reference/topup/getTopupInfo) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Get top-up order status (/en/docs/api-reference/topup/getTopupOrder) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 创建视频生成任务 (/en/docs/api-reference/video/createVideoGeneration) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 获取视频生成任务状态 (/en/docs/api-reference/video/getVideoGeneration) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 即梦视频生成 (/en/docs/api-reference/video-jimeng/createJimengVideo) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Kling 图生视频 (/en/docs/api-reference/video-kling/createKlingImage2Video) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Kling 文生视频 (/en/docs/api-reference/video-kling/createKlingText2Video) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 获取 Kling 图生视频任务状态 (/en/docs/api-reference/video-kling/getKlingImage2Video) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 获取 Kling 文生视频任务状态 (/en/docs/api-reference/video-kling/getKlingText2Video) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 创建视频 (/en/docs/api-reference/video-sora/createVideo) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 获取视频任务状态 (/en/docs/api-reference/video-sora/getVideo) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # 获取视频内容 (/en/docs/api-reference/video-sora/getVideoContent) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Create x402 top-up order (/en/docs/api-reference/x402/createX402Order) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Get x402 configuration (/en/docs/api-reference/x402/getX402Config) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # List pending x402 orders (/en/docs/api-reference/x402/listX402Orders) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Submit signed x402 payment (/en/docs/api-reference/x402/payX402Order) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} # Resume a pending x402 order (/en/docs/api-reference/x402/resumeX402Order) {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}