> ## Documentation Index
> Fetch the complete documentation index at: https://kiosapi.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Trae AI Code Editor to the KiosAPI Gateway

> Configure ByteDance's Trae AI code editor to use KiosAPI as a custom provider, replacing the default backend with KiosAPI's OpenAI-compatible gateway.

Trae is an AI-powered code editor from ByteDance. Because it supports OpenAI-compatible providers, you can point it directly at KiosAPI — giving you access to the full range of models available through KiosAPI's unified gateway. This tutorial walks you through the configuration steps.

## Prerequisites

* [Download and install Trae](https://www.trae.ai/)
* A **KiosAPI API key** (starts with `sk-`) from the [Dashboard](https://kiosapi.com) → **Token Management**

<Steps>
  ### Open Trae settings

  1. Launch Trae
  2. Open Settings with `Ctrl + ,` on Windows or `Cmd + ,` on macOS
  3. Search for **AI Provider**, or navigate to **Settings → AI Settings**

  ### Configure the custom provider

  Set the following values in the custom provider configuration:

  | Field            | Value                                      |
  | ---------------- | ------------------------------------------ |
  | **API Base URL** | `https://kiosapi.com/v1`                   |
  | **API Key**      | `sk-xxx`                                   |
  | **Model**        | `gpt-4o` or any model available on KiosAPI |

  Replace `sk-xxx` with your actual KiosAPI key.

  <Info>
    Trae supports OpenAI-compatible providers. KiosAPI is fully OpenAI-compatible, so it works as a drop-in replacement.
  </Info>

  ### (Optional) Set environment variables

  You can also configure the provider by setting environment variables if Trae reads them from your shell.

  <Tabs>
    <Tab title="macOS / Linux">
      Add the following to `~/.bashrc` or `~/.zshrc`:

      ```bash theme={null}
      export OPENAI_API_KEY="sk-xxx"
      export OPENAI_BASE_URL="https://kiosapi.com/v1"
      ```

      Then reload your shell:

      ```bash theme={null}
      source ~/.bashrc  # or ~/.zshrc
      ```
    </Tab>

    <Tab title="Windows (PowerShell)">
      ```powershell theme={null}
      setx OPENAI_API_KEY "sk-xxx"
      setx OPENAI_BASE_URL "https://kiosapi.com/v1"
      ```
    </Tab>
  </Tabs>

  ### Select the custom provider

  In the Trae chat panel or inline completion settings, select your custom provider as the active AI backend.

  ### Verify your setup

  Use any of Trae's AI features — chat, inline completions, or code generation — to confirm that requests are routing through KiosAPI. If the AI responds, your configuration is working correctly.

  <Tip>
    For best results with coding tasks, use models like `gpt-4o`, `claude-sonnet-4-6`, or `deepseek-chat`. Check the [models list](../api-reference/models/list-models) for all available options.
  </Tip>
</Steps>

## Troubleshooting

### AI features not working

* Verify the API key is correct and starts with `sk-`
* Ensure the base URL is `https://kiosapi.com/v1` — with `/v1`
* Restart Trae after changing settings

### Model not available

* Check that the model name is supported on KiosAPI
* Verify your token group includes the desired model

## Need Help?

* [KiosAPI Dashboard](https://kiosapi.com)
* [Available Models](../api-reference/models/list-models)
