Skip to main content
HaiToken LLM gateway supports three API protocols: OpenAI Chat Completions, OpenAI Responses, and Anthropic Claude Messages. You can get started in three steps: get your API key, call the API, and connect to AI tools.

Step 1: Get your API key

  1. Register and log in to the HaiToken console
  2. Navigate to Token management in the left sidebar
  3. Click Create API Key, enter a name, and generate your key
  4. Copy and securely store the generated API key (it is shown only once)
Keep your API key secure. Do not expose it in client-side code or public repositories.

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 the POST /v1/chat/completions protocol.

OpenAI Responses format

For SDKs and tools that use the OpenAI Responses API, send requests to POST /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 the POST /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

  1. Open Cursor, go to Settings > Models
  2. Enter your API key in the OpenAI API Key field
  3. Set OpenAI Base URL to https://api.haitoken.ai/v1
  4. 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 with ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, and ANTHROPIC_MODEL. For the complete screenshots and model-mapping steps, see Claude Code via CC Switch.

Open Code

  1. Add haitoken directly from the OpenCode TUI:
Launch the OpenCode TUI Type /connect In the provider list, choose “Other” (custom endpoint) Fill in: Base URL: https://api.haitoken.ai/v1 API Key: your haitoken API key After saving, type /models and switch to the newly added model
  1. Configure provider and base URL in the opencode.json file at your project root:
For more AI tool integration guides, see the AI tool integration section.

Next steps