Errors

The Envizion AI API uses standard HTTP status codes and returns errors in a consistent JSON format based on RFC 7807 Problem Details.

Error Format

All error responses follow the same structure:

Error Response
{
  "error": "not_found",
  "detail": "Agent 'nonexistent_agent' not found",
  "status": 404,
  "request_id": "req_abc123def456"
}
FieldTypeDescription
errorstringMachine-readable error code (e.g., not_found, unauthorized)
detailstringHuman-readable explanation of the error
statusintegerHTTP status code
request_idstringUnique request identifier for support and debugging

The request_id is also returned in the X-Request-ID response header on every response (including successful ones). Include this when contacting support.

Error Codes

400

Bad Request

bad_request

The request was malformed or missing required parameters.

Common causes

  • Missing required field in the request body
  • Invalid JSON syntax
  • Invalid scope values when creating API keys
  • Invalid webhook event types
  • Maximum limit exceeded (e.g., 10 API keys per user)
401

Unauthorized

unauthorized

Authentication failed. The API key or JWT token is invalid, expired, or missing.

Common causes

  • No authentication header provided
  • Invalid or revoked API key
  • Expired API key (error: api_key_expired)
  • Invalid or expired JWT token
  • Malformed Authorization header
402

Payment Required

insufficient_credits

The operation requires credits that are not available in your wallet.

Common causes

  • Insufficient credit balance for an agent run
  • Insufficient credits for a render operation
  • Credit hold could not be placed
403

Forbidden

forbidden

The authenticated user does not have the required scope for this operation.

Common causes

  • API key missing required scope (e.g., write scope for POST requests)
  • Attempting to access billing endpoints without billing scope
  • Attempting to publish without publish scope
  • Attempting to delete another user's resource
404

Not Found

not_found

The requested resource does not exist or is not visible to the authenticated user.

Common causes

  • Invalid agent ID or slug
  • Run ID does not exist
  • Webhook ID does not exist or belongs to another user
  • Project UUID not found or not owned by the user
422

Validation Error

validation_error

The request body was syntactically valid but failed semantic validation.

Common causes

  • Invalid pipeline_type value
  • Graph edges reference nonexistent tools
  • Tool slug not found in the catalog
  • Invalid render options combination
429

Too Many Requests

rate_limit_exceeded

You have exceeded the rate limit for your tier. Check the Retry-After header.

Common causes

  • Exceeded per-minute request limit (100/500/1000 depending on tier)
  • Too many requests in a short burst
500

Internal Server Error

internal_server_error

An unexpected error occurred on the server. These are automatically logged and investigated.

Common causes

  • Unhandled server exception
  • Database connection failure
  • Internal service communication error
502

Bad Gateway

bad_gateway

The API gateway could not reach the upstream service that handles this request.

Common causes

  • Upstream service is down or restarting
  • Network connectivity issue between services
  • Service container is not running
504

Gateway Timeout

gateway_timeout

The upstream service did not respond within the configured timeout period.

Common causes

  • Agent run took too long to start (default timeout: 30s)
  • Render operation exceeded timeout
  • Upstream service is overloaded

Error Handling Examples

Python

Python
from envizion import EnvizionClient
from envizion.exceptions import (
    EnvizionError,
    AuthenticationError,
    RateLimitError,
    NotFoundError,
    InsufficientCreditsError,
    ValidationError,
    ServerError,
)

client = EnvizionClient(api_key="vk_...")

try:
    run = client.runs.create(
        agent_id="creative_director",
        inputs={"topic": "AI news"}
    )
except AuthenticationError as e:
    # 401 or 403: bad key or missing scopes
    print(f"Auth failed: {e}")
    print(f"Status: {e.status_code}")

except RateLimitError as e:
    # 429: rate limited
    print(f"Rate limited. Retry after {e.retry_after}s")

except NotFoundError:
    # 404: agent not found
    print("Agent does not exist")

except InsufficientCreditsError:
    # 402: not enough credits
    print("Top up your credits first")

except ValidationError as e:
    # 422: invalid input
    print(f"Validation failed: {e}")

except ServerError:
    # 5xx: server error (SDK auto-retries 3x)
    print("Server error after retries")

except EnvizionError as e:
    # Catch-all for any other API error
    print(f"Error: {e}")
    print(f"Status: {e.status_code}")
    print(f"Request ID: {e.request_id}")

TypeScript

TypeScript
import { EnvizionClient, EnvizionError, RateLimitError, NotFoundError } from "@envizion/sdk";

const client = new EnvizionClient("vk_...");

try {
  const run = await client.runs.create({
    agentId: "creative_director",
    inputs: { topic: "AI news" },
  });
} catch (err) {
  if (err instanceof RateLimitError) {
    // 429: wait and retry
    console.log(`Retry after ${err.retryAfter}s`);
    await new Promise(r => setTimeout(r, err.retryAfter * 1000));

  } else if (err instanceof NotFoundError) {
    // 404: resource not found
    console.log("Agent does not exist");

  } else if (err instanceof EnvizionError) {
    // Any other API error
    console.log(`Error: ${err.message}`);
    console.log(`Status: ${err.statusCode}`);
    console.log(`Request ID: ${err.requestId}`);
  }
}

Raw HTTP (cURL)

cURL
# Check the HTTP status code and parse the error body
response=$(curl -s -w "\n%{http_code}" \
  https://api.envizion.ai/v1/agents/nonexistent \
  -H "X-API-Key: vk_your_key")

body=$(echo "$response" | head -n -1)
status=$(echo "$response" | tail -1)

if [ "$status" -ne 200 ]; then
  echo "Error $status:"
  echo "$body" | python3 -m json.tool
fi

Debugging Tips

Save the request_id

Every response includes a request_id (in the body and X-Request-ID header). Include this when contacting support for faster resolution.

Check the detail field

The detail field contains a human-readable description of what went wrong, often including the specific field or value that caused the error.

Use the /v1/usage/by-endpoint endpoint

If you're seeing unexpected errors, check your usage analytics to identify patterns by endpoint.

Retry on 5xx errors

Server errors (500, 502, 504) are usually transient. Retry with exponential backoff. The SDKs do this automatically.

Do not retry on 4xx errors

Client errors (400, 401, 403, 404, 422) indicate a problem with the request. Fix the request before retrying.