Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.routeway.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Even the best APIs return errors when something needs your attention—like a missing key or a typo in your request. Knowing how to interpret and handle these responses helps you build resilient, user-friendly applications. Why care? Proper error handling means less downtime, better user experience, and easier debugging.
Most errors are easy to fix once you know what they mean. This page shows you how.

Example Error Response

{
  "error": {
    "message": "Invalid or missing API key",
    "type": "error",
    "code": 401,
    "tip": "<tip>",
    "trace_id": "<trace_id>"
  }
}

Quick Start

How to catch and handle errors in your code:
import OpenAI from 'openai'

const openai = new OpenAI({
  apiKey: process.env.Routeway_API_KEY,
  baseURL: 'https://api.routeway.ai/v1',
})

try {
  const response = await openai.chat.completions.create({
    model: 'gpt-4o-mini',
    messages: [{ role: 'user', content: 'Hello' }]
  })
  console.log(response)
} catch (error) {
  // Handle API error
  console.error('API Error:', error.response?.data || error.message)
}

Common Pitfalls

Missing API Key

Double-check your Routeway_API_KEY is set and included in every request.

Rate Limits

Too many requests? You may hit a 429 error. Add retry logic and check your usage.

Wrong Endpoint

A 404 error usually means a typo in your URL or using the wrong HTTP method.

Model Support

Some models don’t support function calling. Check model capabilities before using advanced features.