Token4u AI Chat API · Chat Completions

by Token4u AI Chat API

POSTBasealipay

$0.009

per call · USD Coin on Base

gpt-4o-mini API call (~128 tokens)

Endpoint

POST https://token4u.ai/v1/chat/completions

1.7k

Calls / 30d

2

Unique payers / 30d

Aug 20

Last called

upto

Payment scheme

Call this service

TypeScript · @x402/fetch
import { wrapFetchWithPayment } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY);
const fetchWithPay = wrapFetchWithPayment(fetch, account);

const res = await fetchWithPay("https://token4u.ai/v1/chat/completions", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "messages": [
      {
        "content": "Hello, how are you?",
        "role": "user"
      }
    ],
    "model": "gpt-4o-mini"
  }),
});
const data = await res.json();
cURL
curl -X POST \
  "https://token4u.ai/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{"messages":[{"content":"Hello, how are you?","role":"user"}],"model":"gpt-4o-mini"}' \
  -H "X-PAYMENT: <signed x402 payment>"

Example response

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "Hello! How can I help you today?",
        "role": "assistant"
      }
    }
  ],
  "created": 1753000000,
  "id": "chatcmpl-abc123",
  "model": "gpt-4o-mini",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 8,
    "prompt_tokens": 10,
    "total_tokens": 18
  }
}

Payment details

Pay to0x3ccc6565511f404716cad2d578851ff3ff95fd85
AssetUSD Coin · 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913
NetworksBase, alipay
Schemesupto, nvm:erc4337, alipay:a2m

Is this your API?

Pin it to the top of AI & Inference and the homepage with a featured placement.

Get featured →

More from Token4u AI Chat API & similar services