Skip to content

Add Router One to TRAE (TraeCode) as a custom model

TRAE's AI IDE is named TraeCode in both its international (trae.ai) and China (trae.cn) documentation, and it takes a custom model under Settings > Models > Add Model > Custom Model: an API format (OpenAI Chat Completions or Anthropic Messages), a request URL, a model ID and an API key. Point that form at Router One and the requests TraeCode sends with that model selected go to the gateway on your key, with each request's tokens, cost and status in Dashboard → Logs. Neither edition's built-in model list includes a Claude model as of 2026-09-29, so a custom model is how you call a Claude ID from TraeCode. Checked against TraeCode 3.3.101 (China edition, released 2026-09-15), TraeCode 3.5.91 (international edition, released 2026-08-19) and TRAE's model, mode and billing documentation for both editions on 2026-09-29; on 2026-10-03 both editions were still on those versions, and the model documentation's Model Series descriptions still matched this guide.

Before you add the model: what runs on your Router One key

TraeCode's Add Model window offers two sources: a preset model provider, where you only paste that provider's API key, or Custom Model, where you set the API format, request URL, model ID and key yourself. Router One goes in Custom Model. Requests reach Router One only while that custom model is selected: TRAE's docs state that Auto Mode calls built-in models only and never your custom models, so switch Auto Mode off in the model menu at the bottom right of the chat input. Check your plan first: TRAE's international plans table lists model selection on the Free plan as Auto mode only, while the paid plans add manual model selection. Max Mode's documented model table lists built-in models only; for a custom model, the Context Window fields in Advanced Settings set the limits. Create a dedicated Router One key for TraeCode with a maxSpend cap in the dashboard, then copy a chat model ID from /models, for example anthropic/claude-sonnet-5, openai/gpt-5.5 or deepseek-v4.1-flash.

Configure TRAE to use the Router One base URL

Open Settings > Models, click Add Model and choose Custom Model. Set API Format to OpenAI Chat Completions, leave the Full URL switch off and enter https://api.router.one/v1 as Custom Request URL; TraeCode appends the request path for the selected format, as the international docs show with the base https://api.openai.com/v1. Enter the exact catalog ID in Model ID, an optional Display Name, and the dedicated Router One key in API Key. For the first test, leave Advanced Settings at their defaults with Model Series on Default, then click Add Model: TraeCode checks the connection and adds the model only if the check succeeds. The finished form for a Claude ID looks like this:

自定义请求地址 / Custom Request URL (OpenAI Chat Completions)
https://api.router.one/v1
自定义请求地址 / Custom Request URL (Anthropic Messages)
https://api.router.one
traecode-custom-model
# TraeCode:设置 > 模型 > 添加模型 > 自定义模型
# TraeCode: Settings > Models > Add Model > Custom Model
API 格式 / API Format:                OpenAI Chat Completions
完整 URL / Full URL:                  关闭 / Off
自定义请求地址 / Custom Request URL:  https://api.router.one/v1
模型 ID / Model ID:                   anthropic/claude-sonnet-5
模型展示名称 / Display Name:          Claude Sonnet 5 (Router One)
API 密钥 / API Key:                   sk-your-router-one-key

# 高级配置 / Advanced Settings(首次测试 / first test)
模型系列 / Model Series:              默认 / Default
上下文窗口 / Context Window:          输入与输出留空 / input and output empty (TraeCode defaults)
支持图片输入 / Image Input Support:   仅当模型详情页列出图片输入时开启 / On only if the model page lists image input
思考模式 / Thinking Mode:             跟随模型默认配置 / Follow model default
采样参数 / Hyperparameters:           留空 / empty (Temperature, Top P, Top K)

# Claude 与 DeepSeek V4 的 ID 也可以选 Anthropic 格式 / Claude and DeepSeek V4 IDs can use the Anthropic format instead:
#   API 格式 / API Format: Anthropic Messages,完整 URL 关闭 / Full URL off: https://api.router.one
# 完整 URL 打开 / Full URL on: https://api.router.one/v1/chat/completions
#                     或 / or https://api.router.one/v1/messages

