Skip to content

KlingAIAuth

Namespace: Vercel.AI.KlingAI

public static class KlingAIAuth

Resolves the bearer token for KlingAI API requests. KlingAI accepts a single API key sent as a bearer token, or a legacy access key / secret key pair that signs a short-lived JWT.

Inheritance: object

View source

public const string AccessKeyEnvironmentVariable = "KLINGAI_ACCESS_KEY"

Environment variable that holds the legacy access key.

Value: string

View source

public const string ApiKeyEnvironmentVariable = "KLINGAI_API_KEY"

Environment variable that holds the API key.

Value: string

View source

public const string SecretKeyEnvironmentVariable = "KLINGAI_SECRET_KEY"

Environment variable that holds the legacy secret key.

Value: string

View source

public static string GenerateAuthToken(string? accessKey = null, string? secretKey = null)

Signs a JWT (HS256) from a legacy access key / secret key pair. The token is valid for 30 minutes. A missing key falls back to its environment variable.

Parameters

Name Type Description
accessKey string
secretKey string

Returns: string

View source

ResolveAuthToken(string?, string?, string?)

Section titled “ResolveAuthToken(string?, string?, string?)”
public static string ResolveAuthToken(string? apiKey = null, string? accessKey = null, string? secretKey = null)

Resolves the bearer token. Explicit values win over environment variables, and the API key wins over the access key / secret key pair: apiKey, then accessKey with secretKey, then KLINGAI_API_KEY, then KLINGAI_ACCESS_KEY with KLINGAI_SECRET_KEY.

Parameters

Name Type Description
apiKey string
accessKey string
secretKey string

Returns: string

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product