Developer API
Reliability, errors, and rate limits
Build retry-safe requests with idempotency, stable error codes, response headers, and cost safeguards.
Make every POST idempotent
Send an Idempotency-Key containing 8 to 255 letters, numbers, underscores, or hyphens. The key is scoped per API key and retained for 24 hours; retry the same logical operation with the same value.
# identical resend after a network timeout
curl https://oppermind.com/api/v1/images \
-H "Authorization: Bearer $OPPERMIND_API_KEY" \
-H "Idempotency-Key: order-58213-hero-image" \
-H "Content-Type: application/json" \
-d '{"prompt":"product photo of a walnut desk lamp on white","n":1}'{
"model": "oppermind-lato-1",
"data": [
{
"url": "/api/v1/images/proxy?token=…"
}
]
}Handle errors by meaning
400 means the request is invalid, 401 the key is missing or invalid, 402 credits are insufficient, 403 permission or IP policy blocked the call, 409 the same idempotent operation is still running, 429 the rate limit was exceeded, and 5xx indicates a gateway or server problem.
curl https://oppermind.com/api/v1/messages \
-H "Authorization: Bearer $OPPERMIND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"oppermind-lato-1","max_tokens":400,"messages":[{"role":"user","content":"Draft a welcome email for new members."}]}'{
"error": {
"type": "billing_error",
"code": "OPMD_BILLING_001",
"message": "Insufficient credits. Add credits at oppermind.com/developers"
}
}Use stable machine codes
Branch on error.code rather than parsing prose. Safe messages can be surfaced to users; keep X-Request-ID with logs and support reports.
curl https://oppermind.com/api/v1/messages \
-H "Authorization: Bearer $OPPERMIND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"oppermind-lato-1","prompt":"Draft a welcome email for new members."}'{
"error": {
"type": "invalid_request",
"code": "OPMD_MODEL_001",
"message": "messages array is required"
}
}Respect RateLimit headers
Every response carries RateLimit information. Slow down before exhausting the budget, add jitter to retryable backoff, and do not retry validation, authentication, permission, or billing failures unchanged.
curl https://oppermind.com/api/v1/messages \
-H "Authorization: Bearer $OPPERMIND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"oppermind-lato-1","max_tokens":60,"messages":[{"role":"user","content":"Tag this ticket: refund request."}]}'{
"error": {
"type": "rate_limit_error",
"code": "OPMD_RATE_001",
"message": "Too many requests for this API key. Slow down."
}
}Protect spend
Bound max_tokens, image count, duration, and concurrency in your own application. Monitor usage and credits, set billing alerts, and place expensive generation behind user authorization.
# max_tokens bounded by your own cap of 1500
curl https://oppermind.com/api/v1/messages \
-H "Authorization: Bearer $OPPERMIND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"oppermind-lato-1","max_tokens":1500,"messages":[{"role":"user","content":"Write the product page copy for the walnut desk lamp."}]}'{
"id": "req_6c1f9b3e7a5d2c8f4b0e6a1d",
"model": "oppermind-lato-1",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Warm walnut, clean lines. The lamp gives a soft pool of light for reading and dims to a night glow with one touch."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 24,
"output_tokens": 212
}
}Practise this in Oppermind Academy
Follow the related tutorial or course and apply the concept to a real task.
