Notice: Kling 4.0 is here: text-to-video and image-to-video are 20% off for a limited time. Try it now
HiAPI
Tutorials
On this page

Trae

Add a custom model in Trae, choose the right API format for the model and fill in the address to use Claude, GPT, DeepSeek and other models through HiAPI.

Trae can connect to HiAPI through a custom model. Trae’s API format (API 格式) differs by protocol, and a model only connects if the format is right. There is one example for each: claude-opus-5-5 with the Anthropic Messages format and gpt-6-astra with the OpenAI Chat Completions format. This tutorial was verified on Trae 3.4.4.

1. Prepare a HiAPI API key

Prepare a key as described in Get an API Key, click the copy icon next to the key, and copy the full HiAPI API key to fill into Trae below.

2. Choose the API format

ProtocolChoose in TraeSuitable models
Anthropic MessagesAnthropic Messages formatClaude series
OpenAI Chat CompletionsOpenAI Chat Completions formatGPT series, DeepSeek series
OpenAI ResponsesOpenAI Responses API formatScenarios that need Responses features

The example models on this page have all been tested with the table above. For another model, choose the format from the table first, save and send a message to try it; if you get 400 does not support this endpoint, switch to another format.

3. Connect Claude (Anthropic Messages format)

3.1 Open the entry

Open settings in the lower left of Trae, find Models (模型) on the left, and click Add Model → Custom Model (添加模型 → 自定义模型).

Add a custom model

3.2 Fill in the fields

With claude-opus-5-5 as the example:

FieldValue
API format (API 格式)Anthropic Messages format
Custom request address (自定义请求地址)https://api.hiapi.ai (without /v1)
Full URL (完整 URL)Off
Model ID (模型 ID)claude-opus-5-5
Model display name (模型展示名称)A name you’ll recognize, for example claude-opus-5-5 (HiAPI)
API key (API 密钥)your HiAPI API key

Trae appends /v1/messages to the end of the address automatically, so the final request goes to https://api.hiapi.ai/v1/messages.

Claude model configuration

3.3 Switch to another Claude model

Only change the model ID to the target model; leave the other fields as they are. See the model page for context length and max output.

4. Connect GPT and DeepSeek (OpenAI Chat Completions format)

Enter the same way, via Add Model → Custom Model (添加模型 → 自定义模型). With gpt-6-astra as the example:

FieldValue
API format (API 格式)OpenAI Chat Completions format
Custom request address (自定义请求地址)https://api.hiapi.ai/v1
Full URL (完整 URL)Off
Model ID (模型 ID)gpt-6-astra
Model display name (模型展示名称)A name you’ll recognize, for example GPT-6 Astra (HiAPI)
API key (API 密钥)your HiAPI API key

Trae appends /chat/completions to the end of the address automatically, so the final request goes to https://api.hiapi.ai/v1/chat/completions.

GPT model configuration

To use the Responses format, choose OpenAI Responses API format as the API format and also fill https://api.hiapi.ai/v1 as the address. This format only supports streaming output, so remember to keep streaming on.

5. Address cheat sheet

The path Trae appends changes with the API format, and a wrong address returns 404 straight away:

API formatFill inTrae appendsFinal address
Anthropic Messageshttps://api.hiapi.ai/v1/messages/v1/messages
OpenAI Chat Completionshttps://api.hiapi.ai/v1/chat/completions/v1/chat/completions
OpenAI Responseshttps://api.hiapi.ai/v1/responses/v1/responses

The rule: check whether the path Trae appends contains v1. If it does, don’t include v1 in what you fill in; if it doesn’t, include it yourself. Keep the Full URL (完整 URL) switch off so Trae appends the path; when it is on, you must enter the complete request address.

6. Verify

After saving the configuration, start a new session to test.

6.1 Chat

Switch to the model you just added and send “Hello, introduce yourself in one sentence.” A normal reply means the connection works.

Verify with a chat

6.2 Tool calling

First create tool-call-test.txt in the project folder open in Trae, write one line hello hiapi and save it. Then go to the task / Agent page and send “Only use the file reading tool once. Read the entire contents of tool-call-test.txt and return them exactly as they are. Do not modify the file, do not read any other files, and do not guess the contents from the file name.” A tool call appears and returns hello hiapi, so it passes. In testing, both claude-opus-5-5 and gpt-6-astra could chat and call tools normally.

Verify tool calling

This tutorial only covers text model access; to let Trae call HiAPI’s image and video tools, see the Trae section of the MCP setup guide.

7. Troubleshooting

Only issues specific to Trae are listed here. For common errors such as 401, 404 and 429, see Common errors.

ErrorCauseFix
404The address has an extra or missing /v1Fill it in according to the table in section 5
400 This model does not support this endpointThe API format and model don’t matchChoose the Anthropic Messages format for Claude; choose the OpenAI Chat Completions format for GPT and DeepSeek
401 / invalid api keyThe HiAPI API key is wrongPaste it again, with no spaces before or after
Errors about max_tokensMax output tokens is not setSet a reasonable value in the advanced configuration; when gpt-6-astra uses Chat Completions, do not set max_tokens or temperature
stream: must be trueThis model only supports streaming outputTurn on streaming output
Spinning forever / timeoutA network problem, or the wrong API formatCheck the network and confirm the API format is right