Trae with a custom OpenAI-compatible endpoint

In short: Trae's request-URL field is either a base URL or a full URL depending on a full-URL switch, which is why two guides give opposite answers about /v1 and neither is wrong. The API format selector changes the appended path, so the format has to be chosen before the URL. A rejected save names no field, and the model ID is typed by hand rather than fetched, so a display name fails as an unknown model.

Trae is ByteDance's AI IDE, and unlike most editors in this cluster it does not ask you to edit a JSON file, a custom model is a short form. The endpoint field is the one that stops people, because two write-ups will tell you opposite things about /v1 and both are right, for different positions of the same switch.

Trae accepts two API surfaces. Under Settings → Models → Add Model → Custom Config you choose an API format — OpenAI Chat Completions or Anthropic Messages And then supply a request URL, a model ID and a key. That is the whole form.

The trap is that the URL field is not a base URL. It is either a base URL or a full URL, and a toggle decides which. Everything that follows hangs off that one switch.

You need a key before the code below runs. Create an account, generate a key, and copy the base URL (https://aicomp.ai/v1). Create one free →
Check current rates → Free to sign up · $1 minimum top-up · No prepayment

The full-URL switch decides whether /v1 belongs

Trae's own documentation describes two modes for the request address:

Switch positionWhat you pasteWhat Trae does
Full URL off (the usual failure)a base address, version segment included, no trailing slashappends the path for the chosen API format, e.g. /chat/completions
Full URL onthe complete request addressappends nothing

Read that as a rule about who owns the tail of the URL. When the switch is off, Trae owns everything after the version segment and you must not type it. When the switch is on, you own the whole address and Trae touches nothing.

This is why the two guides contradict each other. A writer who had the switch off correctly reports that the field must end in /v1 and must not carry a path. A writer who had it on correctly reports that you paste the full path including /chat/completions. Neither mentions the switch, so both look wrong to whoever reads the other first.

The doubled segment is the symptom when you get it backwards: paste https://gw.example.com/v1 with the switch on and the request goes out as-is; paste it with the path already attached and the switch off, and you get /v1/chat/completions appended to something that already ended in /chat/completions.

Decide the mode first, then type. Do not type and then try to remember.

Pick the API format before the URL

The format selector is not cosmetic, it changes what Trae appends, and therefore what your base URL should be.

This matters for a gateway because the two formats are not interchangeable at the path level. If your endpoint serves an OpenAI-shaped surface, selecting Anthropic Messages sends the wrong path and the wrong body shape; the reply is an error that looks like an auth problem.

Set the format, then set the URL to match it. Changing the format after pasting a URL is a common way to introduce the doubled or mismatched path without editing the URL at all.

Save triggers a live check, and the failure is not diagnostic

Trae validates the key when you save. That is convenient right up to the moment it fails, because the message does not tell you which of the three fields is wrong.

When a save is rejected, the candidates are, in the order worth checking:

  1. The path. A doubled version segment, a trailing slash, or a path left on a field that should have been a base address. This is the most common cause and the least obvious, because the form is full of valid-looking text.
  2. The model ID. Trae does not fetch a model list. Whatever string you type is sent verbatim, so a display name where the API expects an ID fails as an unknown model.
  3. The key. Genuinely wrong, or from a different account than the endpoint expects.

Work down that list rather than editing the URL repeatedly. The path is where the fixes usually are.

The four fields people leave at defaults

Opening the advanced section of the form exposes settings that quietly change cost and behaviour:

FieldWhy it is worth setting
Context windowSome models advertise a large window but are billed or truncated differently at the top end
Image inputA capability flag; enabling it on a text-only model produces errors that read like request-format problems
Temperature / Top P / Top KPer-model. A value tuned for one model is not a safe default for another

Trae notes that your custom values take precedence over the model-family presets it ships. That is the useful part: setting the context window explicitly stops the IDE from guessing on your behalf.

Routing an IDE through one endpoint

An IDE is a high-volume, unfriendly client. Trae's agent mode resends the conversation on every turn, and the completion path fires continuously while you type — the two shapes that dominate a bill are the ones with the most input tokens and the smallest outputs, plus long agent loops.

A working month on this setup runs about 260k input and 30k output tokens a day, which is 5.2M input and 0.6M output across 20 working days. That ratio is the reason the two slots should not share one model: completion lives almost entirely in the input column, while the agent panel spends far more on output.

Per 1M input / output tokens and a 20-day month
ModelGateway rate
in / out per 1M tokens
One day20 days
gpt-5.6-terra$1.00 / $6.00$0.44$8.80
claude-sonnet-5$1.00 / $5.00$0.41$8.20
deepseek-v4-pro$0.66 / $1.98$0.23$4.62
glm-5.3$0.70 / $2.2$0.25$4.96

One day = 260k input + 30k output on this page's workload. 20 days = 5.2M input and 0.6M output. Rates checked 2026-10-15 (gateway rates move with upstream promotions), so verify the current number in your dashboard before committing to a budget.

Two practical notes that follow from the table rather than from Trae itself:

Across 221 catalogue models that publish both rates, the median output rate is 4.0× the input rate, and 69% of them (153 models) charge at least 4× more for output than input. The other 624 raw catalogue entries are dropped by cleaning (test entries, dated snapshots and non-chat variants) not for a missing rate. This is why an agent workload is decided on the output column, not the input one everyone quotes.

If you are choosing between models for this role, the <a href="/guides/cheapest-models-by-workload/">re-ranked index</a> sorts by workload shape rather than by input price, which is the comparison an IDE actually needs.

What to change if it still will not connect

Work through the list in order — each item eliminates a class of cause rather than a single guess:

  1. Turn the full-URL switch off and paste a base address that ends at the version segment, no trailing slash. If this connects, the switch was the whole problem.
  2. Confirm the API format matches the surface your endpoint serves. Open a terminal against the same base URL and call the chat route directly; if that works, the endpoint is fine and the format selector is the suspect.
  3. Re-copy the model ID from the endpoint's model list, not from the model's marketing page, the two differ constantly.
  4. Re-issue the key and paste it without surrounding whitespace.

FAQ

FAQ

Does Trae need the base URL to end in /v1?

Only in the switch-off mode. With the full-URL switch off, Trae appends the path for the chosen API format, so the version segment is yours and everything after it is Trae's — include /v1, exclude the route. With the switch on, you supply the entire address and /v1 is simply part of it.

Why do two guides give me opposite answers about the path?

Almost always because they were written against different switch positions and neither mentioned it. The rule is about ownership of the tail of the URL, not about a fixed spelling.

Can Trae use a Claude model and a GPT model at the same time?

Yes. Add each as its own custom model entry, changing the model ID and, if the surfaces differ, the API format. The endpoint and key can stay the same.

Does Trae pull the model list from my endpoint?

No. The model ID is typed by hand and sent verbatim, so it has to match the identifier the endpoint expects exactly.

Will the same configuration work for completion and agent mode?

Both use the configured model, but they stress it differently, completion is small, frequent and latency-sensitive, while agent mode is input-heavy and long-lived. It is worth pointing them at different models rather than optimising for one and living with the other.

Related

Get API access

Rate cards: GPT, Claude and DeepSeek