Developer guide

Authenticate with an API key

The header containing the API key and the base URL to configure in the SDK

This page explains how to authenticate with an API key at the CLEVI gateway.
Both the OpenAI-compatible and Anthropic-compatible paths use a single key for authentication,
but the permitted header containing the key and the base URL to configure in the SDK differ by specification.

Authentication headers

Both compatible specifications use a single API key for authentication. Keys are issued on the API Keys page in the console, where you can also revoke them and manage their usage scope.

HeaderOpenAI-compatibleAnthropic-compatible
X-API-Key: <키>AcceptedAccepted
Authorization: Bearer <키>AcceptedAccepted
Authorization: <키> (without Bearer)RejectedAccepted

Header names are case-insensitive. x-api-key sent by the Anthropic SDK also works as is.

base URL

SDKs you already use will continue to work if you only change the base URL to the address below. The two addresses differ in whether they include /v1.

Specificationbase URLPath rules
OpenAI-compatiblehttps://platform.clevi.net/api/v2/aiservice/openai/v1Include /v1 in the base URL.
Anthropic-compatiblehttps://platform.clevi.net/api/v2/aiservice/anthropicThe Anthropic SDK adds /v1 to the path itself, so it ends before /v1.

Verify authentication

You can immediately verify whether authentication is working by entering the key and base URL and retrieving the model list. The three examples below make the same request using curl, the OpenAI SDK and the Anthropic SDK.

curl https://platform.clevi.net/api/v2/aiservice/openai/v1/models \
  -H "X-API-Key: sk-..."

curl https://platform.clevi.net/api/v2/aiservice/anthropic/v1/models \
  -H "Authorization: Bearer sk-..." \
  -H "anthropic-version: 2023-06-01"
from openai import OpenAI

client = OpenAI(
    api_key="sk-...",
    base_url="https://platform.clevi.net/api/v2/aiservice/openai/v1",
)

for model in client.models.list():
    print(model.id)
from anthropic import Anthropic

client = Anthropic(
    api_key="sk-...",
    base_url="https://platform.clevi.net/api/v2/aiservice/anthropic",
)

for model in client.models.list(limit=20).data:
    print(model.id)

Enter the key issued on the API Keys page in place of sk-....

  • A 200 response means authentication was successful. data contains the list of models that can be called with this key.
  • If the response is 401, check in the order described in the Authentication failure section below.

Headers used together

All are optional. To track issues, it is best to include X-Request-Id.

HeaderPurposeIf omitted
X-Request-IdAn identifier for tracking requests. It is returned as the request-id header in Anthropic-compatible responses.Issued by the server.
X-Region-CodeRequest regionglobal.
X-Product-Sku (also available as the product_sku query parameter)Directly specifies the Product SKU to use for billing. The header takes precedence over the query parameter and is mainly used for voice and voice-related routes.Required for voice routes. For audio/speech and audio/transcriptions, select the Product with model in the request body.
anthropic-version / anthropic-betaPassed through unchanged on Anthropic-compatible routes.The version is 2023-06-01.

Authentication failure

If you send a missing, expired or revoked key, the response is 401. If you make a request without a key on an OpenAI-compatible route, the response body below is returned; the error.type on Anthropic-compatible routes is authentication_error.

{
  "error": {
    "message": "API key is required.",
    "type": "invalid_request_error"
  }
}
  1. Check the key status on the API key page. If the key has expired or been revoked, issue a new one.
  2. Check whether the header name is X-API-Key or Authorization.
  3. If you use Authorization on an OpenAI-compatible route, check the Bearer prefix.
CLEVI

Language and region

Machine-translated languages are marked. Availability follows the published site bundle.

136 languages

Recommended

1

East Asia

7

Southeast Asia

11

South Asia

18

Central Asia

5

Middle East and the Caucasus

10

Western and Southern Europe

16

Britain and Ireland

4

Northern Europe and the Baltics

10

Central Europe and the Balkans

14

Eastern Europe

5

East Africa and the Horn

8

West and Central Africa

9

Southern Africa

8

The Americas

5

The Pacific

5