Which API format and URL each Router One model ID needs

TraeCode joins paths the way its docs describe: with Full URL off, the OpenAI Chat Completions format takes a base ending in /v1 and the Anthropic Messages format takes the host root; with Full URL on, you paste the complete endpoint. Router One serves every chat model on Chat Completions, and Claude-family and DeepSeek V4 IDs on Messages, so the format follows the model ID. A GPT, Gemini or Grok ID sent with Anthropic Messages is rejected with HTTP 400 before any model runs, and the message names the path to use (model '<id>' must be called via …); switch that model to OpenAI Chat Completions. Router One accepts the key either as an Authorization: Bearer header or as x-api-key, so the same key serves both formats. Channel IDs such as aws/claude-sonnet-5 are separate catalog entries with their own rates; bare or vendor-prefixed IDs keep the default channel.

Which API format and URL each Router One model ID needs
API Format in TraeCodeFull URL offFull URL onRouter One model IDs
OpenAI Chat Completionshttps://api.router.one/v1https://api.router.one/v1/chat/completionsEvery chat model in the catalog: Claude, GPT, Gemini, Grok and DeepSeek IDs
Anthropic Messageshttps://api.router.onehttps://api.router.one/v1/messagesClaude-family IDs, aws/claude-… and vertex/claude-… channel IDs included, plus deepseek-v4.1-flash and deepseek-v4-flash

SOLO, CUE, the plugin and the CLI: where the custom model applies

TRAE's docs for both editions say where a model you add in TraeCode is used; everything marked No or Not documented keeps running on TRAE's own models, never reaches Router One and never appears in Dashboard → Logs. TraeWork Desktop has a custom-model form of its own (local tasks only), and TRAE Enterprise can let members add custom models in the TraeCode Plugin:

SOLO, CUE, the plugin and the CLI: where the custom model applies
TRAE surfaceUses your custom model?What TRAE's docs say
Chat and agent tasks in TraeCode, custom model selectedYesRequests go to the Custom Request URL with your key; switch Auto Mode off first
SOLO modeYesThe SOLO docs say you can add custom models and use them in the built-in Agent
Auto Mode and Max ModeNoAuto Mode calls built-in models only; Max Mode's model table lists built-in models
CUE code completionNot documentedThe CUE docs don't mention custom models
TraeCode Plugin for VS Code and JetBrains IDEs (formerly MarsCode)Not documented on personal plans; yes in TRAE EnterpriseOn personal plans, the plugin docs list AI features but no model settings, and a reply on TRAE's Chinese community forum (2026-07-13) says the VS Code plugin cannot add custom models yet; TRAE Enterprise's model docs say members can add and use custom models in the TraeCode Plugin once an admin enables member custom models
TraeCode CLINot on individual plansPer the China-edition docs, only customers on the TRAE Enterprise flagship plan can use TraeCode CLI; its model docs add custom models (base_url, api_key, model) in trae_cli.yaml once an admin allows member custom models

Advanced Settings: model series, context window, tool rounds, images and sampling

