Trae custom models: run Claude and GPT with one API key

One Code By AI key runs Claude and GPT inside Trae, billed per token with no subscription and no separate vendor API accounts.

Live catalog token rates: Claude is 1/4 of official list price; GPT/Codex text models are 1/10. See pricingBrowse models

Official subscription vs official API vs Code By AI

Only the qualitative differences are listed here; this page does not quote plan prices.

AspectOfficial subscriptionOfficial APICode By AI
BillingA flat monthly fee per planPer-token usage charged by the vendorPer-token usage, no subscription
AccountsOne account per vendor and planA vendor account with API access and billing enabledOne Code By AI account and key for Claude and GPT
Model rangeThe models the plan exposes, inside the plan's quotaOne vendor's models at that vendor's list priceClaude and GPT through the same OpenAI-compatible endpoint
Usage limitQuotas tied to the planVendor rate limits and prepaid creditSpend from your balance and top up when it runs out
Cost structureA fixed monthly charge whether or not the quota is usedThe vendor's list price per tokenUsage-based: Claude at 1/4 of list price, GPT/Codex text at 1/10

Configure Trae

Trae is ByteDance's AI IDE and keeps custom models inside the app, so setup.sh cannot configure it. Add the endpoint and key in the model manager. Trae official site

  1. 1. Create an API key

    Sign in to Code By AI and create a key on the API Keys page. It looks like sk-proj-...

  2. 2. Open the model settings

    In Trae, open Settings → Models and click Add model. The same manager opens from the model picker in a chat.

  3. 3. Add a custom configuration

    Choose Custom configuration and set API format to OpenAI Chat Completions. With Full URL off, enter https://www.codebyai.net/api/agent/v1 as the request URL, paste the key, and set the model ID to gpt-5.6-terra. Save the model and select it in the chat's model picker.

  4. 4. Keep Full URL off unless you paste the full path

    With Full URL off, Trae appends /chat/completions itself. If you turn it on, enter https://www.codebyai.net/api/agent/v1/chat/completions instead. Do not mix the two, or requests return 404.

  5. 5. Add Claude

    Add a second configuration with the same URL and key, and set the model ID to claude-sonnet-5. The gateway routes claude-* IDs to the Claude channel and bills Claude prices, so both families share one endpoint.

  6. 6. Verify

    Send a short message in a new chat. In Usage History, check which model’s token count increased and compare its name with the ID you entered in Trae. A mistyped ID is rejected with HTTP 400 and is not answered by another model.

Base URL (Full URL off): https://www.codebyai.net/api/agent/v1
Full URL (switch on): https://www.codebyai.net/api/agent/v1/chat/completions
Model ID: gpt-5.6-terra / claude-sonnet-5

SOLO: turn AUTO off first

Inside SOLO, turn AUTO off before selecting a custom model; otherwise the agent may keep routing to a built-in model.

Read the Trae guide

FAQ

How does Code By AI bill requests from Trae?
When Trae sends a request with your Code By AI key, Code By AI deducts the token cost from your balance. You can check the usage and cost in Usage History.
Where does the API key go?
Paste it into the credential field of the custom configuration in Trae's model manager. Trae stores custom models inside the app, so setup.sh has no file it can safely edit, and the key should never be committed to a repository.
Why is my custom model ignored in SOLO?
AUTO is probably still on. Turn AUTO off before choosing a custom model, or the agent may keep routing to a built-in model.
Why does a request return 404?
The request URL and the Full URL switch disagree. Either turn Full URL off and use the base URL, or turn it on and use the full /chat/completions URL. Do not mix the two.
Why did my request return 403?
Read the error message. “Invalid key” means you should check the pasted key and replace it if it was deleted or expired. If the message mentions the API key quota, check its limit on the API Keys page. If it mentions insufficient balance or the user quota, check your wallet balance and top up if needed.
How do I switch between Claude and GPT?
Save one custom configuration for each model. Use the same endpoint and API key for both, enter the corresponding model ID in each, then select the model you want in the chat.

Steps and error codes above follow the Trae guide. Read the Trae guide

Try Trae with a Code By AI key

Create a key, top up your balance, and keep one endpoint for Claude and GPT.