> ## 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.

# Migration Guide

> Learn how to migrate your existing AI applications to Routeway in a few minutes.

Routeway is designed to be a drop-in replacement for the OpenAI API. Since the API layout, request bodies, and response structures are fully compatible, migrating your existing application requires minimal changes.

## 1. Update the Base URL & Authentication

To point your requests to Routeway, you only need to change two configurations: the endpoint URL and your API key.

| Provider     | API Endpoint                 | Authentication Header                    |
| :----------- | :--------------------------- | :--------------------------------------- |
| **OpenAI**   | `https://api.openai.com/v1`  | `Authorization: Bearer OPENAI_API_KEY`   |
| **Routeway** | `https://api.routeway.ai/v1` | `Authorization: Bearer ROUTEWAY_API_KEY` |

<Note>
  In the authentication header, `ROUTEWAY_API_KEY` represents your actual Routeway API key (e.g., `sk-...`).
</Note>

***

## 2. SDK Integration Examples

If you are using official OpenAI client libraries, you don't need to install any new dependencies. Simply update the configuration during client initialization.

<Tabs>
  <Tab title="Python">
    Change your import/initialization to override the `base_url` and use your `ROUTEWAY_API_KEY`:

    <CodeGroup>
      ```python Before (OpenAI) theme={null}
      import os
      from openai import OpenAI

      client = OpenAI(
          api_key=os.getenv("OPENAI_API_KEY")
      )

      # Calls OpenAI gpt-4o-mini
      response = client.chat.completions.create(
          model="gpt-4o-mini",
          messages=[{"role": "user", "content": "Hello!"}]
      )
      ```

      ```python After (Routeway) theme={null}
      import os
      from openai import OpenAI

      client = OpenAI(
          base_url="https://api.routeway.ai/v1",
          api_key=os.getenv("ROUTEWAY_API_KEY")
      )

      # Calls Routeway gpt-4o-mini (or any other of the 200+ supported models)
      response = client.chat.completions.create(
          model="gpt-4o-mini",
          messages=[{"role": "user", "content": "Hello!"}]
      )
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Node.js">
    Update the client initialization options to point to `https://api.routeway.ai/v1`:

    <CodeGroup>
      ```javascript Before (OpenAI) theme={null}
      const { OpenAI } = require("openai");

      const client = new OpenAI({
        apiKey: process.env.OPENAI_API_KEY,
      });

      async function main() {
        const response = await client.chat.completions.create({
          model: "gpt-4o-mini",
          messages: [{ role: "user", content: "Hello!" }]
        });
      }
      ```

      ```javascript After (Routeway) theme={null}
      const { OpenAI } = require("openai");

      const client = new OpenAI({
        baseURL: "https://api.routeway.ai/v1",
        apiKey: process.env.ROUTEWAY_API_KEY,
      });

      async function main() {
        const response = await client.chat.completions.create({
          model: "gpt-4o-mini",
          messages: [{ role: "user", content: "Hello!" }]
        });
      }
      ```
    </CodeGroup>
  </Tab>
</Tabs>

***

## 3. Migrating from Anthropic (Claude)

If you are already using the Anthropic SDK, you don't need to switch to the OpenAI SDK. Simply update the `base_url` to point to Routeway:

<CodeGroup>
  ```python Before (Anthropic) theme={null}
  import os

  from anthropic import Anthropic

  client = Anthropic(
      api_key=os.getenv("ANTHROPIC_API_KEY"),
  )

  message = client.messages.create(
      model="claude-opus-4.8",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Hello, Claude!"}],
  )

  print(message.content)
  ```

  ```python After (Routeway) theme={null}
  import os

  from anthropic import Anthropic

  client = Anthropic(
      api_key=os.getenv("ROUTEWAY_API_KEY"),
      base_url="https://api.routeway.ai",
  )

  message = client.messages.create(
      model="claude-opus-4.8",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Hello, Claude!"}],
  )

  print(message.content)
  ```
</CodeGroup>

***

## 4. Other OpenAI-Compatible Gateways (e.g., DeepInfra, OpenRouter, Together AI)

If you are currently using the OpenAI SDK configured for another proxy, gateway, or compatibility layer (like DeepInfra, OpenRouter, Together AI, Groq, or Open WebUI), migrating is extremely simple.

You only need to update the client configuration references:

* **Base URL**: Change the base URL of your client to `https://api.routeway.ai/v1`.
* **API Key**: Replace your provider-specific API key with your `ROUTEWAY_API_KEY`.
* **Model Identifier**: Update the `model` parameter to one of Routeway's supported models (e.g. `gpt-4o`, `claude-3-5-sonnet`, `deepseek-v3`).

***

## 5. General HTTP / REST Migration

If you are not using an SDK and instead make direct HTTP requests (e.g., using `fetch`, `axios`, or Python `requests`), follow these general guidelines to migrate from any other provider:

1. **Endpoint**: Point your POST requests to:
   ```http theme={null}
   https://api.routeway.ai/v1/chat/completions
   ```
2. **Headers**: Provide your API key in the standard bearer token format:
   ```http theme={null}
   Authorization: Bearer YOUR_ROUTEWAY_API_KEY
   Content-Type: application/json
   ```
3. **Payload Structure**: Ensure your JSON body uses the standard Chat Completions format:
   ```json theme={null}
   {
     "model": "model-id-here",
     "messages": [
       {
         "role": "user",
         "content": "Your prompt goes here"
       }
     ]
   }
   ```

<Note>
  See our [Models](/getting-started/models) page for the full list of model identifiers available on Routeway.
</Note>
