AdvancedTroubleshooting

Error Handling and Troubleshooting

Handle common errors, understand rate limits, and debug issues in your Novisurf API integrations.

{
  "error": {
    "message": "Rate limit exceeded. Retry after 30s.",
    "type": "rate_limit",
    "retry_after": 30
  }
}

Common HTTP Error Codes

Novisurf API returns standard HTTP status codes. Use these to identify issues quickly.

Status CodeMeaningCommon Causes
400Bad RequestInvalid JSON, missing parameters
401UnauthorizedMissing or invalid {API_KEY}
403ForbiddenInsufficient permissions
404Not FoundInvalid endpoint or model
429Rate LimitedExceeded rate limits
500Internal Server ErrorServer-side issue

Always check the error object in responses for detailed messages.

Rate Limit Responses and Mitigation

Rate limits protect the API from abuse. Exceeding them returns a 429 response.

Check Headers

Inspect x-ratelimit-remaining and x-ratelimit-reset headers in responses.

Implement Retry Logic

Use exponential backoff with jitter.

Monitor Usage

Track requests in your dashboard at https://dashboard.example.com/usage.

Debugging Failed Requests

Follow these steps to diagnose API failures.

import { createOpenAI } from '@ai-sdk/openai';
import { generateText } from 'ai';

const openai = createOpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.example.com/v1',
});

try {
  const { text } = await generateText({
    model: openai('gpt-4o-mini'),
    prompt: 'Explain quantum computing.',
  });
  console.log(text);
} catch (error) {
  console.error('Error:', error.message);
  console.error('Status:', error.status);
}

Logging and Monitoring Tips

Enable detailed logging to capture errors effectively.

Never log sensitive data like full {API_KEY} or user payloads.

Next Steps