Developer guide
Authenticate with an API key
The header containing the API key and the base URL to set in the SDK
This page covers how to authenticate with an API key to the CLEVI gateway.
Both the OpenAI-compatible path and the Anthropic-compatible path use a single key for authentication,
but the accepted header containing the key and the base URL to set in the SDK differ by specification.
Authentication headers
Both compatible specifications use a single API key for authentication. The key is issued on the API Keys page in the console, where you can also revoke it and manage its usage scope.
| Header | OpenAI-compatible | Anthropic-compatible |
|---|---|---|
| X-API-Key: <키> | Accepted | Accepted |
| Authorization: Bearer <키> | Accepted | Accepted |
| Authorization: <키> (without Bearer) | Rejected | Accepted |
Header names are case-insensitive. x-api-key sent by the Anthropic SDK also works as is.
base URL
Existing SDKs will continue to work if you only change the base URL to the address below. The two addresses differ in whether they include /v1.
| Specification | base URL | Path rules |
|---|---|---|
| OpenAI-compatible | https://platform.clevi.net/api/v2/aiservice/openai/v1 | Include /v1 in the base URL. |
| Anthropic-compatible | https://platform.clevi.net/api/v2/aiservice/anthropic | The Anthropic SDK adds /v1 to the path itself, so the base URL 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 perform 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)Replace sk-... with the key issued on the API Keys page.
- 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 the items in the Authentication failure section below, in order.
Headers used together
All are optional. To track issues, it is recommended to include X-Request-Id.
| Header | Purpose | If omitted |
|---|---|---|
| X-Request-Id | Identifier for request tracking. It is returned as the request-id header in Anthropic-compatible responses. | Issued by the server. |
| X-Region-Code | Call region | It is global. |
| 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 paths. | Required for voice paths. For audio/speech and audio/transcriptions, select the Product using model in the body. |
| anthropic-version / anthropic-beta | Passed through unchanged on Anthropic-compatible paths. | 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 call without a key on an OpenAI-compatible path, the response body below is returned, and error.type is authentication_error on an Anthropic-compatible path.
{
"error": {
"message": "API key is required.",
"type": "invalid_request_error"
}
}- Check the key status on the API keys page. If the key has expired or been revoked, issue a new one.
- Check whether the header name is X-API-Key or Authorization.
- If you use Authorization on an OpenAI-compatible path, check the Bearer prefix.
