Developer documentation
Create an Anthropic-compatible LLM response
Request fields, payment behavior, response details, and errors for /v1/messages.
Page tools
Create an Anthropic-compatible LLM response
POST /v1/messages
Operation ID: createMessage. The canonical machine-readable schema is OpenAPI.
Request body
Choose an available model value from GET /v1/models. The max_tokens value limits the model's output and helps calculate the fixed exact price. A successful request pays the amount shown in the HTTP 402 challenge; shorter output does not create a later refund. Streaming must remain false.
{
"model": "gemini-3.6-flash",
"messages": [
{
"role": "user",
"content": "Explain why the sky appears blue."
}
],
"max_tokens": 1024,
"stream": false
}Payment lifecycle
The first request returns Hypertext Transfer Protocol (HTTP) status 402 without calling the model provider. Check the Base network, United States Dollar Coin (USDC) contract, payment recipient, expiry time, exact scheme, EIP-712 domain, and amount. Sign locally with an official x402 client, then retry the identical effective request with the same idempotency key.
After success, read the PAYMENT-RESPONSE, X-Request-ID, X-Receipt-ID, and X-Catalog-Version headers together with the receipt link. The response is released only after the result, payment, and receipt are safely stored.
Read the response
Read Anthropic-compatible content blocks and normalized usage. The public alias is preserved even though the private gateway resolves an internal Vertex deployment.
Responses
- 200: Durably settled response with X-Receipt-ID and PAYMENT-RESPONSE headers
- 400: Invalid or unsupported request
- 402: Payment required. The PAYMENT-REQUIRED header is authoritative and contains the official x402 challenge. Empty, structurally incomplete, or syntactically malformed unsigned JSON receives an inspection challenge; a complete semantic error returns 400/415. Submit a valid body to receive its fixed request price before signing.
- 409: Idempotency key reused with a different effective request
- 415: Unsupported request content type. This fails before a payment challenge or verification.
- 503: Provider, payment, or safety dependency unavailable
