LLM inference
POST /api/llmLLM inference proxy - send an OpenAI-format chat/completions request and get a response from GPT-4o-mini. Supports vision (up to 2 image URLs, low detail) and structured output (response_format: json_object or json_schema). No API key needed; pay per call via x402. Input capped at 16k chars, output at 4096 tokens.
Input
| Field | Type | Description |
|---|---|---|
model * | string | Model ID - gpt-4o-mini |
messages * | array | Array of {role, content} objects. content can be a string or array of {type:'text',text} and {type:'image_url',image_url:{url,detail}} blocks |
max_tokens | number | Max output tokens (default 1024, cap 4096) |
response_format | object | Optional: {type:"json_object"} or {type:"json_schema",json_schema:{name,schema}} |
temperature | number | Sampling temperature (0-2) |
top_p | number | Nucleus sampling (0-1) |
stop | string | Stop sequence(s) |
Example output
{
"model": "gpt-4o-mini",
"provider": "openai",
"usage": {
"prompt_tokens": 12,
"completion_tokens": 8,
"total_tokens": 20
},
"choices": [
{
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
]
}
Try it - see the 402 challenge (free)
curl -i -X POST https://agent402.tools/api/llm \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Say hello in one sentence."}],"max_tokens":64}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/llm", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": "Say hello in one sentence."
}
],
"max_tokens": 64
}),
});
Related tools
LLM inference (Pro)
POST /api/llm-proLLM inference proxy (Pro tier) - GPT-4o or GPT-4.1. Supports vision (up to 2 image URLs) and structured output (response…
LLM inference (Premium)
POST /api/llm-premiumLLM inference proxy (Premium tier) - o3 or o3-mini reasoning models. Supports vision (up to 2 image URLs) and structured…
Image generation
POST /api/image-genGenerate an image from a text prompt using GPT Image 2 (low quality, 1024x1024). No API key needed; pay per call via x40…