API Authentication

This guide explains how to choose an integration mode for the AI Gateway, configure request URLs and API keys, and send model API requests.

Prerequisites

Before sending a request, make sure you have the following ready:

  • API Key: Create and copy your full secret key from API Keys in the console. Ensure the key is active and has not expired.
  • Model ID: Find the target model’s ID in the Model Catalog and verify that the model is included in the model configuration associated with your API key.
  • Integration Mode and Endpoint: Check the API Examples tab of the target model to confirm its supported protocols and endpoints. Supported protocols, endpoints, and parameters may vary by model.

Configuring Request URLs and Authentication

Gateway Base URL

A full request URL consists of the gateway base URL, the protocol path prefix, and the endpoint path:

Full Request URL = Gateway Base URL + Protocol Path Prefix + Endpoint Path
  • Gateway Base URL: Fixed as https://api.tokencube.net/v2/llm.
  • Protocol Path Prefix: Specifies the underlying forwarding protocol (e.g., /openai, /anthropic, /gemini). Omit this prefix when using OpenAI-Compatible Mode.
  • Endpoint Path: Specifies the API operation, such as /chat/completions.

Choosing an Integration Mode and Protocol

You can choose between two integration modes based on your business needs:

  • Native Passthrough Protocol (OpenAI / Anthropic / Gemini — Recommended): The gateway forwards requests directly to the corresponding model provider. This mode preserves full support for provider-native parameters and tool capabilities. When a target model supports both integration modes, we recommend using this mode.
  • OpenAI-Compatible Mode (Unified API): Uses the standard OpenAI API format to seamlessly call most mainstream models available on the platform (including Claude, DeepSeek, and more). The gateway automatically handles protocol translation under the hood, significantly reducing the effort required to integrate and switch between multiple models.

Protocol and Endpoint Path Reference

The table below lists common chat and content generation endpoints (all using the POST method). Please confirm that your target model supports the corresponding protocol and endpoint before calling.

Mode / Protocol Protocol Path Prefix Endpoint Path
OpenAI-Compatible Mode None /chat/completions
OpenAI Protocol /openai /chat/completions
Anthropic Protocol /anthropic /v1/messages
Gemini Protocol: Non-streaming /gemini /v1beta/models/{model}:generateContent
Gemini Protocol: Streaming /gemini /v1beta/models/{model}:streamGenerateContent

For example, the full URL for the chat completions endpoint in OpenAI-Compatible Mode is:

https://api.tokencube.net/v2/llm/chat/completions

Authentication (API Key)

The gateway uses standard Bearer Token authentication. When making an HTTP request, include the Authorization header with your API key:

Authorization: Bearer <YOUR_API_KEY>

Tip: When using official Anthropic or Gemini SDKs with the Native Passthrough Protocol, the gateway also supports provider-native authentication headers (x-api-key for Anthropic and x-goog-api-key for Gemini).

Example Request

The following example shows a complete request calling the claude-sonnet-4-6 model using OpenAI-Compatible Mode (replace <YOUR_API_KEY> with your actual API key):

curl https://api.tokencube.net/v2/llm/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {
        "role": "user",
        "content": "Hello, please introduce yourself."
      }
    ]
  }'