Returns JSON with a chat completion from IBM Granite 4.0 Micro on Workers AI, with token usage.
Use when you need an llm chat completion for summaries, extraction or classification from a cheap open model.
Do not use for frontier models, tool calling or streaming.
Price: 0.002 USDC per thousand tokens, up to 0.03 USDC per call; clients without upto pay the cap (x402, eip155:8453). Typical response time: 8000 ms (p95). Asynchronous: the paid call returns a jobId; polling is free.
POST https://x402-gateway.blackwoodstate8.workers.dev/v1/llm-chat. A request without payment gets 402 Payment Required with the
PAYMENT-REQUIRED header; any x402 client signs an EIP-3009 authorization and retries with
PAYMENT-SIGNATURE (or X-PAYMENT). Invalid input is answered with 400 and not charged.
curl -i -X POST https://x402-gateway.blackwoodstate8.workers.dev/v1/llm-chat -H 'content-type: application/json' -d '{"messages":[{"role":"user","content":"In one sentence, what is the x402 payment protocol?"}],"maxTokens":80}'
| Pay to | 0xB7EEC07C045c7Be0C65e0b0526E1afD333e0fa7e |
|---|---|
| Asset | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 (USDC) |
| Amount | 30000 atomic units (0.03 USDC) |
| Authorization window | 60 s |
| Poll (free) | GET https://x402-gateway.blackwoodstate8.workers.dev/v1/llm-chat/jobs/:jobId |
Streamable HTTP at https://x402-gateway.blackwoodstate8.workers.dev/mcp, tool blackwood_llm_chat. Payment goes in
_meta["x402/payment"]; without it the tool returns the payment requirements.
| Field | Type | Meaning |
|---|---|---|
messages | array | Conversation so far, oldest first, e.g. [{"role": "user", "content": "Summarize: ..."}] |
maxTokens (optional) | integer | Maximum tokens to generate (1-4096, 512 when omitted); billed as requested |
temperature (optional) | number | Sampling temperature (0-2), e.g. 0.2 for near-deterministic output |
Example:
{
"messages": [
{
"role": "user",
"content": "In one sentence, what is the x402 payment protocol?"
}
],
"maxTokens": 80
}
Real example of the paid response (the job ticket):
{
"jobId": "job_00000000000000000000000000000000",
"pollUrl": "https://gateway.example/v1/llm-chat/jobs/job_00000000000000000000000000000000",
"expiresAt": "2026-01-31T00:00:00.000Z",
"status": "queued"
}
{
"type": "object",
"properties": {
"jobId": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"pollUrl": {
"type": "string",
"format": "uri"
},
"expiresAt": {
"type": "string",
"description": "ISO 8601: depois disso o resultado deixa de existir"
},
"status": {
"type": "string",
"const": "queued"
},
"next": {
"type": "object",
"properties": {
"service": {
"type": "string",
"description": "Service id of the suggested next paid call"
},
"tool": {
"type": "string",
"description": "MCP tool name of the same call"
},
"method": {
"type": "string",
"enum": [
"GET",
"POST"
]
},
"url": {
"type": "string",
"description": "Paid route of the next call"
},
"useWhen": {
"type": "string",
"description": "When the next call is the right one"
},
"sample": {
"type": "string",
"description": "Free fixed sample of the whole family"
}
},
"required": [
"service",
"tool",
"method",
"url",
"useWhen",
"sample"
],
"additionalProperties": false,
"description": "Suggested next paid call in the same family (call it in a loop when the task continues)"
}
},
"required": [
"jobId",
"pollUrl",
"expiresAt",
"status"
],
"additionalProperties": false
}Free schema and example: GET https://x402-gateway.blackwoodstate8.workers.dev/v1/llm-chat.
OpenAPI 3.1 · llms.txt · All services