Advanced Settings change the request TraeCode builds, so keep the defaults for the first test and change one field at a time:

  • Model Series: start with Default and switch only after a plain request works. Both editions offer GPT-5, Gemini-3, DeepSeek-4 and Default; in the China edition the Claude-4 and GPT-6 options, among others, are enterprise-only. Per TRAE's docs, the GPT-5 option switches the output-limit field from max_tokens to max_completion_tokens, fixes Temperature at 1 and applies GPT-5 prompt templates. Router One's Chat Completions accepts either field as the output cap, so the output field does not decide which option to pick; keep Default unless you want the GPT-5 option's fixed Temperature and prompt templates. The DeepSeek-4 option turns thinking on by default, and the international docs say it does not support image input.
  • Context Window: an input and an output value; left empty, TraeCode uses its own defaults. If you enter an input value, keep it at or below the context window on the model's Router One page (1,048,576 tokens for anthropic/claude-sonnet-5, 1,050,000 for openai/gpt-5.5, 1,000,000 for deepseek-v4.1-flash): a larger window lets long agent sessions send more input per request, and every input token is billed. The output value is a cap you choose.
  • Tool Call Rounds: the most tool calls the model may make in one task. Each round is another billed request, so keep the default or lower it.
  • Image Input Support: turn it on only when the model page lists image input; deepseek-v4-flash, for example, is text-only.
  • Tool calling and Thinking Mode: the agent depends on tool calls, so prefer IDs whose model page lists tool calling; for other IDs, test one tool call first. Leave Thinking Mode on Follow model default for the first test.
  • Hyperparameters (Temperature, Top P, Top K): leave them empty. Per TRAE's docs, empty means the model provider's defaults. Keep them empty for Claude IDs in particular: Anthropic's API returns HTTP 400 for non-default sampling values on Claude Opus 4.7 and later Opus models. If a 400 names one of these parameters, clear the field and try again.

Read the Add Model check and your first requests in Logs

When you click Add Model, TraeCode calls the service to check the key; if the check fails, the window shows the error message and the log the service returned. The common Router One causes: 401 means the key is missing or wrong; 404 usually means the URL does not match the Full URL switch, for example a complete /v1/chat/completions URL entered with the switch off, or https://api.router.one/v1 used with Anthropic Messages, where TraeCode appends /v1/messages to a base that already ends in /v1; 400 with must be called via means the ID needs the other API format; 402 means the wallet balance or the key's maxSpend is used up. TRAE's docs don't say whether the check itself sends a billable model request, so look for it in Dashboard → Logs after adding the model. Then send one plain message with the custom model selected and match it in Logs by time, model and request_id: the log shows tokens, cost, status, total time and, for streamed requests that produced output, time to first token (TTFT). If a chat turn fails with error 4054 (模型请求失败,请稍后重试 in the Chinese UI), the message itself names no cause, and an open issue in TRAE's GitHub repository reports the same error with another provider's custom model (checked 2026-10-01). Look for that turn in Dashboard → Logs: no record means the request never reached Router One, so recheck the API format, the URL against the Full URL switch, and the model ID; if there is a record, read its status code as described above. One agent task can produce a request per tool round, so give TraeCode its own key with maxSpend; once the cap is reached, requests on that key return HTTP 402 while your other keys keep working.

Which model ID should TRAE send?

Copy the exact model ID from /models, preserving case, hyphens, and version suffixes; do not substitute a display name. Open its detail page and match the supported API endpoints, context window, and capabilities such as tool calling to the provider and features selected in TRAE. A catalog listing does not mean the client can use every feature of that model. Give each client or application a dedicated API key with a maxSpend cap.

Which API protocol is TRAE using?

OpenAI-compatible describes an interface format; it does not make Chat Completions (/v1/chat/completions), Responses (/v1/responses), and Anthropic Messages (/v1/messages) interchangeable. Check the installed client version, provider configuration, and actual request path against the model detail page and API compatibility fact sheet. A successful plain-text chat does not establish support for hosted tools, conversation state, or file-editing features.

Verify the TRAE call in your request trace

Send a simple text request from TRAE, then match its trace in Dashboard → Logs by time, model, and request_id: tokens, cost, latency, and status. Next, test streaming, tool calls, and multi-turn history separately. For failures, retain the actual request path, full error message, and request_id. If there is no matching log, either the request never reached the gateway (client configuration or connectivity) or the gateway refused it before calling a model — a 401 for the key, a 402 for funds, a 429 from your key's or account's limits, or a 400 or 404 for the model ID or endpoint; a streamed request that failed before any output may have no log either. The status and error message the client received tell which, so check them before attributing the error to the gateway or upstream.

