BlockRun uses standard HTTP status codes and returns detailed error information.
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid parameters |
| 402 | Payment Required - Sign and retry with payment |
| 500 | Server Error - Something went wrong |
{
"error": "Error type",
"message": "Detailed error message",
"details": {}
}{
"error": "Invalid request body",
"details": [
{"path": ["model"], "message": "Required"}
]
}Causes:
- Missing required fields (
model,messages) - Invalid model ID
- Malformed JSON
{
"error": "Payment Required",
"message": "This endpoint requires x402 payment",
"price": {
"amount": "0.001000",
"currency": "USD"
}
}This is not an error - it's part of the normal x402 flow. The SDK handles this automatically.
{
"error": "Payment verification failed",
"details": "Insufficient balance"
}Causes:
- Insufficient USDC balance
- Invalid signature
- Expired payment authorization
{
"error": "Internal server error"
}Causes:
- Upstream provider error
- Temporary service issue
Python:
from blockrun_llm import LLMClient, APIError, PaymentError
client = LLMClient()
try:
response = client.chat("openai/gpt-4o", "Hello!")
except PaymentError as e:
# Payment failed - check USDC balance
print(f"Payment error: {e}")
except APIError as e:
# API returned an error
print(f"API error ({e.status_code}): {e}")
print(f"Response: {e.response}")
except Exception as e:
# Network or other error
print(f"Error: {e}")TypeScript:
import { LLMClient, APIError, PaymentError } from '@blockrun/llm';
const client = new LLMClient({ privateKey: '0x...' });
try {
const response = await client.chat('openai/gpt-4o', 'Hello!');
} catch (error) {
if (error instanceof PaymentError) {
// Payment failed - check USDC balance
console.error('Payment error:', error.message);
} else if (error instanceof APIError) {
// API returned an error
console.error(`API error (${error.statusCode}):`, error.message);
} else {
// Network or other error
console.error('Error:', error);
}
}- Check your USDC balance on Base
- Ensure your wallet is on the correct network
- Verify your private key is correct
- Check the model ID matches exactly (e.g.,
openai/gpt-4o) - See available models for valid IDs
- Increase the timeout in client options
- Try a faster model (e.g.,
gpt-4o-miniinstead ofo1)
- Check your internet connection
- Verify
blockrun.ai/apiis accessible