Step 1: Get your API key
- Register and log in to the HaiToken console
- Navigate to Token management in the left sidebar
- Click Create API Key, enter a name, and generate your key
- Copy and securely store the generated API key (it is shown only once)
Step 2: Call the API
HaiToken offers three API formats. Choose the one required by your client or SDK; the model ID itself does not determine the protocol.Which protocol should I use?
Select the protocol required by the client or SDK first. If it supports more than one format, use the following guidance:- Choose Chat Completions for the broadest compatibility. It is the best default for existing OpenAI-compatible applications, older SDKs, and tools that send conversation history in
messages. - Choose Responses for new integrations that explicitly use the OpenAI Responses API or need its
input-based request format and Responses-specific features. See Responses format API. - Choose Anthropic Messages for Claude Code, Anthropic SDKs, and other Claude ecosystem tools that expect the native Messages format.
Do not select a protocol based only on the model name. The same model can be called through different supported protocols; the client request format determines the correct endpoint.
OpenAI format
For OpenAI-compatible models, using thePOST /v1/chat/completions protocol.
OpenAI Responses format
For SDKs and tools that use the OpenAI Responses API, send requests toPOST /v1/responses. HaiToken supports streaming, tool calling, structured outputs, reasoning configuration, and web-search options on this endpoint.
See Responses format API for the request format and examples.
Claude format
For Anthropic Claude models, using thePOST /v1/messages protocol.
When calling the Claude format API, include the
anthropic-version header. The recommended value is 2023-06-01.Step 3: Connect to AI tools
Once you have your API key and the API is verified, you can connect HaiToken to popular AI coding tools.Cursor
- Open Cursor, go to Settings > Models
- Enter your API key in the OpenAI API Key field
- Set OpenAI Base URL to
https://api.haitoken.ai/v1 - Save and select from the available models in the model list
Claude Code
Claude Code supports two setup methods: configure a provider through CC Switch, or configure the Claude Code CLI directly withANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, and ANTHROPIC_MODEL.
For the complete screenshots and model-mapping steps, see Claude Code via CC Switch.
Open Code
- Add haitoken directly from the OpenCode TUI:
- Configure provider and base URL in the
opencode.jsonfile at your project root:
Next steps
- See the API reference for complete endpoint parameters
- See Model list for available models
- See Rate limits for API call limits