FAQ

Where do I add a custom model in TRAE?

In TraeCode, open Settings > Models and click Add Model. Choose Custom Model rather than a preset model provider, then fill in API Format, Custom Request URL (with its Full URL switch), Model ID, Display Name and API Key, and optionally Advanced Settings. After it is added you can edit, delete, enable or disable the model in the same panel; a disabled model stays in Settings but disappears from the chat's model list. The China edition labels the same path 设置 > 模型 > 添加模型 > 自定义模型.

Can I use Claude models in TRAE through Router One?

Yes, as a custom model. Neither TraeCode edition's built-in list includes a Claude model as of 2026-09-29, and TRAE's docs describe the Anthropic Messages format as the one suited to Claude-series models. With Router One, a Claude ID such as anthropic/claude-sonnet-5 is served with Anthropic Messages at https://api.router.one and with OpenAI Chat Completions at https://api.router.one/v1. Keep Model Series on Default: the Claude-4 option is enterprise-only in the China edition and not offered in the international docs. Router One bills each request on your key at the model's posted rate; this uses TraeCode's own custom-model feature with your key and does not imply any partnership between TRAE and Router One.

Why does TraeCode still answer with a built-in model?

Auto Mode is on, or the custom model is not selected. TRAE's docs state that Auto Mode picks among built-in models only and never calls your custom models. Open the model menu at the bottom right of the chat input, switch Auto Mode off and select your Router One model by its display name. If it is missing from that list, check in Settings > Models that the model is enabled. Requests that never reach Router One do not appear in Dashboard → Logs.

Should I switch Full URL on?

Either way works as long as the value matches the switch. With Full URL off, enter the base: https://api.router.one/v1 for OpenAI Chat Completions or https://api.router.one for Anthropic Messages, and TraeCode appends the path. With Full URL on, enter the complete endpoint: https://api.router.one/v1/chat/completions or https://api.router.one/v1/messages. A mismatch doubles or drops part of the path, which usually returns 404.

Is a Router One model in TRAE billed by TRAE or by Router One?

Router One bills each request on your key at the model's posted rate, and Dashboard → Logs lists every one. TRAE's international billing docs meter each model request in Dollar Usage and don't mention custom models; the Usage page on the TRAE website lists each charge with the model used, so check it after a test request. Requests made in Auto Mode run on TRAE's built-in models, not on your key.

Which models can TRAE use through the gateway?

Choose a current catalog model that supports both the endpoint and the features TRAE uses. Check /models and the model detail page for the exact ID, current rates, and capabilities; a family name such as GPT or Claude is not a compatibility guarantee. A client that lists a model has only read the ID, from its own configuration or from GET /v1/models; verify an actual request too.

Models are listed, but requests fail with 400 or 404. What should I check?

Record the actual request path and error message, then check the exact model ID. A 400 can indicate invalid parameters, unsupported tools, or a model/endpoint mismatch; a 404 can indicate an incorrect path or missing resource, so it does not by itself establish that a model was retired. If the error says must be called via, use the named endpoint or select a model supported on the current endpoint. Do not add or remove /v1 or /chat/completions across all clients indiscriminately.

Does this work from Mainland China?

Yes. The gateway is reachable from Mainland China without a VPN, and the configuration is identical to the global setup.

How do I debug a 401/402/403/429?

Start from what your client received: the status, the error body and the X-Request-ID header. A 401 (missing, unknown, revoked or expired key), a 402 (wallet balance, or the key's maxSpend cap) and a 429 from your key's or account's rate limits are refused before any model is called, so they never appear in Dashboard → Logs — nor does a 400 or 404 for a wrong model ID or endpoint. For 401, check that the full key is sent and still active in Dashboard → API Keys; for 402, top up or raise the key's maxSpend; for a 403, keep the full error body. For 429, back off and retry later; a 429 that does show up in Logs came back from upstream after the gateway's retries. Keep the request_id and follow the error-codes reference.