Skip to content

KlingAIProvider

Namespace: Vercel.AI.KlingAI

public sealed class KlingAIProvider : OpenAICompatibleProvider

KlingAI provider. It supports video generation only.

Inheritance: object → ProviderBase → OpenAICompatibleProvider

View source

KlingAIProvider(HttpClient, OpenAICompatibleOptions?)

Section titled “KlingAIProvider(HttpClient, OpenAICompatibleOptions?)”
public KlingAIProvider(HttpClient httpClient, OpenAICompatibleOptions? options = null)

Creates a provider. Pass KlingAIOptions to use the legacy access key and secret key. The credentials are read when a request is sent, so a missing key fails then and not here.

Parameters

Name Type Description
httpClient HttpClient
options OpenAICompatibleOptions

View source

public const string DefaultBaseUrl = "https://api-singapore.klingai.com"

Default API origin.

Value: string

View source

public const string ProviderId = "klingai"

Provider id.

Value: string

View source

Create(OpenAICompatibleOptions?, HttpMessageHandler?)

Section titled “Create(OpenAICompatibleOptions?, HttpMessageHandler?)”
public static KlingAIProvider Create(OpenAICompatibleOptions? options = null, HttpMessageHandler? handler = null)

Creates a provider.

Parameters

Name Type Description
options OpenAICompatibleOptions Provider options.
handler HttpMessageHandler Optional message handler. The provider follows redirects by hand so a status poll cannot send the credentials to another host. For that reason it sets AllowAutoRedirect = false on a supplied HttpClientHandler or (on .NET 5 and later) SocketsHttpHandler, including one wrapped in DelegatingHandlers. This changes the handler you pass, and it throws if the handler has already sent a request. Any other handler type that exposes a public settable bool AllowAutoRedirect property is changed by reflection. Any remaining handler is left as is. It must not follow redirects on its own.

Returns: KlingAIProvider

View source

public override IEmbeddingModel EmbeddingModel(string modelId)

Returns an embedding model.

Parameters

Name Type Description
modelId string

Returns: IEmbeddingModel

View source

public override IImageModel ImageModel(string modelId)

Returns an image model.

Parameters

Name Type Description
modelId string

Returns: IImageModel

View source

public override ILanguageModel LanguageModel(string modelId)

Returns a language model.

Parameters

Name Type Description
modelId string

Returns: ILanguageModel

View source

protected override string? ResolveApiKey()

Resolves the bearer token on every call. An API key is sent as is. A legacy access key and secret key sign a fresh JWT.

Returns: string

View source

public IVideoModel Video(string modelId)

Creates a video model. Same as VideoModel(string).

Parameters

Name Type Description
modelId string

Returns: IVideoModel

View source

public override IVideoModel VideoModel(string modelId)

Returns a video model.

Parameters

Name Type Description
modelId string

Returns: IVideoModel

View source

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