AI APIs: Protocol, API Key, and First Request

Before connecting an AI API, determine which contract your client expects: OpenAI-compatible or Anthropic-compatible. Use the provider's documented Base URL, keep the API key out of code, and send one short request. Verify HTTP status, model, usage, and the Dashboard record rather than trusting a saved settings form.

Want to verify the protocol with one safe request? BetterToken provides separate OpenAI-compatible and Anthropic-compatible interfaces with connection documentation. Create your own API key, use the protocol expected by your client, and test the smallest call first.

API access is not a web subscription

An API call is an HTTP request authenticated with your key. A web subscription grants access to a product interface and may have a separate balance and terms. A shared third-party account introduces additional policy and security risk and is unnecessary for a normal API integration.

BetterToken users work with their own BetterToken account and API key. The service is not ChatGPT Plus, Claude.ai, or an official OpenAI/Anthropic subscription.

Choose the protocol from the client

Use OpenAI-compatible when the client expects an OpenAI SDK, Chat Completions, Responses API, or a setting such as OPENAI_BASE_URL. Use Anthropic-compatible when the client creates Messages requests and uses ANTHROPIC_BASE_URL or x-api-key.

The model name does not determine the protocol. Client and server must implement the same request contract.

BetterToken uses different Base URLs:

OpenAI-compatible:    https://www.bettertoken.ai/v1
Anthropic-compatible: https://www.bettertoken.ai

The second value is a Base URL for compatible clients. A raw Anthropic Messages request uses the full path https://www.bettertoken.ai/v1/messages.

Base URL versus request path

An SDK or tool normally asks for a Base URL and appends its own resource path. A direct HTTP request needs the full path. For example, a raw OpenAI-compatible Chat Completions call may use https://www.bettertoken.ai/v1/chat/completions, while Anthropic Messages uses /v1/messages.

Do not paste a full request path into a field that expects only the Base URL. The client may append the resource again and return 404.

Keep the key outside code

For a local test, use a dedicated environment variable or the client's secret store. Use only placeholders in documentation and repositories:

export BETTERTOKEN_API_KEY="your_api_key_here"
export BETTERTOKEN_MODEL_ID="your_current_model_id"

Never put the real key in source code, an example environment file, an issue, a prompt, or a screenshot. Use a platform secret manager in production.

Verify the minimum call

Copy the current Model ID and request format from the provider documentation. Send a short text-only request without streaming or tools. Confirm:

  • a successful HTTP status;
  • the expected Model ID or documented display name;
  • a usage object when the chosen contract returns one;
  • a matching Dashboard record with model, status, applicable input/output/cache tokens, and charge.

Link to the current model catalog instead of hard-coding a dynamic price or model list.

Diagnose failures by layer

A 401 points to the key or authentication method; do not swap Bearer and x-api-key headers unless the protocol requires it. A 404 often means a duplicated /v1 or resource path. model not found requires the current exact API ID and an appropriate key/provider path. For timeout or TLS errors, separate local proxy, firewall, and certificate conditions from an API response. Do not permanently disable TLS verification.

After the minimal call succeeds, add streaming, tools, long context, or an agent loop one layer at a time. Each feature has its own event format and failure modes.

Related articles