Skip to content

@graphty/graphty-element / catalog / checkApiKeyShape

Function: checkApiKeyShape() ​

checkApiKeyShape(id, key): AiKeyShapeCheck

Defined in: graphty-element/src/catalog/ai.ts:201

Whether a key has the shape of a provider's keys, without calling the provider. A key of the right shape can still be refused; LlmProvider.validateApiKey asks the provider itself.

Parameters ​

id ​

"openai" | "anthropic" | "google" | "webllm" | "mock"

The provider the key is for.

key ​

string

The key.

Returns ​

AiKeyShapeCheck

{ valid: true }, or the code saying what is wrong and its parameters.