API Reference

Errors

NeuronEdge uses conventional HTTP response codes to indicate the success or failure of an API request. Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error with your request. Codes in the 5xx range indicate an error on our end.

Error Response Format

All error responses include a JSON body with details about the error:

json
{
  "error": {
    "code": "INVALID_API_KEY",
    "message": "The API key provided is invalid or has been revoked.",
    "status": 401,
    "request_id": "01HXYZ123ABC456DEF"
  }
}

HTTP Status Codes

CodeNameDescription
400Bad RequestThe request was malformed or missing required parameters.
401UnauthorizedAuthentication failed. Check your API key.
403ForbiddenYou don't have permission to access this resource.
404Not FoundThe requested resource doesn't exist.
422Unprocessable EntityThe request was valid but couldn't be processed.
429Too Many RequestsRate limit exceeded. Slow down and retry.
500Internal Server ErrorSomething went wrong on our end.
502Bad GatewayError communicating with the upstream LLM provider.
503Service UnavailableThe service is temporarily unavailable.
504Gateway TimeoutThe upstream LLM provider took too long to respond.

Error Codes

In addition to HTTP status codes, responses include specific error codes:

INVALID_API_KEY

The NeuronEdge API key is missing, invalid, or revoked.

MISSING_PROVIDER_KEY

The X-Provider-API-Key header is missing.

INVALID_PROVIDER_KEY

The LLM provider rejected the API key.

RATE_LIMIT_EXCEEDED

You've exceeded your rate limit. Check X-RateLimit-* headers.

QUOTA_EXCEEDED

You've exceeded your monthly request quota.

POLICY_NOT_FOUND

The specified policy ID doesn't exist.

INVALID_ENTITY_TYPE

One or more entity types in the policy are invalid.

PROVIDER_ERROR

The upstream LLM provider returned an error.

FEATURE_NOT_AVAILABLE

This feature is not available on your subscription tier.

Handling Errors

typescript
try {
  const response = await fetch('https://api.neuronedge.ai/v1/openai/chat/completions', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer ne_live_your_api_key',
      'X-Provider-API-Key': 'sk-your-openai-key',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ model: 'gpt-5.2', messages: [...] }),
  });

  if (!response.ok) {
    const error = await response.json();

    switch (error.error.code) {
      case 'RATE_LIMIT_EXCEEDED':
        // Wait and retry
        const retryAfter = response.headers.get('Retry-After') || 60;
        await sleep(retryAfter * 1000);
        // Retry request
        break;
      case 'INVALID_API_KEY':
        // Check API key configuration
        throw new Error('Invalid API key');
      case 'PROVIDER_ERROR':
        // Handle provider-specific error
        console.error('Provider error:', error.error.message);
        break;
      default:
        throw new Error(error.error.message);
    }
  }
} catch (error) {
  console.error('Request failed:', error);
}

Health Check Endpoints

Use these endpoints to check service health (no authentication required):

GET /health

Basic health check

GET /health/ready

Readiness probe for Kubernetes

GET /health/db

Database connectivity check